[PATCH] D23130: [Clang-tidy] Add a check for definitions in the global namespace.

Piotr Padlewski via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 3 20:45:30 PDT 2016

Prazek added inline comments.

Comment at: clang-tidy/misc/GlobalNamespaceCheck.cpp:46
@@ +45,3 @@
+    // extern "C" globals need to be in the global namespace.
+    if (VDecl->isExternC())
+      return;
I think it would be better to check it in matcher.
I see that there is isExternC, but it only works for FunctionDecl, but I think that adding isExternC for VarDecl would be good

Comment at: clang-tidy/misc/GlobalNamespaceCheck.cpp:67
@@ +66,3 @@
+  }
+  // FIXME: If we want to be really fancy we could move declaration-less
What about macros? I think you should check isMacroId on location here (don't do fixit when it is in macro, but print warning)

Also please add tests for it.



More information about the cfe-commits mailing list