
this PR fixes #91835. For `DeclRefExpr` in lambda's function body, it will references to original variable declaration in AST rather than `FieldDecl` for lambda class, so it's needed to find the corresponding `FieldDecl` and bind `DeclRefExpr`'s value to it. This is already implemented for variables that are not in a structured binding structure, so I extracted that part of the code so that it can be used in the structured binding case.
16 lines
288 B
C++
16 lines
288 B
C++
// RUN: %clang_analyze_cc1 -std=c++20 %s -analyzer-checker=core.NullDereference -analyzer-output=text -verify
|
|
|
|
// expected-no-diagnostics
|
|
|
|
struct S { int x; };
|
|
|
|
void f(int x) { (void)x; }
|
|
|
|
int main()
|
|
{
|
|
S s{42};
|
|
auto& [x] = s;
|
|
auto g = [x](){ f(x); }; // no warning
|
|
g();
|
|
}
|