File indexing completed on 2024-04-28 05:38:31
0001 /* 0002 SPDX-FileCopyrightText: 2015 Klarälvdalens Datakonsult AB a KDAB Group company info@kdab.com 0003 SPDX-FileContributor: Sérgio Martins <sergio.martins@kdab.com> 0004 0005 SPDX-FileCopyrightText: 2015 Sergio Martins <smartins@kde.org> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #ifndef VIRTUALCALLSFROMCTOR_H 0011 #define VIRTUALCALLSFROMCTOR_H 0012 0013 #include "checkbase.h" 0014 0015 #include <string> 0016 #include <vector> 0017 0018 class ClazyContext; 0019 0020 namespace clang 0021 { 0022 class CXXRecordDecl; 0023 class Stmt; 0024 class SourceLocation; 0025 class Decl; 0026 } 0027 0028 /** 0029 * Finds places where you're calling pure virtual functions inside a CTOR or DTOR. 0030 * Compilers warn about this if there isn't any indirection, this plugin will catch cases like calling 0031 * a non-pure virtual that calls a pure virtual. 0032 * 0033 * This plugin only checks for pure virtuals, ignoring non-pure, which in theory you shouldn't call, 0034 * but seems common practice. 0035 */ 0036 class VirtualCallCtor : public CheckBase 0037 { 0038 public: 0039 VirtualCallCtor(const std::string &name, ClazyContext *context); 0040 void VisitDecl(clang::Decl *decl) override; 0041 0042 private: 0043 clang::SourceLocation containsVirtualCall(clang::CXXRecordDecl *classDecl, clang::Stmt *stmt, std::vector<clang::Stmt *> &processedStmts); 0044 }; 0045 0046 #endif