summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-05-15 21:18:27 +0000
committerDouglas Gregor <dgregor@apple.com>2009-05-15 21:18:27 +0000
commit8d2ad873e7077bf4700bfbc8adfe3bc9c68baf93 (patch)
tree494c1dcb6c385d2c214e868c55f5821ea748792f /clang/lib
parent6802ed99684f42e0e5eb604e33f51e5d5e616f8f (diff)
downloadbcm5719-llvm-8d2ad873e7077bf4700bfbc8adfe3bc9c68baf93.tar.gz
bcm5719-llvm-8d2ad873e7077bf4700bfbc8adfe3bc9c68baf93.zip
Make sure that we use the canonical type for the names of instantiated
constructors and destructors. This is a requirement of DeclarationNameTable::getCXXSpecialName that we weren't assert()'ing, so it should have been caught much earlier :( Big thanks to Anders for the test case. llvm-svn: 71895
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/DeclarationName.cpp3
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateDecl.cpp7
2 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/AST/DeclarationName.cpp b/clang/lib/AST/DeclarationName.cpp
index 15461bb99b8..a17abde7773 100644
--- a/clang/lib/AST/DeclarationName.cpp
+++ b/clang/lib/AST/DeclarationName.cpp
@@ -302,7 +302,8 @@ DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
assert(Kind >= DeclarationName::CXXConstructorName &&
Kind <= DeclarationName::CXXConversionFunctionName &&
"Kind must be a C++ special name kind");
-
+ assert(Ty->isCanonical() &&
+ "Can only build C++ special names from canonical types");
llvm::FoldingSet<CXXSpecialName> *SpecialNames
= static_cast<llvm::FoldingSet<CXXSpecialName>*>(CXXSpecialNamesImpl);
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index f1a02c48dd1..382c2fa98ac 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -333,7 +333,8 @@ Decl *TemplateDeclInstantiator::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner);
QualType ClassTy = SemaRef.Context.getTypeDeclType(Record);
DeclarationName Name
- = SemaRef.Context.DeclarationNames.getCXXConstructorName(ClassTy);
+ = SemaRef.Context.DeclarationNames.getCXXConstructorName(
+ SemaRef.Context.getCanonicalType(ClassTy));
CXXConstructorDecl *Constructor
= CXXConstructorDecl::Create(SemaRef.Context, Record, D->getLocation(),
Name, T, D->isExplicit(), D->isInline(),
@@ -362,6 +363,7 @@ Decl *TemplateDeclInstantiator::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
SemaRef.CheckFunctionDeclaration(Constructor, PrevDecl, Redeclaration,
/*FIXME:*/OverloadableAttrRequired);
+ Record->addedConstructor(SemaRef.Context, Constructor);
Owner->addDecl(SemaRef.Context, Constructor);
return Constructor;
}
@@ -377,7 +379,8 @@ Decl *TemplateDeclInstantiator::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
// Build the instantiated destructor declaration.
CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner);
- QualType ClassTy = SemaRef.Context.getTypeDeclType(Record);
+ QualType ClassTy =
+ SemaRef.Context.getCanonicalType(SemaRef.Context.getTypeDeclType(Record));
CXXDestructorDecl *Destructor
= CXXDestructorDecl::Create(SemaRef.Context, Record,
D->getLocation(),
OpenPOWER on IntegriCloud