]> granicus.if.org Git - clang/commitdiff
Frontend: Stop leaking when not -disable-free
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 4 May 2015 12:36:56 +0000 (12:36 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 4 May 2015 12:36:56 +0000 (12:36 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236419 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/FrontendAction.cpp

index d42ca718c397da1d0a1d1e839abbb565512e9ed4..3c136262ef7a5199d7e8b400aa37e395b3b3fde5 100644 (file)
@@ -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);