File indexing completed on 2024-04-28 05:38:30

0001 /*
0002     SPDX-FileCopyrightText: 2015 Sergio Martins <smartins@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef CLANG_MISSING_Q_OBJECT_H
0008 #define CLANG_MISSING_Q_OBJECT_H
0009 
0010 #include "checkbase.h"
0011 
0012 #include <clang/Basic/SourceLocation.h>
0013 
0014 #include <string>
0015 #include <vector>
0016 
0017 class ClazyContext;
0018 
0019 namespace clang
0020 {
0021 class Decl;
0022 class SourceLocation;
0023 class MacroInfo;
0024 class Token;
0025 }
0026 
0027 /**
0028  * Finds QObject derived classes that don't have a Q_OBJECT macro
0029  *
0030  * See README-missing-qobject for more information
0031  */
0032 class MissingQObjectMacro : public CheckBase
0033 {
0034 public:
0035     explicit MissingQObjectMacro(const std::string &name, ClazyContext *context);
0036     void VisitDecl(clang::Decl *decl) override;
0037 
0038 private:
0039     void VisitMacroExpands(const clang::Token &MacroNameTok, const clang::SourceRange &range, const clang::MacroInfo *minfo = nullptr) override;
0040     void registerQ_OBJECT(clang::SourceLocation);
0041     std::vector<clang::SourceLocation> m_qobjectMacroLocations;
0042 
0043     bool m_hasAddedMocFile = false;
0044 };
0045 
0046 #endif