[cfe-commits] r90174 - /cfe/trunk/lib/AST/DeclBase.cpp
Ted Kremenek
kremenek at apple.com
Mon Nov 30 16:07:10 PST 2009
Author: kremenek
Date: Mon Nov 30 18:07:10 2009
New Revision: 90174
URL: http://llvm.org/viewvc/llvm-project?rev=90174&view=rev
Log:
Allocate MultipleDC objects using the allocator associated with
ASTContext instead of malloc. Besides reducing malloc traffic, this
also removes a source of memory leaks when using a BumpPtrAllocator
for the allocator of ASTContext. There are still leaks when using
MallocAllocator because Decl::Destroy() isn't fully finished.
Fixes: <rdar://problem/7431556>
Modified:
cfe/trunk/lib/AST/DeclBase.cpp
Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=90174&r1=90173&r2=90174&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Mon Nov 30 18:07:10 2009
@@ -129,9 +129,6 @@
// Out-of-line virtual method providing a home for Decl.
Decl::~Decl() {
- if (isOutOfSemaDC())
- delete getMultipleDC();
-
assert(!HasAttrs && "attributes should have been freed by Destroy");
}
@@ -147,7 +144,7 @@
return;
if (isInSemaDC()) {
- MultipleDC *MDC = new MultipleDC();
+ MultipleDC *MDC = new (getASTContext()) MultipleDC();
MDC->SemanticDC = getDeclContext();
MDC->LexicalDC = DC;
DeclCtx = MDC;
@@ -342,9 +339,12 @@
N = Tmp;
}
+ if (isOutOfSemaDC())
+ delete (C) getMultipleDC();
+
this->~Decl();
C.Deallocate((void *)this);
-#endif
+#endif
}
Decl *Decl::castFromDeclContext (const DeclContext *D) {
More information about the cfe-commits
mailing list