From 6eaaf30968b286568b96847a083171406986cb0c Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sat, 28 Feb 2009 01:04:19 +0000 Subject: Template instantiation for function types llvm-svn: 65668 --- clang/lib/Sema/SemaTemplateInstantiate.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'clang/lib/Sema/SemaTemplateInstantiate.cpp') diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index f864a50c5ec..f4653c1e99a 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -65,7 +65,7 @@ TemplateTypeInstantiator::InstantiateExtQualType(const ExtQualType *T, QualType TemplateTypeInstantiator::InstantiateBuiltinType(const BuiltinType *T, unsigned Quals) const { - assert(false && "BuiltinType is never dependent and cannot be instantiated"); + assert(false && "Builtin types are not dependent and cannot be instantiated"); return QualType(T, Quals); } @@ -191,17 +191,32 @@ QualType TemplateTypeInstantiator:: InstantiateFunctionProtoType(const FunctionProtoType *T, unsigned Quals) const { - // FIXME: Implement this - assert(false && "Cannot instantiate FunctionProtoType yet"); - return QualType(); + QualType ResultType = Instantiate(T->getResultType()); + if (ResultType.isNull()) + return ResultType; + + llvm::SmallVector ParamTypes; + for (FunctionProtoType::arg_type_iterator Param = T->arg_type_begin(), + ParamEnd = T->arg_type_end(); + Param != ParamEnd; ++Param) { + QualType P = Instantiate(*Param); + if (P.isNull()) + return P; + + ParamTypes.push_back(P); + } + + return SemaRef.BuildFunctionType(ResultType, &ParamTypes[0], + ParamTypes.size(), + T->isVariadic(), T->getTypeQuals(), + Loc, Entity); } QualType TemplateTypeInstantiator:: InstantiateFunctionNoProtoType(const FunctionNoProtoType *T, unsigned Quals) const { - // FIXME: Implement this - assert(false && "Cannot instantiate FunctionNoProtoType yet"); + assert(false && "Functions without prototypes cannot be dependent."); return QualType(); } -- cgit v1.2.3