15 : CheckName(CheckName), Context(Context),
16 Options(CheckName, Context->getOptions().CheckOptions) {
17 assert(Context !=
nullptr);
18 assert(!CheckName.empty());
22 DiagnosticIDs::Level Level) {
23 return Context->
diag(CheckName, Loc, Message, Level);
26 void ClangTidyCheck::run(
const ast_matchers::MatchFinder::MatchResult &
Result) {
35 : NamePrefix(CheckName.str() +
"."), CheckOptions(CheckOptions) {}
38 StringRef Default)
const {
39 const auto &Iter = CheckOptions.find(NamePrefix + LocalName.str());
40 if (Iter != CheckOptions.end())
47 StringRef Default)
const {
48 auto Iter = CheckOptions.find(NamePrefix + LocalName.str());
49 if (Iter != CheckOptions.end())
52 Iter = CheckOptions.find(LocalName.str());
53 if (Iter != CheckOptions.end())
60 StringRef Value)
const {
61 Options[NamePrefix + LocalName.str()] = Value;
66 int64_t Value)
const {
67 store(Options, LocalName, llvm::itostr(Value));
SourceLocation Loc
'#' location in the include directive
constexpr llvm::StringLiteral Message
DiagnosticBuilder diag(StringRef CheckName, SourceLocation Loc, StringRef Message, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Report any errors detected using this method.
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.
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.
std::string get(StringRef LocalName, StringRef Default) const
Read a named option from the Context.
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.