10#include "clang/Frontend/CompilerInstance.h"
11#include "clang/Lex/Preprocessor.h"
19 : Check(Check), User(User ? *User :
"unknown"),
20 TodoMatch(
"^// *TODO *(\\(.*\\))?:?( )?(.*)$") {}
24 Lexer::getSourceText(CharSourceRange::getCharRange(
Range),
25 PP.getSourceManager(), PP.getLangOpts());
27 SmallVector<StringRef, 4> Matches;
28 if (!TodoMatch.match(
Text, &Matches))
31 StringRef Username = Matches[1];
32 StringRef Comment = Matches[3];
34 if (!Username.empty())
37 std::string NewText = (
"// TODO(" + Twine(User) +
"): " + Comment).str();
39 Check.
diag(
Range.getBegin(),
"missing username/bug in TODO")
40 << FixItHint::CreateReplacement(CharSourceRange::getCharRange(
Range),
48 llvm::Regex TodoMatch;
54 *this, Context->getOptions().User)) {}
60 Preprocessor *ModuleExpanderPP) {
61 PP->addCommentHandler(Handler.get());
llvm::SmallString< 256U > Name
CharSourceRange Range
SourceRange for the file name.
Base class for all clang-tidy checks.
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.