Skip to content

Commit 2c269df

Browse files
Merge pull request #11478 from swiftlang/lldb/lambda-import-to-6.2
[lldb][ClangASTImporter] Don't ASTImport LambdaExpr nodes (llvm#154962)
2 parents f9c51ff + c45eced commit 2c269df

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,16 @@ ClangASTImporter::MapCompleter::~MapCompleter() = default;
10601060

10611061
llvm::Expected<Decl *>
10621062
ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) {
1063+
// FIXME: The Minimal import mode of clang::ASTImporter does not correctly
1064+
// import Lambda definitions. Work around this for now by not importing
1065+
// lambdas at all. This is most likely encountered when importing decls from
1066+
// the `std` module (not from debug-info), where lambdas can be defined in
1067+
// inline function bodies. Those will be imported by LLDB.
1068+
if (const auto *CXX = llvm::dyn_cast<clang::CXXRecordDecl>(From))
1069+
if (CXX->isLambda())
1070+
return llvm::make_error<ASTImportError>(
1071+
ASTImportError::UnsupportedConstruct);
1072+
10631073
if (m_std_handler) {
10641074
std::optional<Decl *> D = m_std_handler->Import(From);
10651075
if (D) {
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
from lldbsuite.test import lldbinline
22
from lldbsuite.test import decorators
33

4-
lldbinline.MakeInlineTest(__file__, globals())
4+
lldbinline.MakeInlineTest(
5+
__file__,
6+
globals(),
7+
[
8+
decorators.expectedFailureAll(
9+
bugnumber="https://github.com/llvm/llvm-project/issues/149477"
10+
)
11+
],
12+
)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Test that we can successfully ASTImport clang::LambdaExpr nodes.
2+
# Currently this is not supported in MinimalImport mode (which LLDB
3+
# uses always).
4+
5+
# RUN: split-file %s %t
6+
# RUN: %clang_host -g -gdwarf %t/main.cpp -o %t.out
7+
# RUN: %lldb -o "settings set interpreter.stop-command-source-on-error false" \
8+
# RUN: -x -b -s %t/commands.input %t.out 2>&1 \
9+
# RUN: | FileCheck %s
10+
11+
#--- main.cpp
12+
13+
int main() {
14+
__builtin_debugtrap();
15+
}
16+
17+
#--- commands.input
18+
19+
run
20+
expression --top-level -- void method(int x) { [x=x] { ; }; }
21+
target dump typesystem
22+
23+
# CHECK: expression
24+
# CHECK: target dump typesystem
25+
# CHECK-NOT: FunctionDecl
26+
# CHECK-NOT: LambdaExpr

0 commit comments

Comments
 (0)