plugin.h (1679B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef plugin_h__ 6 #define plugin_h__ 7 8 #include "clang/AST/ASTConsumer.h" 9 #include "clang/AST/ASTContext.h" 10 #include "clang/AST/RecursiveASTVisitor.h" 11 #include "clang/ASTMatchers/ASTMatchFinder.h" 12 #include "clang/ASTMatchers/ASTMatchers.h" 13 #include "clang/Analysis/CFG.h" 14 #include "clang/Basic/Version.h" 15 #include "clang/Frontend/CompilerInstance.h" 16 #include "clang/Frontend/MultiplexConsumer.h" 17 #include "clang/Sema/Sema.h" 18 #include "llvm/ADT/DenseMap.h" 19 #include "llvm/Support/FileSystem.h" 20 #include "llvm/Support/Path.h" 21 #include <memory> 22 23 #define CLANG_VERSION_FULL (CLANG_VERSION_MAJOR * 100 + CLANG_VERSION_MINOR) 24 25 using namespace llvm; 26 using namespace clang; 27 using namespace clang::ast_matchers; 28 29 #if CLANG_VERSION_FULL >= 306 30 typedef std::unique_ptr<ASTConsumer> ASTConsumerPtr; 31 #else 32 typedef ASTConsumer *ASTConsumerPtr; 33 #endif 34 35 #if CLANG_VERSION_FULL < 800 36 // Starting with Clang 8.0 some basic functions have been renamed 37 #define getBeginLoc getLocStart 38 #define getEndLoc getLocEnd 39 #endif 40 41 // In order to support running our checks using clang-tidy, we implement a 42 // source compatible base check class called BaseCheck, and we use the 43 // preprocessor to decide which base class to pick. 44 #ifdef CLANG_TIDY 45 #if CLANG_VERSION_FULL >= 900 46 #include "../ClangTidyCheck.h" 47 #else 48 #include "../ClangTidy.h" 49 #endif 50 typedef clang::tidy::ClangTidyCheck BaseCheck; 51 typedef clang::tidy::ClangTidyContext ContextType; 52 #else 53 #include "BaseCheck.h" 54 #endif 55 56 #endif // plugin_h__