File indexing completed on 2024-05-12 17:13:16
0001 /* 0002 This file is part of the clazy static checker. 0003 0004 Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com 0005 Author: Sérgio Martins <sergio.martins@kdab.com> 0006 0007 Copyright (C) 2015 Sergio Martins <smartins@kde.org> 0008 0009 This library is free software; you can redistribute it and/or 0010 modify it under the terms of the GNU Library General Public 0011 License as published by the Free Software Foundation; either 0012 version 2 of the License, or (at your option) any later version. 0013 0014 This library is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0017 Library General Public License for more details. 0018 0019 You should have received a copy of the GNU Library General Public License 0020 along with this library; see the file COPYING.LIB. If not, write to 0021 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0022 Boston, MA 02110-1301, USA. 0023 */ 0024 0025 #ifndef VIRTUALCALLSFROMCTOR_H 0026 #define VIRTUALCALLSFROMCTOR_H 0027 0028 #include "checkbase.h" 0029 0030 #include <vector> 0031 #include <string> 0032 0033 class ClazyContext; 0034 0035 namespace clang { 0036 class CXXRecordDecl; 0037 class Stmt; 0038 class SourceLocation; 0039 class Decl; 0040 } 0041 0042 /** 0043 * Finds places where you're calling pure virtual functions inside a CTOR or DTOR. 0044 * Compilers warn about this if there isn't any indirection, this plugin will catch cases like calling 0045 * a non-pure virtual that calls a pure virtual. 0046 * 0047 * This plugin only checks for pure virtuals, ignoring non-pure, which in theory you shouldn't call, 0048 * but seems common practice. 0049 */ 0050 class VirtualCallCtor 0051 : public CheckBase 0052 { 0053 public: 0054 VirtualCallCtor(const std::string &name, ClazyContext *context); 0055 void VisitDecl(clang::Decl *decl) override; 0056 0057 private: 0058 clang::SourceLocation containsVirtualCall(clang::CXXRecordDecl *classDecl, clang::Stmt *stmt, 0059 std::vector<clang::Stmt*> &processedStmts); 0060 }; 0061 0062 0063 #endif