[all-commits] [llvm/llvm-project] d8c260: [clang][Sema] Fix false positive -Wshadow with str...
Ivan Murashko via All-commits
all-commits at lists.llvm.org
Mon Sep 15 02:56:22 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d8c2607fb1f4094db18e7716764738f9bc8489df
https://github.com/llvm/llvm-project/commit/d8c2607fb1f4094db18e7716764738f9bc8489df
Author: Ivan Murashko <ivan.murashko at gmail.com>
Date: 2025-09-15 (Mon, 15 Sep 2025)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/lib/Sema/SemaDecl.cpp
A clang/test/SemaCXX/PR68605.cpp
M clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
Log Message:
-----------
[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 at intel.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list