[clang] [Clang] Fix Itanium mangling crash for local lambda in ctor/dtor (PR #181068)

via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 4 18:39:54 PDT 2026


================
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -O2 -emit-llvm -o /dev/null %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -O2 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 -O2 -disable-llvm-passes -fclang-abi-compat=18 -emit-llvm -o - %s | FileCheck %s
+
+struct E {
+  E();
+  ~E();
+};
+
+E::E() {
+  struct {
+    int anotherValue = [] { return 1; }();
+  } obj;
+}
+
+E::~E() {
+  struct {
+    int anotherValue = [] { return 2; }();
+  } obj;
+}
+
+// CHECK-LABEL: define internal void @"_ZZN1EC1EvEN3$_0C2Ev"
+// CHECK: store i32 %{{.*}}, ptr %anotherValue, align 4, !tbaa ![[CTOR_ACCESS:[0-9]+]]
+
+// CHECK-LABEL: define internal void @"_ZZN1ED1EvEN3$_0C2Ev"
+// CHECK: store i32 %{{.*}}, ptr %anotherValue, align 4, !tbaa ![[DTOR_ACCESS:[0-9]+]]
+
+// CHECK: ![[CTOR_ACCESS]] = !{![[CTOR_TYPE:[0-9]+]], ![[INT:[0-9]+]], i64 0}
+// CHECK: ![[CTOR_TYPE]] = !{!"_ZTSZN1EC1EvE3$_0", ![[INT]], i64 0}
----------------
eiytoq wrote:

Emm... my mistake. Fixed.

https://github.com/llvm/llvm-project/pull/181068


More information about the cfe-commits mailing list