@@ -1062,33 +1062,35 @@ void CXXNameMangler::mangleNameWithAbiTags(GlobalDecl GD,
10621062 // ::= <local-name>
10631063 //
10641064 const DeclContext *DC = Context.getEffectiveDeclContext (ND);
1065+ bool IsLambda = isLambda (ND);
10651066
10661067 // If this is an extern variable declared locally, the relevant DeclContext
10671068 // is that of the containing namespace, or the translation unit.
10681069 // FIXME: This is a hack; extern variables declared locally should have
10691070 // a proper semantic declaration context!
1070- if (isLocalContainerContext (DC) && ND->hasLinkage () && !isLambda (ND) )
1071+ if (isLocalContainerContext (DC) && ND->hasLinkage () && !IsLambda )
10711072 while (!DC->isNamespace () && !DC->isTranslationUnit ())
10721073 DC = Context.getEffectiveParentContext (DC);
1073- else if (GetLocalClassDecl (ND)) {
1074+ else if (GetLocalClassDecl (ND) &&
1075+ (!IsLambda || isCompatibleWith (LangOptions::ClangABI::Ver18))) {
10741076 mangleLocalName (GD, AdditionalAbiTags);
10751077 return ;
10761078 }
10771079
10781080 assert (!isa<LinkageSpecDecl>(DC) && " context cannot be LinkageSpecDecl" );
10791081
1080- if (isLocalContainerContext (DC)) {
1081- mangleLocalName (GD, AdditionalAbiTags);
1082- return ;
1083- }
1084-
10851082 // Closures can require a nested-name mangling even if they're semantically
10861083 // in the global namespace.
10871084 if (const NamedDecl *PrefixND = getClosurePrefix (ND)) {
10881085 mangleNestedNameWithClosurePrefix (GD, PrefixND, AdditionalAbiTags);
10891086 return ;
10901087 }
10911088
1089+ if (isLocalContainerContext (DC)) {
1090+ mangleLocalName (GD, AdditionalAbiTags);
1091+ return ;
1092+ }
1093+
10921094 if (DC->isTranslationUnit () || isStdNamespace (DC)) {
10931095 // Check if we have a template.
10941096 const TemplateArgumentList *TemplateArgs = nullptr ;
@@ -2201,8 +2203,6 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC, bool NoFunction) {
22012203 if (NoFunction && isLocalContainerContext (DC))
22022204 return ;
22032205
2204- assert (!isLocalContainerContext (DC));
2205-
22062206 const NamedDecl *ND = cast<NamedDecl>(DC);
22072207 if (mangleSubstitution (ND))
22082208 return ;
0 commit comments