[PATCH] D59318: Add an overload for ClangTidy's diag method that allows users to provide a diagnostic name rather than using the check name when building a diagnostic.
Harshal Lehri via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 13 13:12:56 PDT 2019
htl created this revision.
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D59318
Files:
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidy.h
Index: clang-tools-extra/clang-tidy/ClangTidy.h
===================================================================
--- clang-tools-extra/clang-tidy/ClangTidy.h
+++ 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.
///
Index: clang-tools-extra/clang-tidy/ClangTidy.cpp
===================================================================
--- clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59318.190481.patch
Type: text/x-patch
Size: 1788 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190313/3eedffad/attachment.bin>
More information about the cfe-commits
mailing list