[cfe-commits] r106008 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/Decl.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaTemplate.cpp
Douglas Gregor
dgregor at apple.com
Tue Jun 15 10:44:39 PDT 2010
Author: dgregor
Date: Tue Jun 15 12:44:38 2010
New Revision: 106008
URL: http://llvm.org/viewvc/llvm-project?rev=106008&view=rev
Log:
Allocate template parameter lists for out-of-line definitions via the
ASTContext rather than via the normal heap.
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=106008&r1=106007&r2=106008&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Jun 15 12:44:38 2010
@@ -385,10 +385,12 @@
: NNS(0), NNSRange(), NumTemplParamLists(0), TemplParamLists(0) {}
/// setTemplateParameterListsInfo - Sets info about matched template
/// parameter lists.
- void setTemplateParameterListsInfo(unsigned NumTPLists,
+ void setTemplateParameterListsInfo(ASTContext &Context,
+ unsigned NumTPLists,
TemplateParameterList **TPLists);
- /// Destructor: frees the array of template parameter lists pointers.
- ~QualifierInfo() { delete[] TemplParamLists; }
+
+ void Destroy(ASTContext &Context);
+
private:
// Copy constructor and copy assignment are disabled.
QualifierInfo(const QualifierInfo&);
@@ -447,9 +449,9 @@
assert(index < getNumTemplateParameterLists());
return getExtInfo()->TemplParamLists[index];
}
- void setTemplateParameterListsInfo(unsigned NumTPLists,
+ void setTemplateParameterListsInfo(ASTContext &Context, unsigned NumTPLists,
TemplateParameterList **TPLists) {
- getExtInfo()->setTemplateParameterListsInfo(NumTPLists, TPLists);
+ getExtInfo()->setTemplateParameterListsInfo(Context, NumTPLists, TPLists);
}
SourceLocation getTypeSpecStartLoc() const;
@@ -1887,9 +1889,9 @@
assert(i < getNumTemplateParameterLists());
return getExtInfo()->TemplParamLists[i];
}
- void setTemplateParameterListsInfo(unsigned NumTPLists,
+ void setTemplateParameterListsInfo(ASTContext &Context, unsigned NumTPLists,
TemplateParameterList **TPLists) {
- getExtInfo()->setTemplateParameterListsInfo(NumTPLists, TPLists);
+ getExtInfo()->setTemplateParameterListsInfo(Context, NumTPLists, TPLists);
}
// Implement isa/cast/dyncast/etc.
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=106008&r1=106007&r2=106008&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Jun 15 12:44:38 2010
@@ -567,7 +567,8 @@
}
void
-QualifierInfo::setTemplateParameterListsInfo(unsigned NumTPLists,
+QualifierInfo::setTemplateParameterListsInfo(ASTContext &Context,
+ unsigned NumTPLists,
TemplateParameterList **TPLists) {
assert((NumTPLists == 0 || TPLists != 0) &&
"Empty array of template parameters with positive size!");
@@ -576,19 +577,25 @@
// Free previous template parameters (if any).
if (NumTemplParamLists > 0) {
- delete[] TemplParamLists;
+ Context.Deallocate(TemplParamLists);
TemplParamLists = 0;
NumTemplParamLists = 0;
}
// Set info on matched template parameter lists (if any).
if (NumTPLists > 0) {
- TemplParamLists = new TemplateParameterList*[NumTPLists];
+ TemplParamLists = new (Context) TemplateParameterList*[NumTPLists];
NumTemplParamLists = NumTPLists;
for (unsigned i = NumTPLists; i-- > 0; )
TemplParamLists[i] = TPLists[i];
}
}
+void QualifierInfo::Destroy(ASTContext &Context) {
+ // FIXME: Deallocate template parameter lists themselves!
+ if (TemplParamLists)
+ Context.Deallocate(TemplParamLists);
+}
+
//===----------------------------------------------------------------------===//
// VarDecl Implementation
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=106008&r1=106007&r2=106008&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jun 15 12:44:38 2010
@@ -2573,7 +2573,8 @@
SetNestedNameSpecifier(NewVD, D);
if (NumMatchedTemplateParamLists > 0) {
- NewVD->setTemplateParameterListsInfo(NumMatchedTemplateParamLists,
+ NewVD->setTemplateParameterListsInfo(Context,
+ NumMatchedTemplateParamLists,
(TemplateParameterList**)TemplateParamLists.release());
}
@@ -3151,7 +3152,8 @@
}
if (NumMatchedTemplateParamLists > 0) {
- NewFD->setTemplateParameterListsInfo(NumMatchedTemplateParamLists,
+ NewFD->setTemplateParameterListsInfo(Context,
+ NumMatchedTemplateParamLists,
(TemplateParameterList**)TemplateParamLists.release());
}
@@ -5412,7 +5414,8 @@
= static_cast<NestedNameSpecifier*>(SS.getScopeRep());
New->setQualifierInfo(NNS, SS.getRange());
if (NumMatchedTemplateParamLists > 0) {
- New->setTemplateParameterListsInfo(NumMatchedTemplateParamLists,
+ New->setTemplateParameterListsInfo(Context,
+ NumMatchedTemplateParamLists,
(TemplateParameterList**) TemplateParameterLists.release());
}
}
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=106008&r1=106007&r2=106008&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue Jun 15 12:44:38 2010
@@ -3868,7 +3868,8 @@
SequenceNumber);
SetNestedNameSpecifier(Partial, SS);
if (NumMatchedTemplateParamLists > 0) {
- Partial->setTemplateParameterListsInfo(NumMatchedTemplateParamLists,
+ Partial->setTemplateParameterListsInfo(Context,
+ NumMatchedTemplateParamLists,
(TemplateParameterList**) TemplateParameterLists.release());
}
@@ -3929,8 +3930,8 @@
PrevDecl);
SetNestedNameSpecifier(Specialization, SS);
if (NumMatchedTemplateParamLists > 0) {
- Specialization->setTemplateParameterListsInfo(
- NumMatchedTemplateParamLists,
+ Specialization->setTemplateParameterListsInfo(Context,
+ NumMatchedTemplateParamLists,
(TemplateParameterList**) TemplateParameterLists.release());
}
More information about the cfe-commits
mailing list