9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYCHECK_H 10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYCHECK_H 14 #include "clang/ASTMatchers/ASTMatchFinder.h" 15 #include "clang/Basic/Diagnostic.h" 16 #include "clang/Basic/SourceManager.h" 17 #include "llvm/ADT/StringExtras.h" 19 #include <type_traits> 24 class CompilerInstance;
72 Preprocessor *ModuleExpanderPP) {}
90 virtual void check(
const ast_matchers::MatchFinder::MatchResult &
Result) {}
94 DiagnosticIDs::Level Level = DiagnosticIDs::Warning);
119 std::string
get(StringRef LocalName, StringRef Default)
const;
135 template <
typename T>
136 typename std::enable_if<std::is_integral<T>::value, T>::type
137 get(StringRef LocalName, T Default)
const {
138 std::string Value =
get(LocalName,
"");
141 StringRef(Value).getAsInteger(10, Result);
152 template <
typename T>
153 typename std::enable_if<std::is_integral<T>::value, T>::type
158 StringRef(Value).getAsInteger(10, Result);
165 StringRef Value)
const;
170 int64_t Value)
const;
173 std::string NamePrefix;
178 void run(
const ast_matchers::MatchFinder::MatchResult &
Result)
override;
179 StringRef getID()
const override {
return CheckName; }
180 std::string CheckName;
194 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYCHECK_H SourceLocation Loc
'#' location in the include directive
virtual void registerMatchers(ast_matchers::MatchFinder *Finder)
Override this to register AST matchers with Finder.
Provides access to the ClangTidyCheck options via check-local names.
StringRef getCurrentMainFile() const
Returns the main file name of the current translation unit.
Base class for all clang-tidy checks.
virtual void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP)
Override this to register PPCallbacks in the preprocessor.
const LangOptions & getLangOpts() const
Returns the language options from the context.
std::string getLocalOrGlobal(StringRef LocalName, StringRef Default) const
Read a named option from the Context.
void store(ClangTidyOptions::OptionMap &Options, StringRef LocalName, StringRef Value) const
Stores an option with the check-local name LocalName with string value Value to Options.
const LangOptions & getLangOpts() const
Gets the language options from the AST context.
StringRef getCurrentFile() const
Returns the main file name of the current translation unit.
std::map< std::string, std::string > OptionMap
ClangTidyCheck(StringRef CheckName, ClangTidyContext *Context)
Initializes the check with CheckName and Context.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
OptionsView(StringRef CheckName, const ClangTidyOptions::OptionMap &CheckOptions)
Initializes the instance using CheckName + "." as a prefix.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
virtual void check(const ast_matchers::MatchFinder::MatchResult &Result)
ClangTidyChecks that register ASTMatchers should do the actual work in here.
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
virtual void storeOptions(ClangTidyOptions::OptionMap &Options)
Should store all options supported by this check with their current values or default values for opti...
std::enable_if< std::is_integral< T >::value, T >::type getLocalOrGlobal(StringRef LocalName, T Default) const
Read a named option from the Context and parse it as an integral type T.