summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2013-09-17 22:21:27 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2013-09-17 22:21:27 +0000
commit1ebb145bdff0b3dc85a972922b9c706d298fc462 (patch)
treec6580c88b57f6ccfb0565553d7d13e9a6b02ee19 /clang/lib/AST
parent870b662779107b429a3ebc10340b039c48229806 (diff)
downloadbcm5719-llvm-1ebb145bdff0b3dc85a972922b9c706d298fc462.tar.gz
bcm5719-llvm-1ebb145bdff0b3dc85a972922b9c706d298fc462.zip
[-cxx-abi microsoft] Mangle local TagDecls appropriately
Summary: When selecting a mangling for an anonymous tag type: - We should first try it's typedef'd name. - If that doesn't work, we should mangle in the name of the declarator that specified it as a declaration specifier. - If that doesn't work, fall back to a static mangling of <unnamed-type>. This should make our anonymous type mangling compatible. This partially fixes PR16994; we would need to have an implementation of scope numbering to get it right (a separate issue). Reviewers: rnk, rsmith, rjmccall, cdavis5x CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1540 llvm-svn: 190892
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/Decl.cpp8
-rw-r--r--clang/lib/AST/MicrosoftMangle.cpp12
2 files changed, 13 insertions, 7 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 0fa1b980f31..dbbf4753dcc 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3084,7 +3084,7 @@ TagDecl* TagDecl::getCanonicalDecl() {
}
void TagDecl::setTypedefNameForAnonDecl(TypedefNameDecl *TDD) {
- TypedefNameDeclOrQualifier = TDD;
+ NamedDeclOrQualifier = TDD;
if (TypeForDecl)
assert(TypeForDecl->isLinkageValid());
assert(isLinkageValid());
@@ -3141,7 +3141,7 @@ void TagDecl::setQualifierInfo(NestedNameSpecifierLoc QualifierLoc) {
if (QualifierLoc) {
// Make sure the extended qualifier info is allocated.
if (!hasExtInfo())
- TypedefNameDeclOrQualifier = new (getASTContext()) ExtInfo;
+ NamedDeclOrQualifier = new (getASTContext()) ExtInfo;
// Set qualifier info.
getExtInfo()->QualifierLoc = QualifierLoc;
} else {
@@ -3149,7 +3149,7 @@ void TagDecl::setQualifierInfo(NestedNameSpecifierLoc QualifierLoc) {
if (hasExtInfo()) {
if (getExtInfo()->NumTemplParamLists == 0) {
getASTContext().Deallocate(getExtInfo());
- TypedefNameDeclOrQualifier = (TypedefNameDecl*) 0;
+ NamedDeclOrQualifier = (TypedefNameDecl*) 0;
}
else
getExtInfo()->QualifierLoc = QualifierLoc;
@@ -3164,7 +3164,7 @@ void TagDecl::setTemplateParameterListsInfo(ASTContext &Context,
// Make sure the extended decl info is allocated.
if (!hasExtInfo())
// Allocate external info struct.
- TypedefNameDeclOrQualifier = new (getASTContext()) ExtInfo;
+ NamedDeclOrQualifier = new (getASTContext()) ExtInfo;
// Set the template parameter lists info.
getExtInfo()->setTemplateParameterListsInfo(Context, NumTPLists, TPLists);
}
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index 8506c4c8dde..119bc86be29 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -563,9 +563,15 @@ MicrosoftCXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
break;
}
- // When VC encounters an anonymous type with no tag and no typedef,
- // it literally emits '<unnamed-tag>@'.
- Out << "<unnamed-tag>@";
+ if (TD->hasDeclaratorForAnonDecl())
+ // Anonymous types with no tag or typedef get the name of their
+ // declarator mangled in.
+ Out << "<unnamed-type-" << TD->getDeclaratorForAnonDecl()->getName()
+ << ">@";
+ else
+ // Anonymous types with no tag, no typedef, or declarator get
+ // '<unnamed-tag>@'.
+ Out << "<unnamed-tag>@";
break;
}
OpenPOWER on IntegriCloud