[PATCH] D62829: [clang-tidy] Check for dynamically initialized statics in headers.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 20 07:53:07 PDT 2019


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!



================
Comment at: clang-tools-extra/test/clang-tidy/bugprone-dynamic-static-initializers.hpp:1
+// RUN: %check_clang_tidy %s bugprone-dynamic-static-initializers %t
+
----------------
alexfh wrote:
> aaron.ballman wrote:
> > I'm a bit confused.
> > 
> > 1) Why is this file a .hpp if the check is currently supposed to be C-only?
> > 2) Why are there no `#include` directives in the test if the check is supposed to only work on header files?
> > 
> > As best I can tell, this is a moral equivalent to doing: clang -x c whatever.h, and so this should be a compilation unit and not a header file. @alexfh, do you have thoughts there?
> > Why is this file a .hpp if the check is currently supposed to be C-only?
> This seems to have been cleared in a different comment: the check is C++-only.
> 
> > Why are there no #include directives in the test if the check is supposed to only work on header files?
> Since the check is using a list of extensions to figure out, if a file is a header, it's not overly important to actually add a separate file that includes this one. And there's a certain benefit in convenience of not doing so (it's nice when CHECK-... and RUN: directives just work).  At least one more check - misc-definitions-in-headers - does it the same way.
Awesome, thank you for weighing in, @alexfh!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62829/new/

https://reviews.llvm.org/D62829





More information about the cfe-commits mailing list