aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateInstantiate.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-02-28 01:04:19 +0000
committerDouglas Gregor <dgregor@apple.com>2009-02-28 01:04:19 +0000
commit724651c3523e25fbf2f6cd0419bc3466e0afdb07 (patch)
tree69cebded551363e1c7cf7c11400ad44fc4176e12 /lib/Sema/SemaTemplateInstantiate.cpp
parent5a1edf6c0dc70bd555e51bedba782da8e3552f94 (diff)
Template instantiation for function types
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65668 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index f864a50c5e..f4653c1e99 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/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<QualType, 16> 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();
}