[PATCH] D18649: [clang-tidy] cppcoreguidelines-interfaces-global-init

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 1 06:38:43 PDT 2016


alexfh added a comment.

Thank you for working on the new clang-tidy check!

We usually recommend authors to run their checks on a large code base to ensure it doesn't crash and doesn't generate obvious false positives. It would be nice, if you could provide a quick summary of such a run (total number of hits, number of what seems to be a false positive in a sample of ~100).


================
Comment at: clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp:41
@@ +40,3 @@
+  // For now assume that people who write macros know what they're doing.
+  if (Var->getLocation().isMacroID()) {
+    return;
----------------
nit: No need for braces around single-line if/for/... bodies.

================
Comment at: clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.h:20
@@ +19,3 @@
+/// Flags possible initialization order issues of static variables.
+/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-interfaces-global-init.html
+class InterfacesGlobalInitCheck : public ClangTidyCheck {
----------------
I'd leave the "For user-facing documentation, see ..." phrase that the add_new_check.py script adds.

================
Comment at: test/clang-tidy/cppcoreguidelines-interfaces-global-init.cpp:37
@@ +36,3 @@
+static int FromClassBadInit = takesInt(A::ClassScope);
+// CHECK-MESSAGES: [[@LINE-1]]:12: warning: initializing static variable with
+// non-const expression depending on static variable 'ClassScope'
----------------
These should be on a single line. I guess, your clang-format doesn't use -style=file by default and doesn't understand the local style configured for the test/ directory. Otherwise it wouldn't split the lines.


http://reviews.llvm.org/D18649





More information about the cfe-commits mailing list