diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-05-27 05:35:12 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-05-27 05:35:12 +0000 |
commit | 815215daf8f642b53a28212313fca7b9f77e5b9d (patch) | |
tree | 69e5ffd49e965203e38e6dfa545c6cb08f300fb9 /lib/Sema/SemaTemplateInstantiate.cpp | |
parent | 7ff69269cf13583a981b265d4edee689feb4a830 (diff) |
Initial stab at a generalized operation for determining the
instantiation of a declaration from the template version (or version
that lives in a template) and a given set of template arguments. This
needs much, much more testing, but it suffices for simple examples
like
typedef T* iterator;
iterator begin();
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72461 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index 86e69997bc..1cc999201b 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -406,9 +406,13 @@ InstantiateFunctionNoProtoType(const FunctionNoProtoType *T, QualType TemplateTypeInstantiator::InstantiateTypedefType(const TypedefType *T, unsigned Quals) const { - // FIXME: Implement this - assert(false && "Cannot instantiate TypedefType yet"); - return QualType(); + TypedefDecl *Typedef + = cast_or_null<TypedefDecl>(SemaRef.InstantiateDeclRef(T->getDecl(), + TemplateArgs)); + if (!Typedef) + return QualType(); + + return SemaRef.Context.getTypeDeclType(Typedef); } QualType @@ -435,17 +439,25 @@ TemplateTypeInstantiator::InstantiateTypeOfType(const TypeOfType *T, QualType TemplateTypeInstantiator::InstantiateRecordType(const RecordType *T, unsigned Quals) const { - // FIXME: Implement this - assert(false && "Cannot instantiate RecordType yet"); - return QualType(); + RecordDecl *Record + = cast_or_null<RecordDecl>(SemaRef.InstantiateDeclRef(T->getDecl(), + TemplateArgs)); + if (!Record) + return QualType(); + + return SemaRef.Context.getTypeDeclType(Record); } QualType TemplateTypeInstantiator::InstantiateEnumType(const EnumType *T, unsigned Quals) const { - // FIXME: Implement this - assert(false && "Cannot instantiate EnumType yet"); - return QualType(); + EnumDecl *Enum + = cast_or_null<EnumDecl>(SemaRef.InstantiateDeclRef(T->getDecl(), + TemplateArgs)); + if (!Enum) + return QualType(); + + return SemaRef.Context.getTypeDeclType(Enum); } QualType |