[lldb][ClangASTImporter] Don't ASTImport LambdaExpr nodes #154962
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch works around an assertion that we hit in the
LambdaExpr
constructor when we call it fromASTNodeImporter::VisitLambdaExpr
(see #149477). The lambda that we imported doesn't have theNumCaptures
field accurately set to the one on the source decl. This is because inMinimalImport
mode, we skip importing of lambda definitions:llvm-project/clang/lib/AST/ASTImporter.cpp
Line 2499 in e21b0dd
In practice we have seen this assertion occur in our
import-std-module
test-suite when libc++ headers decide to use lambdas inside inline function bodies (the latest failure being caused by #144602).To avoid running into this whenever libc++ decides to use lambdas in headers, this patch skips
ASTImport
of lambdas alltogether. Ideally this would bubble up to the user or log as an error, but we swallow theASTImportError
s currently. The only way this codepath is hit is when lambdas are used inside functions in defined in the expression evaluator, or when importing AST nodes from Clang modules. Both of these are very niche use-cases (for now), so a workaround seemed appropriate.