diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-06-29 20:59:39 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-06-29 20:59:39 +0000 |
commit | 127102b5196ffe04bdb70fd553fe62c265ab10a9 (patch) | |
tree | 04e917cd6dba09eebeafa02b274519f444ac5ab8 /lib/AST/Decl.cpp | |
parent | f7b8eec37c8c8012fa525c71fb29a58c9f29beef (diff) |
Keep track of function template specializations, to eliminate
redundant, implicit instantiations of function templates and provide a
place where we can hang function template specializations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74454 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 725b06676e..e25fe90b4d 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -372,11 +372,6 @@ void FunctionDecl::Destroy(ASTContext& C) { C.Deallocate(ParamInfo); - if (FunctionTemplateSpecializationInfo *Info - = TemplateOrSpecialization - .dyn_cast<FunctionTemplateSpecializationInfo*>()) - C.Deallocate(Info); - Decl::Destroy(C); } @@ -564,6 +559,18 @@ bool FunctionDecl::isExternGNUInline(ASTContext &Context) const { return false; } +void +FunctionDecl::setPreviousDeclaration(FunctionDecl *PrevDecl) { + PreviousDeclaration = PrevDecl; + + if (FunctionTemplateDecl *FunTmpl = getDescribedFunctionTemplate()) { + FunctionTemplateDecl *PrevFunTmpl + = PrevDecl? PrevDecl->getDescribedFunctionTemplate() : 0; + assert((!PrevDecl || PrevFunTmpl) && "Function/function template mismatch"); + FunTmpl->setPreviousDeclaration(PrevFunTmpl); + } +} + /// getOverloadedOperator - Which C++ overloaded operator this /// function represents, if any. OverloadedOperatorKind FunctionDecl::getOverloadedOperator() const { @@ -595,15 +602,21 @@ FunctionDecl::getTemplateSpecializationArgs() const { void FunctionDecl::setFunctionTemplateSpecialization(ASTContext &Context, FunctionTemplateDecl *Template, - const TemplateArgumentList *TemplateArgs) { + const TemplateArgumentList *TemplateArgs, + void *InsertPos) { FunctionTemplateSpecializationInfo *Info = TemplateOrSpecialization.dyn_cast<FunctionTemplateSpecializationInfo*>(); if (!Info) Info = new (Context) FunctionTemplateSpecializationInfo; + Info->Function = this; Info->Template = Template; Info->TemplateArguments = TemplateArgs; TemplateOrSpecialization = Info; + + // Insert this function template specialization into the set of known + // function template specialiations. + Template->getSpecializations().InsertNode(Info, InsertPos); } //===----------------------------------------------------------------------===// |