10 #include "clang/Frontend/CompilerInstance.h" 11 #include "clang/Lex/Preprocessor.h" 16 namespace readability {
21 : Check(Check), User(User ? *User :
"unknown"),
22 TodoMatch(
"^// *TODO *(\\(.*\\))?:?( )?(.*)$") {}
26 Lexer::getSourceText(CharSourceRange::getCharRange(Range),
27 PP.getSourceManager(), PP.getLangOpts());
29 SmallVector<StringRef, 4> Matches;
30 if (!TodoMatch.match(Text, &Matches))
33 StringRef Username = Matches[1];
34 StringRef Comment = Matches[3];
36 if (!Username.empty())
39 std::string NewText = (
"// TODO(" + Twine(User) +
"): " + Comment).str();
41 Check.
diag(Range.getBegin(),
"missing username/bug in TODO")
42 << FixItHint::CreateReplacement(CharSourceRange::getCharRange(Range),
50 llvm::Regex TodoMatch;
56 *this, Context->getOptions().User)) {}
60 Preprocessor *ModuleExpanderPP) {
61 PP->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.