https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/154962

>From 1d3dc85d575570cf0869a72bb00ae9d57c338d13 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuc...@gmail.com>
Date: Fri, 22 Aug 2025 15:43:34 +0100
Subject: [PATCH 1/2] [lldb][ClangASTImporter] Don't ASTImport LambdaExpr nodes

Works around https://github.com/llvm/llvm-project/issues/149477
---
 .../Clang/ClangASTImporter.cpp                | 10 +++++++
 .../test/Shell/Expr/TestLambdaExprImport.test | 26 +++++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 lldb/test/Shell/Expr/TestLambdaExprImport.test

diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 08e2d0f1b4011..92094c01e2a54 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -1048,6 +1048,16 @@ ClangASTImporter::MapCompleter::~MapCompleter() = 
default;
 
 llvm::Expected<Decl *>
 ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) {
+  // FIXME: The Minimal import mode of clang::ASTImporter does not correctly
+  // import Lambda definitions. Work around this for now by not importing
+  // lambdas at all. This is most likely encountered when importing decls from
+  // the `std` module (not from debug-info), where lambdas can be defined in
+  // inline function bodies. Those will be imported by LLDB.
+  if (const auto *CXX = llvm::dyn_cast<clang::CXXRecordDecl>(From))
+    if (CXX->isLambda())
+      return llvm::make_error<ASTImportError>(
+          ASTImportError::UnsupportedConstruct);
+
   if (m_std_handler) {
     std::optional<Decl *> D = m_std_handler->Import(From);
     if (D) {
diff --git a/lldb/test/Shell/Expr/TestLambdaExprImport.test 
b/lldb/test/Shell/Expr/TestLambdaExprImport.test
new file mode 100644
index 0000000000000..c57ce06453fe2
--- /dev/null
+++ b/lldb/test/Shell/Expr/TestLambdaExprImport.test
@@ -0,0 +1,26 @@
+# 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

>From ec5932da428da7c3e8a07fa67c7f52d1d47336ae Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuc...@gmail.com>
Date: Fri, 22 Aug 2025 20:29:05 +0100
Subject: [PATCH 2/2] fixup! XFAIL TestLambdas.py

---
 lldb/test/API/lang/cpp/lambdas/TestLambdas.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lldb/test/API/lang/cpp/lambdas/TestLambdas.py 
b/lldb/test/API/lang/cpp/lambdas/TestLambdas.py
index c8308c16011e0..112f375c0ef2f 100644
--- a/lldb/test/API/lang/cpp/lambdas/TestLambdas.py
+++ b/lldb/test/API/lang/cpp/lambdas/TestLambdas.py
@@ -1,4 +1,12 @@
 from lldbsuite.test import lldbinline
 from lldbsuite.test import decorators
 
-lldbinline.MakeInlineTest(__file__, globals())
+lldbinline.MakeInlineTest(
+    __file__,
+    globals(),
+    [
+        decorators.expectedFailureAll(
+            bugnumber="https://github.com/llvm/llvm-project/issues/149477";
+        )
+    ],
+)

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to