Debian Codegraph @

src/checks/level2/virtual-call-ctor.h

raw
1 /*
2 SPDX-FileCopyrightText: 2015 Klarälvdalens Datakonsult AB a KDAB Group company [email protected]
3 SPDX-FileContributor: Sérgio Martins <[email protected]>
4
5 SPDX-FileCopyrightText: 2015 Sergio Martins <[email protected]>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9
10 #ifndef VIRTUALCALLSFROMCTOR_H
11 #define VIRTUALCALLSFROMCTOR_H
12
13 #include "checkbase.h"
14
15 #include <vector>
16
17 namespace clang
18 {
19 class CXXRecordDecl;
20 class SourceLocation;
21 }
22
23 /**
24 * Finds places where you're calling pure virtual functions inside a CTOR or DTOR.
25 * Compilers warn about this if there isn't any indirection, this plugin will catch cases like calling
26 * a non-pure virtual that calls a pure virtual.
27 *
28 * This plugin only checks for pure virtuals, ignoring non-pure, which in theory you shouldn't call,
29 * but seems common practice.
30 */
31 class VirtualCallCtor : public CheckBase
32 {
33 public:
34 using CheckBase::CheckBase;
35 void VisitDecl(clang::Decl *decl) override;
36
37 private:
38 clang::SourceLocation containsVirtualCall(clang::CXXRecordDecl *classDecl, clang::Stmt *stmt, std::vector<clang::Stmt *> &processedStmts);
39 };
40
41 #endif