================
@@ -304,12 +304,24 @@ Sema::getCurrentMangleNumberContext(const DeclContext 
*DC) {
     //    Yeah, I think the only cases left where lambdas don't need a
     //    mangling are when they have (effectively) internal linkage or appear
     //    in a non-inline function in a non-module translation unit.
-    if (auto *ND = dyn_cast<NamedDecl>(ManglingContextDecl ? 
ManglingContextDecl
-                                                           : cast<Decl>(DC));
+
+    Decl *ManglingContextDeclForModule = [&]() {
+      if (!ManglingContextDecl || [&]() {
+            // If we must allocate mangling numbers but the
+            // `ManglingContextDecl` is a local variable, use the `DeclContext`
+            // containing the lambda expression instead.
+            VarDecl *Var = dyn_cast<VarDecl>(ManglingContextDecl);
+            return Var && Var->isLocalVarDecl();
+          }())
+        return const_cast<Decl *>(cast<Decl>(DC));
----------------
jiixyj wrote:

Hm, this doesn't quite work, sadly... It doesn't handle the case where 
`ManglingContextDecl` is set, but not a local `VarDecl`. Any other ideas?

https://github.com/llvm/llvm-project/pull/179035
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to