Patch by Alexei Svitkine: Refactor Sema::ParseAST API to allow clients to pass as an argument a TranslationUnit object whose contents live beyond the call to ParseAST.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63175 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/clang.cpp b/Driver/clang.cpp
index 51f4a5d..bc548e4 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -1418,9 +1418,20 @@
ClearSourceMgr = true;
break;
}
-
- if (Consumer)
- ParseAST(PP, Consumer.get(), Stats, !DisableFree);
+
+ if (Consumer) {
+ TranslationUnit *TU = 0;
+ if (DisableFree) {
+ ASTContext *Context = new ASTContext(PP.getLangOptions(),
+ PP.getSourceManager(),
+ PP.getTargetInfo(),
+ PP.getIdentifierTable(),
+ PP.getSelectorTable(),
+ /* FreeMemory = */ false);
+ TU = new TranslationUnit(*Context);
+ }
+ ParseAST(PP, Consumer.get(), TU, Stats);
+ }
if (VerifyDiagnostics)
if (CheckDiagnostics(PP))