r236419 - Frontend: Stop leaking when not -disable-free

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon May 4 05:36:56 PDT 2015


Author: dexonsmith
Date: Mon May  4 07:36:56 2015
New Revision: 236419

URL: http://llvm.org/viewvc/llvm-project?rev=236419&view=rev
Log:
Frontend: Stop leaking when not -disable-free

Try again to plug a leak that's been around since at least r128011 after
coming across the FIXME.  Nico Weber tried something similar in r207065
but had to revert in r207070 due to a bot failure.

The build failure isn't visible anymore so I'm not sure what went wrong.
I'm doing this slightly differently -- when not -disable-free I'm still
resetting the members (just not leaking them) -- so maybe it will work
out this time?  Tests pass locally, anyway.

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=236419&r1=236418&r2=236419&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Mon May  4 07:36:56 2015
@@ -494,13 +494,20 @@ void FrontendAction::EndSourceFile() {
   // FrontendAction.
   CI.clearOutputFiles(/*EraseFiles=*/shouldEraseOutputFiles());
 
-  // FIXME: Only do this if DisableFree is set.
   if (isCurrentFileAST()) {
-    CI.resetAndLeakSema();
-    CI.resetAndLeakASTContext();
-    CI.resetAndLeakPreprocessor();
-    CI.resetAndLeakSourceManager();
-    CI.resetAndLeakFileManager();
+    if (DisableFree) {
+      CI.resetAndLeakSema();
+      CI.resetAndLeakASTContext();
+      CI.resetAndLeakPreprocessor();
+      CI.resetAndLeakSourceManager();
+      CI.resetAndLeakFileManager();
+    } else {
+      CI.setSema(nullptr);
+      CI.setASTContext(nullptr);
+      CI.setPreprocessor(nullptr);
+      CI.setSourceManager(nullptr);
+      CI.setFileManager(nullptr);
+    }
   }
 
   setCompilerInstance(nullptr);





More information about the cfe-commits mailing list