summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclTemplate.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-06-29 20:59:39 +0000
committerDouglas Gregor <dgregor@apple.com>2009-06-29 20:59:39 +0000
commit8f5d4423ca126d66beddd0db69c384f6d07f1a93 (patch)
tree5835a0a7c5c6d546cae3a3f320d5ecd8f1f4ce39 /clang/lib/AST/DeclTemplate.cpp
parent10de9e6602fcbe351aa20367c19a8cc39bb0c991 (diff)
downloadbcm5719-llvm-8f5d4423ca126d66beddd0db69c384f6d07f1a93.tar.gz
bcm5719-llvm-8f5d4423ca126d66beddd0db69c384f6d07f1a93.zip
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. llvm-svn: 74454
Diffstat (limited to 'clang/lib/AST/DeclTemplate.cpp')
-rw-r--r--clang/lib/AST/DeclTemplate.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 165672d50f4..f1bd1b67d21 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -81,11 +81,36 @@ FunctionTemplateDecl *FunctionTemplateDecl::Create(ASTContext &C,
DeclContext *DC,
SourceLocation L,
DeclarationName Name,
- TemplateParameterList *Params,
+ TemplateParameterList *Params,
NamedDecl *Decl) {
return new (C) FunctionTemplateDecl(DC, L, Name, Params, Decl);
}
+void FunctionTemplateDecl::Destroy(ASTContext &C) {
+ if (Common *CommonPtr = CommonOrPrev.dyn_cast<Common*>()) {
+ for (llvm::FoldingSet<FunctionTemplateSpecializationInfo>::iterator
+ Spec = CommonPtr->Specializations.begin(),
+ SpecEnd = CommonPtr->Specializations.end();
+ Spec != SpecEnd; ++Spec)
+ C.Deallocate(&*Spec);
+ }
+
+ Decl::Destroy(C);
+}
+
+FunctionTemplateDecl::Common *FunctionTemplateDecl::getCommonPtr() {
+ // Find the first declaration of this function template.
+ FunctionTemplateDecl *First = this;
+ while (First->getPreviousDeclaration())
+ First = First->getPreviousDeclaration();
+
+ if (First->CommonOrPrev.isNull()) {
+ // FIXME: Allocate with the ASTContext
+ First->CommonOrPrev = new Common;
+ }
+ return First->CommonOrPrev.get<Common*>();
+}
+
//===----------------------------------------------------------------------===//
// ClassTemplateDecl Implementation
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud