[clang] [clang][Sema] Fix false positive -Wshadow with structured binding captures (PR #157667)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 9 17:57:27 PDT 2025
zwuis wrote:
Oh, I missed "-Wshadow-uncaptured-local". Thanks for pointing out!
> IIUC we shouldn't emit any warning on "lambda captures shadow something". It is a better approach for me that removing emitting this warning and performing code cleanup (there must be some checks preventing false positive with shadowing variables).
So this is wrong.
> My fix was focused on the simplest solution to make behavior consistent for the most popular case (basic `-Wshadow`). A proper fix should probably preserve the `uncaptured-local` warning classification for structured bindings rather than suppressing all shadow warnings, but that would require more complex changes to the warning classification logic.
So current fix will introduce false negative with `-Wshadow-uncaptured-local` and shadowing structured bindings, and, **hide the underlying issue**. It would be great to explore the difference of handling shadowing `VarDecl` and `BindingDecl`.
https://github.com/llvm/llvm-project/pull/157667
More information about the cfe-commits
mailing list