forked from OSchip/llvm-project
[MS ABI] Mangle unnamed enums correctly
Unnamed enums take the name of the first enumerator they define. llvm-svn: 290509
This commit is contained in:
parent
83c451e998
commit
a5cfddc367
|
@ -863,21 +863,28 @@ void MicrosoftCXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
|
|||
}
|
||||
}
|
||||
|
||||
llvm::SmallString<64> Name("<unnamed-type-");
|
||||
llvm::SmallString<64> Name;
|
||||
if (DeclaratorDecl *DD =
|
||||
Context.getASTContext().getDeclaratorForUnnamedTagDecl(TD)) {
|
||||
// Anonymous types without a name for linkage purposes have their
|
||||
// declarator mangled in if they have one.
|
||||
Name += "<unnamed-type-";
|
||||
Name += DD->getName();
|
||||
} else if (TypedefNameDecl *TND =
|
||||
Context.getASTContext().getTypedefNameForUnnamedTagDecl(
|
||||
TD)) {
|
||||
// Anonymous types without a name for linkage purposes have their
|
||||
// associate typedef mangled in if they have one.
|
||||
Name += "<unnamed-type-";
|
||||
Name += TND->getName();
|
||||
} else if (auto *ED = dyn_cast<EnumDecl>(TD)) {
|
||||
auto EnumeratorI = ED->enumerator_begin();
|
||||
assert(EnumeratorI != ED->enumerator_end());
|
||||
Name += "<unnamed-enum-";
|
||||
Name += EnumeratorI->getName();
|
||||
} else {
|
||||
// Otherwise, number the types using a $S prefix.
|
||||
Name += "$S";
|
||||
Name += "<unnamed-type-$S";
|
||||
Name += llvm::utostr(Context.getAnonymousStructId(TD) + 1);
|
||||
}
|
||||
Name += ">";
|
||||
|
|
|
@ -343,3 +343,7 @@ A a;
|
|||
|
||||
int call_it = (A::default_args(), 1);
|
||||
}
|
||||
|
||||
enum { enumerator };
|
||||
void f(decltype(enumerator)) {}
|
||||
// CHECK-DAG: define void @"\01?f@@YAXW4<unnamed-enum-enumerator>@@@Z"(
|
||||
|
|
Loading…
Reference in New Issue