[PATCH] D18180: [clang-tidy] Add a check to detect static definitions in anonymous namespace.

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 4 04:53:47 PDT 2016


alexfh added inline comments.

================
Comment at: clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp:52
@@ +51,3 @@
+                               "anonymous namespace; static is redundant here")
+      << Def->getName();
+  Token Tok;
----------------
`DiagnosticBuilder` handles hella different stuff. I wonder whether this code works without `->getName()`?

================
Comment at: docs/clang-tidy/checks/readability-static-definition-in-anonymous-namespace.rst:9
@@ +8,3 @@
+Static is redundant in the current translation unit because anonymous namespace
+is only visible in the unit.
+
----------------
Still reads a bit strange. A bit more wordsmithing:

  In this case, `static` is redundant, because anonymous namespace limits the visibility of definitions to a single translation unit.

================
Comment at: test/clang-tidy/readability-static-definition-in-anonymous-namespace.cpp:32
@@ +31,3 @@
+STATIC int h = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'h' is a static definition in anonymous namespace
+
----------------
Please add a CHECK-FIXES for this case as well. Also move the macro definition closer to its usage and add a CHECK-FIXES to ensure it doesn't get changed.

Same below.


http://reviews.llvm.org/D18180





More information about the cfe-commits mailing list