Source code

Revision control

Other Tools

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 <iterator>
22
#include <memory>
23
24
#define CLANG_VERSION_FULL (CLANG_VERSION_MAJOR * 100 + CLANG_VERSION_MINOR)
25
26
using namespace llvm;
27
using namespace clang;
28
using namespace clang::ast_matchers;
29
30
#if CLANG_VERSION_FULL >= 306
31
typedef std::unique_ptr<ASTConsumer> ASTConsumerPtr;
32
#else
33
typedef ASTConsumer *ASTConsumerPtr;
34
#endif
35
36
#if CLANG_VERSION_FULL < 800
37
// Starting with Clang 8.0 some basic functions have been renamed
38
#define getBeginLoc getLocStart
39
#define getEndLoc getLocEnd
40
#endif
41
42
// In order to support running our checks using clang-tidy, we implement a
43
// source compatible base check class called BaseCheck, and we use the
44
// preprocessor to decide which base class to pick.
45
#ifdef CLANG_TIDY
46
#include "../ClangTidy.h"
47
typedef clang::tidy::ClangTidyCheck BaseCheck;
48
typedef clang::tidy::ClangTidyContext ContextType;
49
#else
50
#include "BaseCheck.h"
51
#endif
52
53
#endif // plugin_h__