summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-05-23 18:26:36 +0000
committerDouglas Gregor <dgregor@apple.com>2010-05-23 18:26:36 +0000
commit1a80933d24cb290eff24404be4571a054ede9a0d (patch)
tree04fd44a437480d80eeecd540f6a19ed00f75b64c /clang/lib/AST/ASTContext.cpp
parent5773205a8d99859d91d23ab299fc4ece7ab0c354 (diff)
downloadbcm5719-llvm-1a80933d24cb290eff24404be4571a054ede9a0d.tar.gz
bcm5719-llvm-1a80933d24cb290eff24404be4571a054ede9a0d.zip
Keep track of all of the class and function template's "common"
pointers in the ASTContext, so that the folding sets stored inside them will be deallocated when the ASTContext is destroyed (under -disable-free). <rdar://problem/7998824>. llvm-svn: 104465
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r--clang/lib/AST/ASTContext.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 801a1f63917..d6e094e5b4a 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -64,6 +64,12 @@ 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);
+ }
+
// Release all of the memory associated with overridden C++ methods.
for (llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::iterator
OM = OverriddenMethods.begin(), OMEnd = OverriddenMethods.end();
@@ -114,6 +120,10 @@ ASTContext::~ASTContext() {
TUDecl->Destroy(*this);
}
+void ASTContext::AddDeallocation(void (*Callback)(void*), void *Data) {
+ Deallocations.push_back(std::make_pair(Callback, Data));
+}
+
void
ASTContext::setExternalSource(llvm::OwningPtr<ExternalASTSource> &Source) {
ExternalSource.reset(Source.take());
OpenPOWER on IntegriCloud