From 1880ba59f3667d9747e00a8394ed86df25e3b341 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 25 Mar 2009 00:34:44 +0000 Subject: Template instantiation for conversion functions llvm-svn: 67664 --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp') diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 4738dfbd8e7..97fd2ed5f40 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -46,6 +46,7 @@ namespace { 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 @@ Decl *TemplateDeclInstantiator::VisitCXXDestructorDecl(CXXDestructorDecl *D) { return Destructor; } +Decl *TemplateDeclInstantiator::VisitCXXConversionDecl(CXXConversionDecl *D) { + llvm::SmallVector 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(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(), -- cgit v1.2.3