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 | b4850465b77f98dce508201c938b7222ed878331 (patch) | |
tree | 5c0a8def5dbd729b776c6dd7d2e32f7df51d0edd /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | 35ea2c9aa687f5ad36428b3a6dc147a72cf7eeb0 (diff) | |
download | bcm5719-llvm-b4850465b77f98dce508201c938b7222ed878331.tar.gz bcm5719-llvm-b4850465b77f98dce508201c938b7222ed878331.zip |
Introduce basic support for instantiating the definitions of member
functions of class templates. Only compound statements and expression
statements are currently implemented.
llvm-svn: 71814
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 02df5931a5b..eb006dc3f3e 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -572,6 +572,9 @@ TemplateDeclInstantiator::InitMethodInstantiation(CXXMethodDecl *New, void Sema::InstantiateFunctionDefinition(FunctionDecl *Function) { // FIXME: make this work for function template specializations, too. + if (Function->isInvalidDecl()) + return; + // Find the function body that we'll be substituting. const FunctionDecl *PatternDecl = Function->getInstantiatedFromMemberFunction(); @@ -582,7 +585,23 @@ void Sema::InstantiateFunctionDefinition(FunctionDecl *Function) { if (!Pattern) return; - // FIXME: instantiate the pattern + // Introduce a new scope where local variable instantiations will be + // recorded. + LocalInstantiationScope Scope(*this); + + // Introduce the instantiated function parameters into the local + // instantiation scope. + for (unsigned I = 0, N = PatternDecl->getNumParams(); I != N; ++I) + Scope.InstantiatedLocal(PatternDecl->getParamDecl(I), + Function->getParamDecl(I)); + + // Instantiate the function body. + OwningStmtResult Body + = InstantiateStmt(Pattern, getTemplateInstantiationArgs(Function)); + if (Body.isInvalid()) + Function->setInvalidDecl(true); + else + Function->setBody(Body.takeAs<Stmt>()); } /// \brief Instantiate the definition of the given variable from its |