llvm-project
7eae833f - Fix a crash in handling this-pointer captured in nested lambdas in field initializer. (#245491)

Commit
1 day ago
Fix a crash in handling this-pointer captured in nested lambdas in field initializer. (#245491) Environment.initialize() currently crashes when handling a this-pointer captured by a nested lambda expression appearing in a field initializer of a struct. Consider the following example: ```cpp struct { int f = int f{[this]() { return [this]() { return 1; }(); }()}; } ``` When handling the this-pointer captured in the inner lambda, Environment.initialize() tries to get the enclosing record by calling getLambdaContext() on the lambda's Closure. However, getLambdaContext() only works for the outermost lambda. For inner lambdas, it just returns nullptr, which causes a null-dereference. This PR fixes that issue by introducing a helper function that finds the outermost lambda and get getLambdaContextDecl() from it.
Author
Parents
Loading