[PATCH] D13090: [clang-tidy] IdentifierNamingCheck should only emit warnings when declaration or usage is outside of macros

Beren Minor via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 23 00:40:50 PDT 2015


berenm updated this revision to Diff 35468.
berenm added a comment.

Even better with the corresponding unit test fix.


http://reviews.llvm.org/D13090

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  test/clang-tidy/readability-identifier-naming.cpp

Index: test/clang-tidy/readability-identifier-naming.cpp
===================================================================
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -77,8 +79,7 @@
 
 #define BLA int FOO_bar
 BLA;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for global variable 'FOO_bar'
-// NO fix expected as FOO_bar is from macro expansion
+// NO warnings or fixes expected as FOO_bar is from macro expansion
 
 enum my_enumeration {
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for enum 'my_enumeration'
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===================================================================
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -567,10 +567,11 @@
     SourceRange DeclRange =
         DeclarationNameInfo(Decl.getDeclName(), Decl.getLocation())
             .getSourceRange();
-    auto Diag = diag(Decl.getLocStart(), "invalid case style for %0 '%1'")
-                << Failure.KindName << Decl.getName();
 
     if (Failure.ShouldFix) {
+      auto Diag = diag(Decl.getLocStart(), "invalid case style for %0 '%1'")
+                  << Failure.KindName << Decl.getName();
+
       Diag << FixItHint::CreateReplacement(
           CharSourceRange::getTokenRange(DeclRange), Failure.Fixup);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13090.35468.patch
Type: text/x-patch
Size: 1418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150923/2d391d44/attachment.bin>


More information about the cfe-commits mailing list