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

Commit
19 days ago
[clang][Sema] Fix false positive -Wshadow with structured binding captures (#157667) Previously, lambda init captures of structured bindings were incorrectly classified as regular shadow warnings (shown with `-Wshadow`), while regular parameter captures were correctly classified as `uncaptured-local` warnings (shown only with `-Wshadow-all`). This created inconsistent behavior: ```cpp void foo1(std::pair<int, int> val) { [val = std::move(val)](){}(); // No warning with -Wshadow (correct) } void foo2(std::pair<int, int> val) { auto [a, b] = val; [a = std::move(a)](){}(); // Warning with -Wshadow (incorrect) } ``` The fix extends the existing lambda capture classification logic in `CheckShadow()` to handle `BindingDecl` consistently with `VarDecl`, ensuring both cases show no warnings with `-Wshadow` and `uncaptured-local` warnings with `-Wshadow-all`. Fixes #68605. --------- Co-authored-by: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>
Author
Parents
Loading