[PATCH] Add clang-tidy check google-global-names-in-headers.

Samuel Benzaquen sbenza at google.com
Wed Feb 11 13:21:24 PST 2015


================
Comment at: clang-tidy/google/GlobalNamesInHeadersCheck.cpp:31
@@ +30,3 @@
+void GlobalNamesInHeadersCheck::check(const MatchFinder::MatchResult &Result) {
+  auto *D = Result.Nodes.getNodeAs<Decl>("using_decl");
+  // If it comes from a macro, we'll assume it is fine.
----------------
alexfh wrote:
> nit: const auto*?
Done

================
Comment at: clang-tidy/google/GlobalNamesInHeadersCheck.cpp:36
@@ +35,3 @@
+
+  // Ignore if it comes from the "main" file
+  if (Result.SourceManager->isInMainFile(
----------------
alexfh wrote:
> nit: I'd put ellipsis in the end of the comment to avoid confusion.
Done.

================
Comment at: clang-tidy/google/GlobalNamesInHeadersCheck.cpp:43
@@ +42,3 @@
+
+    if (!Filename.endswith(".h")) {
+      return;
----------------
alexfh wrote:
> nit: No braces needed in the LLVM style.
Done.

================
Comment at: clang-tidy/google/GlobalNamesInHeadersCheck.cpp:49
@@ +48,3 @@
+  diag(D->getLocStart(),
+       "no using declarations in the global namespace in headers");
+}
----------------
alexfh wrote:
> The message reads as if clang-tidy didn't find the aforementioned using declaration and wants you to insert one. Maybe "using declarations in the global namespace in headers are prohibited" or something similar? I'd even go with "don't use using declarations in ...", it's an error message, not a novel after all ;)
Done.

http://reviews.llvm.org/D7563

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list