From ee97307fb8860b4f721fce8f1a919995452366a4 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sun, 25 Dec 2016 05:26:02 +0000 Subject: [PATCH] [MS ABI] Mangle unnamed enums correctly Unnamed enums take the name of the first enumerator they define. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290509 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/MicrosoftMangle.cpp | 11 +++++++++-- test/CodeGenCXX/mangle-ms-cxx11.cpp | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index 27806a7d9e..911b8b471a 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/lib/AST/MicrosoftMangle.cpp @@ -863,21 +863,28 @@ void MicrosoftCXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND, } } - llvm::SmallString<64> Name(" 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 += "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 += "getName(); + } else if (auto *ED = dyn_cast(TD)) { + auto EnumeratorI = ED->enumerator_begin(); + assert(EnumeratorI != ED->enumerator_end()); + Name += "getName(); } else { // Otherwise, number the types using a $S prefix. - Name += "$S"; + Name += "@@@Z"( -- 2.40.0