diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-08-31 18:48:39 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-08-31 18:48:39 +0000 |
commit | 0035052729e4a3adfbbf0a65ac42d372e9a29c55 (patch) | |
tree | e941f52afb7f7eae68bf12a49a2e11ab8a728622 /clang/lib/AST/MicrosoftMangle.cpp | |
parent | d40722e26787a6e080e0de30d8980bc15da93ec9 (diff) | |
download | bcm5719-llvm-0035052729e4a3adfbbf0a65ac42d372e9a29c55.tar.gz bcm5719-llvm-0035052729e4a3adfbbf0a65ac42d372e9a29c55.zip |
[MS ABI] Correctly mangle classes without names for linkage purposes
A class without a name for linkage purposes gets a name along the lines
of <unnamed-type-foo> where foo is either the name of a declarator which
defined it (like a variable or field) or a
typedef-name (like a typedef or alias-declaration).
We handled the declarator case correctly but it would fall down during
template instantiation if the declarator didn't share the tag's type.
We failed to handle the typedef-name case at all.
Instead, keep track of the association between the two and keep it up to
date in the face of template instantiation.
llvm-svn: 246469
Diffstat (limited to 'clang/lib/AST/MicrosoftMangle.cpp')
-rw-r--r-- | clang/lib/AST/MicrosoftMangle.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 1be02f5e23c..596f1386570 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -786,10 +786,17 @@ void MicrosoftCXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND, } llvm::SmallString<64> Name("<unnamed-type-"); - if (TD->hasDeclaratorForAnonDecl()) { - // Anonymous types with no tag or typedef get the name of their + 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 += TD->getDeclaratorForAnonDecl()->getName(); + 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 += TND->getName(); } else { // Otherwise, number the types using a $S prefix. Name += "$S"; |