[PATCH] [clang-tidy] Add a namespace checker.
Daniel Jasper
djasper at google.com
Wed Jul 16 02:11:24 PDT 2014
================
Comment at: clang-tidy/google/GoogleTidyModule.cpp:32-33
@@ -30,1 +31,4 @@
CheckFactories.addCheckFactory(
+ "google-build-namespaces",
+ new ClangTidyCheckFactory<build::NamespacesCheck>());
+ CheckFactories.addCheckFactory(
----------------
I think both the check name and the class Name should be more specific, e.g. UnnamedNamespaceInHeaderCheck. Or do you envision this to be a more generic check?
================
Comment at: clang-tidy/google/NamespacesCheck.cpp:27
@@ +26,3 @@
+
+} // namespace ast_matchers
+namespace tidy {
----------------
nit: I'd probably remove the empty lines inside the ast_matchers namespace but add an empty line before starting the tidy namespace.
================
Comment at: clang-tidy/google/NamespacesCheck.h:19
@@ +18,3 @@
+
+/// \brief Finds anonymous namespaces in headers and using namespace directives.
+/// Corresponding cpplint.py check name: 'build/namespaces'.
----------------
IMO, "using namespace directives" should be detected in a separate check, there doesn't seem to be a strong relation to the empty namespaces in headers.
================
Comment at: clang-tidy/google/NamespacesCheck.h:20
@@ +19,3 @@
+/// \brief Finds anonymous namespaces in headers and using namespace directives.
+/// Corresponding cpplint.py check name: 'build/namespaces'.
+class NamespacesCheck : public ClangTidyCheck {
----------------
I actually don't think we should keep references to a different tool. The meaning of "build/namespaces" might change making this comment stale. This check is good on its own without a specific reference.
http://reviews.llvm.org/D4523
More information about the cfe-commits
mailing list