[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 08:19:13 PDT 2016

alexfh added inline comments.

Comment at: clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp:49
@@ +48,3 @@
+  DiagnosticBuilder Diag =
+      diag(Def->getLocation(), "%0 is a static definition in "
nit: `auto`?

Comment at: docs/clang-tidy/checks/readability-static-definition-in-anonymous-namespace.rst:8
@@ +7,3 @@
+In this case, `static` is redundant, because anonymous namespace limits the
+visibility of definitions to a single translation unit.
Double backquotes should be used for inline code snippets (yeah, I know, this is confusing: different flavors of markdown and RST are completely inconsistent in this regard).

Comment at: test/clang-tidy/readability-static-definition-in-anonymous-namespace.cpp:33
@@ +32,3 @@
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: 'h' is a static definition in anonymous namespace
+// CHECK-FIXES: {{^}}DEFINE_STATIC int h = 1;
You missed the "Also move the macro definition closer to its usage and add a CHECK-FIXES to ensure it doesn't get changed." part.

Same below.


More information about the cfe-commits mailing list