This patch works around an assertion that we hit in the `LambdaExpr`
constructor when we call it from `ASTNodeImporter::VisitLambdaExpr` (see
https://github.com/llvm/llvm-project/issues/149477). The lambda that we
imported doesn't have the `NumCaptures` field accurately set to the one
on the source decl. This is because in `MinimalImport` mode, we skip
importing of lambda definitions:
e21b0dd819/clang/lib/AST/ASTImporter.cpp (L2499)
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
https://github.com/llvm/llvm-project/pull/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 the
`ASTImportError`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.
27 lines
672 B
Plaintext
27 lines
672 B
Plaintext
# Test that we can successfully ASTImport clang::LambdaExpr nodes.
|
|
# Currently this is not supported in MinimalImport mode (which LLDB
|
|
# uses always).
|
|
|
|
# RUN: split-file %s %t
|
|
# RUN: %clang_host -g -gdwarf %t/main.cpp -o %t.out
|
|
# RUN: %lldb -o "settings set interpreter.stop-command-source-on-error false" \
|
|
# RUN: -x -b -s %t/commands.input %t.out 2>&1 \
|
|
# RUN: | FileCheck %s
|
|
|
|
#--- main.cpp
|
|
|
|
int main() {
|
|
__builtin_debugtrap();
|
|
}
|
|
|
|
#--- commands.input
|
|
|
|
run
|
|
expression --top-level -- void method(int x) { [x=x] { ; }; }
|
|
target dump typesystem
|
|
|
|
# CHECK: expression
|
|
# CHECK: target dump typesystem
|
|
# CHECK-NOT: FunctionDecl
|
|
# CHECK-NOT: LambdaExpr
|