summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-25 00:34:44 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-25 00:34:44 +0000
commit1880ba59f3667d9747e00a8394ed86df25e3b341 (patch)
treec456999ddce9cae9ddbecf88eeecfc7dfdbeffee /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
parent7b7b3f08175b8c8524374d90bac080823b76a075 (diff)
downloadbcm5719-llvm-1880ba59f3667d9747e00a8394ed86df25e3b341.tar.gz
bcm5719-llvm-1880ba59f3667d9747e00a8394ed86df25e3b341.zip
Template instantiation for conversion functions
llvm-svn: 67664
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateDecl.cpp31
1 files changed, 31 insertions, 0 deletions
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<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(),
OpenPOWER on IntegriCloud