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

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 25 20:13:15 PST 2026


================
@@ -13745,6 +13753,11 @@ void Sema::DiagnoseUniqueObjectDuplication(const VarDecl *VD) {
 }
 
 void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
+  auto ResetDeclForInitializer = llvm::make_scope_exit([this]() {
+    if (this->ExprEvalContexts.empty())
----------------
zwuis wrote:

```suggestion
    if (!this->ExprEvalContexts.empty())
```


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


More information about the cfe-commits mailing list