diff --git a/clang-tools-extra/clang-tidy/ClangTidy.h b/clang-tools-extra/clang-tidy/ClangTidy.h --- a/clang-tools-extra/clang-tidy/ClangTidy.h +++ b/clang-tools-extra/clang-tidy/ClangTidy.h @@ -165,6 +165,14 @@ DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level = DiagnosticIDs::Warning); + /// \brief Add a diagnostic with a user-specified name. + /// + /// Similar to the method above, but allows user to specify a DiagnosticName + /// of the Diagnostic created. + DiagnosticBuilder diag(StringRef DiagnosticName, SourceLocation Loc, + StringRef Description, + DiagnosticIDs::Level Level = DiagnosticIDs::Warning); + /// \brief Should store all options supported by this check with their /// current values or default values for options that haven't been overridden. /// diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp --- a/clang-tools-extra/clang-tidy/ClangTidy.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp @@ -439,6 +439,13 @@ return Context->diag(CheckName, Loc, Message, Level); } +DiagnosticBuilder ClangTidyCheck::diag(StringRef DiagnosticName, + SourceLocation Loc, + StringRef Description, + DiagnosticIDs::Level Level) { + return Context->diag(DiagnosticName, Loc, Description, Level); +} + void ClangTidyCheck::run(const ast_matchers::MatchFinder::MatchResult &Result) { // For historical reasons, checks don't implement the MatchFinder run() // callback directly. We keep the run()/check() distinction to avoid interface