diff options
author | Ivan Murashko <ivan.murashko@gmail.com> | 2025-09-15 10:55:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-15 10:55:59 +0100 |
commit | d8c2607fb1f4094db18e7716764738f9bc8489df (patch) | |
tree | 936646201bbc693a93175303486cf4643c334b5f /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 44061d14fb03ebbd38050c628ed009ae4db2714c (diff) | |
download | llvm-d8c2607fb1f4094db18e7716764738f9bc8489df.zip llvm-d8c2607fb1f4094db18e7716764738f9bc8489df.tar.gz llvm-d8c2607fb1f4094db18e7716764738f9bc8489df.tar.bz2 |
[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>
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions