[PATCH] D53882: [clang-tidy] Adding Zircon checker for std namespace

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 30 15:42:39 PDT 2018


steveire added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/zircon/NoStdNamespaceCheck.cpp:52
+  Finder->addMatcher(
+      valueDecl(hasType(decl(hasDeclContext(namespaceDecl(isStdNamespace())))))
+          .bind("stdVar"),
----------------
Recommend extracting `namespaceDecl(isStdNamespace())` to a local variable.


================
Comment at: clang-tools-extra/test/clang-tidy/zircon-no-std-namespace.cpp:13
+int b = func();
+std_int c;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use of the 'std' namespace is not allowed in Zircon kernel code
----------------
Are you sure it's wise to warn on every declaration inside the `std` namespace? Surely warning only on declarations outside it is enough.


https://reviews.llvm.org/D53882





More information about the cfe-commits mailing list