[clang] 2ae0fbb - [Clang][ItaniumMangle] Preserve field-name closure-prefix for instantiated lambdas (#195340)
via cfe-commits
cfe-commits at lists.llvm.org
Sun May 3 09:13:32 PDT 2026
Author: eiytoq
Date: 2026-05-03T18:13:29+02:00
New Revision: 2ae0fbb9bcd6b93a5f8ec84e9299e8d63b473f5c
URL: https://github.com/llvm/llvm-project/commit/2ae0fbb9bcd6b93a5f8ec84e9299e8d63b473f5c
DIFF: https://github.com/llvm/llvm-project/commit/2ae0fbb9bcd6b93a5f8ec84e9299e8d63b473f5c.diff
LOG: [Clang][ItaniumMangle] Preserve field-name closure-prefix for instantiated lambdas (#195340)
Previously, instantiation did not pass `LambdaContextDecl`, so the NSDMI
lambda in the class template used the wrong `ContextDecl`.
Fixes: #190555
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/CodeGenCXX/dtor-local-lambda-mangle.cpp
clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fdafc4871ed1b..2c1d0d22dfa10 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -62,6 +62,9 @@ ABI Changes in This Version
types, or ``_Complex float`` types are passed, and may introduce
incompatibilities with code compiled by earlier versions of Clang that uses
the ``__regcall`` calling convention on these targets. (#GH62999) (#GH98635)
+- Fixed Itanium mangling for lambdas in instantiated non-static data member
+ initializers by preserving the field-name closure-prefix. This changes the
+ mangled names for affected lambdas. (#GH190555)
AST Dumping Potentially Breaking Changes
----------------------------------------
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index f9dcd8b24b783..f4cd6ca9930ff 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3873,7 +3873,8 @@ bool Sema::InstantiateInClassInitializer(
// we don't have a scope.
ContextRAII SavedContext(*this, Instantiation->getParent());
EnterExpressionEvaluationContext EvalContext(
- *this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
+ *this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated,
+ Instantiation);
ExprEvalContexts.back().DelayedDefaultInitializationContext = {
PointOfInstantiation, Instantiation, CurContext};
diff --git a/clang/test/CodeGenCXX/dtor-local-lambda-mangle.cpp b/clang/test/CodeGenCXX/dtor-local-lambda-mangle.cpp
index 2c0269ecdaec5..95283dad4a933 100644
--- a/clang/test/CodeGenCXX/dtor-local-lambda-mangle.cpp
+++ b/clang/test/CodeGenCXX/dtor-local-lambda-mangle.cpp
@@ -18,7 +18,7 @@ E::E() {
template<typename T>
E::E(T t) {
struct {
- // CHECK-DAG: _ZTSN1EC1IiEUt_UlvE_E
+ // CHECK-DAG: _ZTSN1EC1IiEUt_12anotherValueMUlvE_E
int anotherValue = [x = 1] { return x; }();
} obj;
}
diff --git a/clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp b/clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
index bb21c87eed8ff..1b4268f56ab48 100644
--- a/clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
+++ b/clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
@@ -43,8 +43,8 @@ L<int> l;
// CHECK-LABEL: define linkonce_odr noundef i32 @_ZZNK12non_template1L1tMUliE_clEiENKUliE_clEi(ptr
-// CHECK-LABEL: define linkonce_odr void @_ZNK32lambdas_in_NSDMIs_template_class1LIiEUliE_clEi(ptr
-// CHECK-LABEL: define linkonce_odr noundef i32 @_ZZNK32lambdas_in_NSDMIs_template_class1LIiEUliE_clEiENKUliE_clEi(ptr
+// CHECK-LABEL: define linkonce_odr void @_ZNK32lambdas_in_NSDMIs_template_class1LIiE2t2MUliE_clEi(ptr
+// CHECK-LABEL: define linkonce_odr noundef i32 @_ZZNK32lambdas_in_NSDMIs_template_class1LIiE2t2MUliE_clEiENKUliE_clEi(ptr
// CHECK-LABEL: define linkonce_odr void @_ZZN15inline_function3fooEvENKUliE_clEi
// CHECK-LABEL: define linkonce_odr noundef signext i8 @_ZZZN15inline_function3fooEvENKUliE_clEiENKUlcE_clEc
More information about the cfe-commits
mailing list