Template instantiation for conversion functions
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67664 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 4738dfb..97fd2ed 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -46,6 +46,7 @@
Decl *VisitCXXMethodDecl(CXXMethodDecl *D);
Decl *VisitCXXConstructorDecl(CXXConstructorDecl *D);
Decl *VisitCXXDestructorDecl(CXXDestructorDecl *D);
+ Decl *VisitCXXConversionDecl(CXXConversionDecl *D);
Decl *VisitParmVarDecl(ParmVarDecl *D);
Decl *VisitOriginalParmVarDecl(OriginalParmVarDecl *D);
@@ -320,6 +321,36 @@
return Destructor;
}
+Decl *TemplateDeclInstantiator::VisitCXXConversionDecl(CXXConversionDecl *D) {
+ llvm::SmallVector<ParmVarDecl *, 16> Params;
+ QualType T = InstantiateFunctionType(D, Params);
+ if (T.isNull())
+ return 0;
+ assert(Params.size() == 0 && "Destructor with parameters?");
+
+ // Build the instantiated conversion declaration.
+ CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner);
+ QualType ClassTy = SemaRef.Context.getTypeDeclType(Record);
+ QualType ConvTy
+ = SemaRef.Context.getCanonicalType(T->getAsFunctionType()->getResultType());
+ CXXConversionDecl *Conversion
+ = CXXConversionDecl::Create(SemaRef.Context, Record,
+ D->getLocation(),
+ SemaRef.Context.DeclarationNames.getCXXConversionFunctionName(ConvTy),
+ T, D->isInline(), D->isExplicit());
+ if (InitMethodInstantiation(Conversion, D))
+ Conversion->setInvalidDecl();
+
+ bool Redeclaration = false;
+ bool OverloadableAttrRequired = false;
+ NamedDecl *PrevDecl = 0;
+ if (SemaRef.CheckFunctionDeclaration(Conversion, PrevDecl, Redeclaration,
+ /*FIXME:*/OverloadableAttrRequired))
+ Conversion->setInvalidDecl();
+ Owner->addDecl(Conversion);
+ return Conversion;
+}
+
Decl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) {
QualType OrigT = SemaRef.InstantiateType(D->getOriginalType(), TemplateArgs,
NumTemplateArgs, D->getLocation(),