[clang] [clang][Sema] Fix false positive -Wshadow with structured binding captures (PR #157667)

Ivan Murashko via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 10 10:59:24 PDT 2025


================
@@ -8508,10 +8525,17 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
           return;
         }
       }
-      if (const auto *VD = dyn_cast<VarDecl>(ShadowedDecl);
-          VD && VD->hasLocalStorage()) {
-        // A variable can't shadow a local variable in an enclosing scope, if
-        // they are separated by a non-capturing declaration context.
+      // Apply scoping logic to both VarDecl and BindingDecl
+      bool shouldApplyScopingLogic = false;
+      if (const auto *VD = dyn_cast<VarDecl>(ShadowedDecl)) {
+        shouldApplyScopingLogic = VD->hasLocalStorage();
----------------
ivanmurashko wrote:

Addressed at 578e61b7aebbfa9213a28f3dabd29708112ce2a5 (also changed local vars names according the coding style)

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


More information about the cfe-commits mailing list