aboutsummaryrefslogtreecommitdiff
path: root/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
commit0054531488928a424666ac11fcdc6bcc5112de52 (patch)
treecfca1427469235ca09dbbb57cf477eaa2ad364b1 /lib/AST/ASTContext.cpp
parentbfcdc40cbc213d91d91513ba8e1fbde65734ddf4 (diff)
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>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104465 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r--lib/AST/ASTContext.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 801a1f6391..d6e094e5b4 100644
--- a/lib/AST/ASTContext.cpp
+++ b/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());