[clang] [Clang] Consider reachability for file-scope warnings on initializers (PR #163885)

Justin Stitt via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 17 11:12:51 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()) {
----------------
JustinStitt wrote:

Changed this to be more clear and also added tests for statics in functions.

https://github.com/llvm/llvm-project/pull/163885


More information about the cfe-commits mailing list