diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-05-15 00:01:03 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-05-15 00:01:03 +0000 |
commit | b9f1b8d877541e76390cd3807c2dcff2f950360a (patch) | |
tree | 1cf7756fcf570aabc11988eddd535efa54e5bc39 /lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | 2574a68e5cca0171f1e8c09373cb2f7e612ab77e (diff) |
Implement template instantiation for DeclStmt
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71818 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index eb006dc3f3..113003fd44 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -107,7 +107,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) { if (T.isNull()) return 0; - // Build the instantiataed declaration + // Build the instantiated declaration VarDecl *Var = VarDecl::Create(SemaRef.Context, Owner, D->getLocation(), D->getIdentifier(), T, D->getStorageClass(), @@ -585,6 +585,8 @@ void Sema::InstantiateFunctionDefinition(FunctionDecl *Function) { if (!Pattern) return; + // FIXME: add to the instantiation stack. + // Introduce a new scope where local variable instantiations will be // recorded. LocalInstantiationScope Scope(*this); @@ -595,6 +597,11 @@ void Sema::InstantiateFunctionDefinition(FunctionDecl *Function) { Scope.InstantiatedLocal(PatternDecl->getParamDecl(I), Function->getParamDecl(I)); + // Enter the scope of this instantiation. We don't use + // PushDeclContext because we don't have a scope. + DeclContext *PreviousContext = CurContext; + CurContext = Function; + // Instantiate the function body. OwningStmtResult Body = InstantiateStmt(Pattern, getTemplateInstantiationArgs(Function)); @@ -602,6 +609,8 @@ void Sema::InstantiateFunctionDefinition(FunctionDecl *Function) { Function->setInvalidDecl(true); else Function->setBody(Body.takeAs<Stmt>()); + + CurContext = PreviousContext; } /// \brief Instantiate the definition of the given variable from its |