[PATCH] D62829: [clang-tidy] Check for dynamically initialized statics in headers.
Charles Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 8 10:38:03 PDT 2019
czhang marked an inline comment as done.
czhang added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp:39
+ return;
+ Finder->addMatcher(varDecl(hasGlobalStorage()).bind("var"), this);
+}
----------------
aaron.ballman wrote:
> Do you want to restrict this matcher to only variable declarations that have initializers, or are you also intending for this check to cover cases like:
> ```
> // At file scope.
> struct S { S(); } s;
> ```
I think only variables with static storage are relevant to the stated goal of the checker.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp:55
+ SourceLocation Loc = Var->getLocation();
+ if (!Loc.isValid() || !utils::isPresumedLocInHeaderFile(Loc, *Result.SourceManager,
+ HeaderFileExtensions))
----------------
aaron.ballman wrote:
> We have an AST matcher for this (`isExpansionInSystemHeader()`).
Isn't this for system headers only, not just included 'user' headers?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62829/new/
https://reviews.llvm.org/D62829
More information about the cfe-commits
mailing list