summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-07-25 17:53:33 +0000
committerDouglas Gregor <dgregor@apple.com>2010-07-25 17:53:33 +0000
commit5b11d49a7c2ea35903004198dd5570afe6ab0529 (patch)
tree51b3718bd357aff0b481f5294d8d987a94a738fe /clang/lib/AST
parentf2430ba223687538681071ce4746a2878ad3db53 (diff)
downloadbcm5719-llvm-5b11d49a7c2ea35903004198dd5570afe6ab0529.tar.gz
bcm5719-llvm-5b11d49a7c2ea35903004198dd5570afe6ab0529.zip
Make ASTContext always use the BumpPtrAllocator.
llvm-svn: 109375
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ASTContext.cpp66
-rw-r--r--clang/lib/AST/DeclarationName.cpp20
2 files changed, 15 insertions, 71 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 330f42e8353..c63d9734254 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -138,7 +138,7 @@ ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
const TargetInfo &t,
IdentifierTable &idents, SelectorTable &sels,
Builtin::Context &builtins,
- bool FreeMem, unsigned size_reserve) :
+ unsigned size_reserve) :
TemplateSpecializationTypes(this_()),
DependentTemplateSpecializationTypes(this_()),
GlobalNestedNameSpecifier(0), IsInt128Installed(false),
@@ -146,7 +146,7 @@ ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
ObjCFastEnumerationStateTypeDecl(0), FILEDecl(0), jmp_bufDecl(0),
sigjmp_bufDecl(0), BlockDescriptorType(0), BlockDescriptorExtendedType(0),
NullTypeSourceInfo(QualType()),
- SourceMgr(SM), LangOpts(LOpts), FreeMemory(FreeMem), Target(t),
+ SourceMgr(SM), LangOpts(LOpts), Target(t),
Idents(idents), Selectors(sels),
BuiltinInfo(builtins),
DeclarationNames(*this),
@@ -155,7 +155,7 @@ ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
UniqueBlockByRefTypeID(0), UniqueBlockParmTypeID(0) {
ObjCIdRedefinitionType = QualType();
ObjCClassRedefinitionType = QualType();
- ObjCSelRedefinitionType = QualType();
+ ObjCSelRedefinitionType = QualType();
if (size_reserve > 0) Types.reserve(size_reserve);
TUDecl = TranslationUnitDecl::Create(*this);
InitBuiltinTypes();
@@ -166,11 +166,9 @@ ASTContext::~ASTContext() {
// FIXME: Is this the ideal solution?
ReleaseDeclContextMaps();
- if (!FreeMemory) {
- // Call all of the deallocation functions.
- for (unsigned I = 0, N = Deallocations.size(); I != N; ++I)
- Deallocations[I].first(Deallocations[I].second);
- }
+ // Call all of the deallocation functions.
+ for (unsigned I = 0, N = Deallocations.size(); I != N; ++I)
+ Deallocations[I].first(Deallocations[I].second);
// Release all of the memory associated with overridden C++ methods.
for (llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::iterator
@@ -178,53 +176,23 @@ ASTContext::~ASTContext() {
OM != OMEnd; ++OM)
OM->second.Destroy();
- if (FreeMemory) {
- // Deallocate all the types.
- while (!Types.empty()) {
- Types.back()->Destroy(*this);
- Types.pop_back();
- }
-
- for (llvm::FoldingSet<ExtQuals>::iterator
- I = ExtQualNodes.begin(), E = ExtQualNodes.end(); I != E; ) {
- // Increment in loop to prevent using deallocated memory.
- Deallocate(&*I++);
- }
-
- for (llvm::DenseMap<const ObjCContainerDecl*,
- const ASTRecordLayout*>::iterator
- I = ObjCLayouts.begin(), E = ObjCLayouts.end(); I != E; ) {
- // Increment in loop to prevent using deallocated memory.
- if (ASTRecordLayout *R = const_cast<ASTRecordLayout*>((I++)->second))
- R->Destroy(*this);
- }
- }
-
// ASTRecordLayout objects in ASTRecordLayouts must always be destroyed
- // even when using the BumpPtrAllocator because they can contain
- // DenseMaps.
+ // because they can contain DenseMaps.
+ for (llvm::DenseMap<const ObjCContainerDecl*,
+ const ASTRecordLayout*>::iterator
+ I = ObjCLayouts.begin(), E = ObjCLayouts.end(); I != E; )
+ // Increment in loop to prevent using deallocated memory.
+ if (ASTRecordLayout *R = const_cast<ASTRecordLayout*>((I++)->second))
+ R->Destroy(*this);
+
for (llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>::iterator
I = ASTRecordLayouts.begin(), E = ASTRecordLayouts.end(); I != E; ) {
// Increment in loop to prevent using deallocated memory.
if (ASTRecordLayout *R = const_cast<ASTRecordLayout*>((I++)->second))
R->Destroy(*this);
}
-
- // Destroy nested-name-specifiers.
- for (llvm::FoldingSet<NestedNameSpecifier>::iterator
- NNS = NestedNameSpecifiers.begin(),
- NNSEnd = NestedNameSpecifiers.end();
- NNS != NNSEnd; ) {
- // Increment in loop to prevent using deallocated memory.
- (*NNS++).Destroy(*this);
}
- if (GlobalNestedNameSpecifier)
- GlobalNestedNameSpecifier->Destroy(*this);
-
- TUDecl->Destroy(*this);
-}
-
void ASTContext::AddDeallocation(void (*Callback)(void*), void *Data) {
Deallocations.push_back(std::make_pair(Callback, Data));
}
@@ -275,16 +243,12 @@ void ASTContext::PrintStats() const {
fprintf(stderr, " %u/%u implicit destructors created\n",
NumImplicitDestructorsDeclared, NumImplicitDestructors);
- if (!FreeMemory)
- BumpAlloc.PrintStats();
-
if (ExternalSource.get()) {
fprintf(stderr, "\n");
ExternalSource->PrintStats();
}
- if (!FreeMemory)
- BumpAlloc.PrintStats();
+ BumpAlloc.PrintStats();
}
diff --git a/clang/lib/AST/DeclarationName.cpp b/clang/lib/AST/DeclarationName.cpp
index 343d403e76a..606ce891807 100644
--- a/clang/lib/AST/DeclarationName.cpp
+++ b/clang/lib/AST/DeclarationName.cpp
@@ -404,26 +404,6 @@ DeclarationNameTable::~DeclarationNameTable() {
= static_cast<llvm::FoldingSet<CXXLiteralOperatorIdName>*>
(CXXLiteralOperatorNames);
- if (Ctx.FreeMemory) {
- llvm::FoldingSetIterator<CXXSpecialName>
- SI = SpecialNames->begin(), SE = SpecialNames->end();
-
- while (SI != SE) {
- CXXSpecialName *n = &*SI++;
- Ctx.Deallocate(n);
- }
-
- llvm::FoldingSetIterator<CXXLiteralOperatorIdName>
- LI = LiteralNames->begin(), LE = LiteralNames->end();
-
- while (LI != LE) {
- CXXLiteralOperatorIdName *n = &*LI++;
- Ctx.Deallocate(n);
- }
-
- Ctx.Deallocate(CXXOperatorNames);
- }
-
delete SpecialNames;
delete LiteralNames;
}
OpenPOWER on IntegriCloud