| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDY_H |
| 10 |
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDY_H |
| 11 |
|
| 12 |
#include "ClangTidyDiagnosticConsumer.h" |
| 13 |
#include "ClangTidyOptions.h" |
| 14 |
#include "llvm/ADT/StringSet.h" |
| 15 |
#include <memory> |
| 16 |
#include <vector> |
| 17 |
|
| 18 |
namespace llvm { |
| 19 |
class raw_ostream; |
| 20 |
} |
| 21 |
|
| 22 |
namespace clang { |
| 23 |
|
| 24 |
class ASTConsumer; |
| 25 |
class CompilerInstance; |
| 26 |
namespace tooling { |
| 27 |
class CompilationDatabase; |
| 28 |
} |
| 29 |
|
| 30 |
namespace tidy { |
| 31 |
|
| 32 |
class ClangTidyCheckFactories; |
| 33 |
|
| 34 |
class ClangTidyASTConsumerFactory { |
| 35 |
public: |
| 36 |
ClangTidyASTConsumerFactory( |
| 37 |
ClangTidyContext &Context, |
| 38 |
IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS = nullptr); |
| 39 |
|
| 40 |
|
| 41 |
std::unique_ptr<clang::ASTConsumer> |
| 42 |
createASTConsumer(clang::CompilerInstance &Compiler, StringRef File); |
| 43 |
|
| 44 |
|
| 45 |
std::vector<std::string> getCheckNames(); |
| 46 |
|
| 47 |
|
| 48 |
ClangTidyOptions::OptionMap getCheckOptions(); |
| 49 |
|
| 50 |
private: |
| 51 |
ClangTidyContext &Context; |
| 52 |
IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS; |
| 53 |
std::unique_ptr<ClangTidyCheckFactories> CheckFactories; |
| 54 |
}; |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
std::vector<std::string> getCheckNames(const ClangTidyOptions &Options, |
| 59 |
bool AllowEnablingAnalyzerAlphaCheckers); |
| 60 |
|
| 61 |
struct NamesAndOptions { |
| 62 |
llvm::StringSet<> Names; |
| 63 |
llvm::StringSet<> Options; |
| 64 |
}; |
| 65 |
|
| 66 |
NamesAndOptions |
| 67 |
getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers = true); |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
ClangTidyOptions::OptionMap |
| 76 |
getCheckOptions(const ClangTidyOptions &Options, |
| 77 |
bool AllowEnablingAnalyzerAlphaCheckers); |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
std::vector<ClangTidyError> |
| 87 |
runClangTidy(clang::tidy::ClangTidyContext &Context, |
| 88 |
const tooling::CompilationDatabase &Compilations, |
| 89 |
ArrayRef<std::string> InputFiles, |
| 90 |
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> BaseFS, |
| 91 |
bool ApplyAnyFix, bool EnableCheckProfile = false, |
| 92 |
llvm::StringRef StoreCheckProfile = StringRef()); |
| 93 |
|
| 94 |
|
| 95 |
enum FixBehaviour { |
| 96 |
|
| 97 |
FB_NoFix, |
| 98 |
|
| 99 |
FB_Fix, |
| 100 |
|
| 101 |
FB_FixNotes |
| 102 |
}; |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
void handleErrors(llvm::ArrayRef<ClangTidyError> Errors, |
| 112 |
ClangTidyContext &Context, FixBehaviour Fix, |
| 113 |
unsigned &WarningsAsErrorsCount, |
| 114 |
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS); |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
void exportReplacements(StringRef MainFilePath, |
| 119 |
const std::vector<ClangTidyError> &Errors, |
| 120 |
raw_ostream &OS); |
| 121 |
|
| 122 |
} |
| 123 |
} |
| 124 |
|
| 125 |
#endif |