diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-05-14 23:26:13 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-05-14 23:26:13 +0000 |
commit | 54dabfca850ca9e60e9ffb60003529f868d4d127 (patch) | |
tree | 8e9ea9e3574c06f8bc4d4a67caaf42a967da3154 /lib/Sema/SemaTemplateInstantiate.cpp | |
parent | 77b7f1d4fb782c9152f91b76f9f8b1d1af21bd35 (diff) |
Introduce basic support for instantiating the definitions of member
functions of class templates. Only compound statements and expression
statements are currently implemented.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71814 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index 5c6ed758d9..9503ad9180 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -24,6 +24,26 @@ using namespace clang; // Template Instantiation Support //===----------------------------------------------------------------------===/ +/// \brief Retrieve the template argument list that should be used to +/// instantiate the given declaration. +const TemplateArgumentList & +Sema::getTemplateInstantiationArgs(NamedDecl *D) { + if (ClassTemplateSpecializationDecl *Spec + = dyn_cast<ClassTemplateSpecializationDecl>(D)) + return Spec->getTemplateArgs(); + + DeclContext *EnclosingTemplateCtx = D->getDeclContext(); + while (!isa<ClassTemplateSpecializationDecl>(EnclosingTemplateCtx)) { + assert(!EnclosingTemplateCtx->isFileContext() && + "Tried to get the instantiation arguments of a non-template"); + EnclosingTemplateCtx = EnclosingTemplateCtx->getParent(); + } + + ClassTemplateSpecializationDecl *EnclosingTemplate + = cast<ClassTemplateSpecializationDecl>(EnclosingTemplateCtx); + return EnclosingTemplate->getTemplateArgs(); +} + Sema::InstantiatingTemplate:: InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, CXXRecordDecl *Entity, |