[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.

2019-03-13 Thread Harshal Lehri via Phabricator via cfe-commits
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


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
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59318: [clang-tidy] add an overload for diag method that allows users to provide a diagnostic name rather than using the check name when building a diagnostic.

2019-03-17 Thread Harshal Lehri via Phabricator via cfe-commits
htl abandoned this revision.
htl added a comment.

In D59318#1430829 , @JonasToth wrote:

> What is the reason you want this change to happen? I think this gives the 
> chance to create inconsistencies which we should avoid.


Sorry this was a bit rushed. I was trying to pass some metadata in the 
diagnostic name so that another tool that uses the diagnostic name can perform 
some conditional evaluation based on the data. I will try coming up with a 
better plan and design for such a change.

Thank you


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59318/new/

https://reviews.llvm.org/D59318



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits