11 #include "clang/Frontend/CompilerInstance.h" 12 #include "clang/Lex/Preprocessor.h" 17 namespace readability {
22 : Check(Check), User(User ? *User :
"unknown"),
23 TodoMatch(
"^// *TODO *(\\(.*\\))?:?( )?(.*)$") {}
27 Lexer::getSourceText(CharSourceRange::getCharRange(Range),
28 PP.getSourceManager(), PP.getLangOpts());
30 SmallVector<StringRef, 4> Matches;
31 if (!TodoMatch.match(Text, &Matches))
34 StringRef Username = Matches[1];
35 StringRef Comment = Matches[3];
37 if (!Username.empty())
40 std::string NewText = (
"// TODO(" + Twine(User) +
"): " + Comment).str();
42 Check.
diag(Range.getBegin(),
"missing username/bug in TODO")
43 << FixItHint::CreateReplacement(CharSourceRange::getCharRange(Range),
51 llvm::Regex TodoMatch;
57 *this, Context->getOptions().User)) {}
60 Compiler.getPreprocessor().addCommentHandler(Handler.get());
Some operations such as code completion produce a set of candidates.
Base class for all clang-tidy checks.
static constexpr llvm::StringLiteral Name
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
CharSourceRange Range
SourceRange for the file name.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.