summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
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/Sema/SemaTemplateInstantiateDecl.cpp
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/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateDecl.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index cc9cb6317a1..8cd37258b6a 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3356,6 +3356,19 @@ void Sema::BuildVariableInstantiation(
NewVar->setReferenced(OldVar->isReferenced());
}
+ // See if the old variable had a type-specifier that defined an anonymous tag.
+ // If it did, mark the new variable as being the declarator for the new
+ // anonymous tag.
+ if (const TagType *OldTagType = OldVar->getType()->getAs<TagType>()) {
+ TagDecl *OldTag = OldTagType->getDecl();
+ if (OldTag->getDeclaratorForAnonDecl() == OldVar) {
+ TagDecl *NewTag = NewVar->getType()->castAs<TagType>()->getDecl();
+ assert(!NewTag->hasNameForLinkage() &&
+ !NewTag->hasDeclaratorForAnonDecl());
+ NewTag->setDeclaratorForAnonDecl(NewVar);
+ }
+ }
+
InstantiateAttrs(TemplateArgs, OldVar, NewVar, LateAttrs, StartingScope);
if (NewVar->hasAttrs())
OpenPOWER on IntegriCloud