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

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 1 08:22:04 PDT 2016


alexfh added inline comments.

================
Comment at: clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp:46
@@ +45,3 @@
+       "initializing static variable with non-const expression depending on "
+       "static variable '%0'.")
+      << Referencee->getName();
----------------
nit: no trailing period needed in diagnostic messages

================
Comment at: clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp:47
@@ +46,3 @@
+       "static variable '%0'.")
+      << Referencee->getName();
+}
----------------
This might work even better without `->getName()`. Not sure, but it makes sense to try.

================
Comment at: docs/clang-tidy/checks/cppcoreguidelines-interfaces-global-init.rst:7
@@ +6,3 @@
+This check flags initializers of globals that access extern objects,
+and therefore can lead to order-of-initialization problems.
+
----------------
What about indirect access of other globals, e.g. via function calls? We obviously can't analyze functions defined in a different translation unit, and I'm not sure we need to analyze even those defined in the same TU (since it may be imprecise and quite expensive), but maybe we should use some heuristic here (the most agressive would be to flag all initializers containing function calls, but that might be rather noisy).


http://reviews.llvm.org/D18649





More information about the cfe-commits mailing list