r207065 - Don't leak objects in load-from-ast path unless DisableFree is set.

Nico Weber nicolasweber at gmx.de
Wed Apr 23 19:42:04 PDT 2014


Author: nico
Date: Wed Apr 23 21:42:04 2014
New Revision: 207065

URL: http://llvm.org/viewvc/llvm-project?rev=207065&view=rev
Log:
Don't leak objects in load-from-ast path unless DisableFree is set.

Also update a comment to match a code change that was done in r110978.

Modified:
    cfe/trunk/lib/Frontend/FrontendAction.cpp

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=207065&r1=207064&r2=207065&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Wed Apr 23 21:42:04 2014
@@ -408,16 +408,16 @@ void FrontendAction::EndSourceFile() {
   // Finalize the action.
   EndSourceFileAction();
 
-  // Release the consumer and the AST, in that order since the consumer may
-  // perform actions in its destructor which require the context.
+  // Sema references the ast consumer, so reset sema first.
   //
   // FIXME: There is more per-file stuff we could just drop here?
-  if (CI.getFrontendOpts().DisableFree) {
-    BuryPointer(CI.takeASTConsumer());
+  bool DisableFree = CI.getFrontendOpts().DisableFree;
+  if (DisableFree) {
     if (!isCurrentFileAST()) {
       CI.resetAndLeakSema();
       CI.resetAndLeakASTContext();
     }
+    BuryPointer(CI.takeASTConsumer());
   } else {
     if (!isCurrentFileAST()) {
       CI.setSema(0);
@@ -443,7 +443,7 @@ void FrontendAction::EndSourceFile() {
   // FrontendAction.
   CI.clearOutputFiles(/*EraseFiles=*/shouldEraseOutputFiles());
 
-  if (isCurrentFileAST()) {
+  if (DisableFree && isCurrentFileAST()) {
     CI.resetAndLeakSema();
     CI.resetAndLeakASTContext();
     CI.resetAndLeakPreprocessor();





More information about the cfe-commits mailing list