diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-05-14 21:06:31 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-05-14 21:06:31 +0000 |
commit | 1eee0e753fb390b04848846e837714ec774b7bfd (patch) | |
tree | a9863807ed0a889f93d55c8097b8f93e167ded4e /lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | 67a1eadcf7c20cd5534645468eca458902e31add (diff) |
Link FunctionDecls instantiated from the member functions of a class
template to the FunctionDecls from which they were instantiated. This
is a necessary first step to support instantiation of the definitions
of such functions, but by itself does essentially nothing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71792 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 92d253d3ba..6ae6b2240b 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -80,8 +80,8 @@ Decl *TemplateDeclInstantiator::VisitTypedefDecl(TypedefDecl *D) { bool Invalid = false; QualType T = D->getUnderlyingType(); if (T->isDependentType()) { - T = SemaRef.InstantiateType(T, TemplateArgs, D->getLocation(), - D->getDeclName()); + T = SemaRef.InstantiateType(T, TemplateArgs, + D->getLocation(), D->getDeclName()); if (T.isNull()) { Invalid = true; T = SemaRef.Context.IntTy; @@ -139,8 +139,8 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) { bool Invalid = false; QualType T = D->getType(); if (T->isDependentType()) { - T = SemaRef.InstantiateType(T, TemplateArgs, D->getLocation(), - D->getDeclName()); + T = SemaRef.InstantiateType(T, TemplateArgs, + D->getLocation(), D->getDeclName()); if (!T.isNull() && T->isFunctionType()) { // C++ [temp.arg.type]p3: // If a declaration acquires a function type through a type @@ -290,6 +290,7 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D) { = CXXMethodDecl::Create(SemaRef.Context, Record, D->getLocation(), D->getDeclName(), T, D->isStatic(), D->isInline()); + Method->setInstantiationOfMemberFunction(D); // Attach the parameters for (unsigned P = 0; P < Params.size(); ++P) @@ -333,6 +334,7 @@ Decl *TemplateDeclInstantiator::VisitCXXConstructorDecl(CXXConstructorDecl *D) { = CXXConstructorDecl::Create(SemaRef.Context, Record, D->getLocation(), Name, T, D->isExplicit(), D->isInline(), false); + Constructor->setInstantiationOfMemberFunction(D); // Attach the parameters for (unsigned P = 0; P < Params.size(); ++P) @@ -375,6 +377,7 @@ Decl *TemplateDeclInstantiator::VisitCXXDestructorDecl(CXXDestructorDecl *D) { D->getLocation(), SemaRef.Context.DeclarationNames.getCXXDestructorName(ClassTy), T, D->isInline(), false); + Destructor->setInstantiationOfMemberFunction(D); if (InitMethodInstantiation(Destructor, D)) Destructor->setInvalidDecl(); @@ -404,6 +407,7 @@ Decl *TemplateDeclInstantiator::VisitCXXConversionDecl(CXXConversionDecl *D) { D->getLocation(), SemaRef.Context.DeclarationNames.getCXXConversionFunctionName(ConvTy), T, D->isInline(), D->isExplicit()); + Conversion->setInstantiationOfMemberFunction(D); if (InitMethodInstantiation(Conversion, D)) Conversion->setInvalidDecl(); @@ -513,7 +517,7 @@ TemplateDeclInstantiator::InstantiateFunctionType(FunctionDecl *D, const FunctionProtoType *Proto = D->getType()->getAsFunctionProtoType(); assert(Proto && "Missing prototype?"); QualType ResultType - = SemaRef.InstantiateType(Proto->getResultType(), TemplateArgs, + = SemaRef.InstantiateType(Proto->getResultType(), TemplateArgs, D->getLocation(), D->getDeclName()); if (ResultType.isNull()) return QualType(); @@ -557,7 +561,19 @@ TemplateDeclInstantiator::InitMethodInstantiation(CXXMethodDecl *New, /// \param Function the already-instantiated declaration of a /// function. void Sema::InstantiateFunctionDefinition(FunctionDecl *Function) { - // FIXME: Implement this! + // FIXME: make this work for function template specializations, too. + + // Find the function body that we'll be substituting. + const FunctionDecl *PatternDecl + = Function->getInstantiatedFromMemberFunction(); + Stmt *Pattern = 0; + if (PatternDecl) + Pattern = PatternDecl->getBody(Context, PatternDecl); + + if (!Pattern) + return; + + // FIXME: instantiate the pattern } /// \brief Instantiate the definition of the given variable from its |