[PATCH] Add a level parameter to ClangTidyCheck::diag.

Peter Collingbourne peter at pcc.me.uk
Sun Mar 2 04:25:17 PST 2014


Hi alexfh,

The goal is to make it possible for checks to emit diagnostics at levels
other than 'warning'.

http://llvm-reviews.chandlerc.com/D2913

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidy.h

Index: clang-tidy/ClangTidy.cpp
===================================================================
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -226,8 +226,9 @@
   return EnableChecks.match(Name) && !DisableChecks.match(Name);
 }
 
-DiagnosticBuilder ClangTidyCheck::diag(SourceLocation Loc, StringRef Message) {
-  return Context->diag(CheckName, Loc, Message);
+DiagnosticBuilder ClangTidyCheck::diag(SourceLocation Loc, StringRef Message,
+                                       DiagnosticIDs::Level Level) {
+  return Context->diag(CheckName, Loc, Message, Level);
 }
 
 void ClangTidyCheck::run(const ast_matchers::MatchFinder::MatchResult &Result) {
Index: clang-tidy/ClangTidy.h
===================================================================
--- clang-tidy/ClangTidy.h
+++ clang-tidy/ClangTidy.h
@@ -76,7 +76,8 @@
   void setContext(ClangTidyContext *Ctx) { Context = Ctx; }
 
   /// \brief Add a diagnostic with the check's name.
-  DiagnosticBuilder diag(SourceLocation Loc, StringRef Description);
+  DiagnosticBuilder diag(SourceLocation Loc, StringRef Description,
+                         DiagnosticIDs::Level Level = DiagnosticIDs::Warning);
 
   /// \brief Sets the check name. Intended to be used by the clang-tidy
   /// framework. Can be called only once.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2913.1.patch
Type: text/x-patch
Size: 1297 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140302/33a2a7f8/attachment.bin>


More information about the cfe-commits mailing list