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

Justin Stitt via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 20 10:54:28 PDT 2025


================
@@ -6750,6 +6750,11 @@ class Sema final : public SemaBase {
     /// suffice, e.g., in a default function argument.
     Decl *ManglingContextDecl;
 
+    /// Declaration for initializer if one is currently being
+    /// parsed. Used when an expression has a possibly unreachable
+    /// diagnostic to reference the declaration as a whole.
+    VarDecl *DeclForInitializer = nullptr;
----------------
JustinStitt wrote:

There was a fixme: `// FIXME: Using the mangling context here is a hack.`

So I went ahead and made `DeclForInitializer`. I think this is better because I can type it as `VarDecl` and its name makes more sense in this context too.

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


More information about the cfe-commits mailing list