[clang] [Clang] Consider reachability for file-scope warnings on initializers (PR #163885)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 17 07:53:44 PDT 2025
================
@@ -117,6 +117,11 @@ Stmt *AnalysisDeclContext::getBody(bool &IsAutosynthesized) const {
return BD->getBody();
else if (const auto *FunTmpl = dyn_cast_or_null<FunctionTemplateDecl>(D))
return FunTmpl->getTemplatedDecl()->getBody();
+ else if (const auto *VD = dyn_cast_or_null<VarDecl>(D)) {
+ if (VD->hasGlobalStorage()) {
----------------
zwuis wrote:
`hasGlobalStorage` is used here but `isFileVarDecl` is used elsewhere. It seems that you want to handle `static` variables in function bodies. Do we have tests with it, or could you please adding tests regardless of whether it's supported?
https://github.com/llvm/llvm-project/pull/163885
More information about the cfe-commits
mailing list