summaryrefslogtreecommitdiffstats
path: root/clang/tools/clang-cc
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-28 01:37:17 +0000
committerChris Lattner <sabre@nondot.org>2009-03-28 01:37:17 +0000
commit84bcc4795e5bae96ae547421d8615471bbc87148 (patch)
tree0aeb629d592e1851c12783950417597b17799e1e /clang/tools/clang-cc
parent8b7b1b1aee8685c34130f7e4a8457a52558af034 (diff)
downloadbcm5719-llvm-84bcc4795e5bae96ae547421d8615471bbc87148.tar.gz
bcm5719-llvm-84bcc4795e5bae96ae547421d8615471bbc87148.zip
simplify ParseAST by sucking -disable-free handling logic up into
clang.cpp llvm-svn: 67890
Diffstat (limited to 'clang/tools/clang-cc')
-rw-r--r--clang/tools/clang-cc/clang.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/clang/tools/clang-cc/clang.cpp b/clang/tools/clang-cc/clang.cpp
index 5d3f68dd8ef..3b2afa91a61 100644
--- a/clang/tools/clang-cc/clang.cpp
+++ b/clang/tools/clang-cc/clang.cpp
@@ -1476,17 +1476,26 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
}
if (Consumer) {
- TranslationUnit *TU = 0;
+ llvm::OwningPtr<ASTContext> ContextOwner;
+ llvm::OwningPtr<TranslationUnit> TranslationUnitOwner;
+
+ ContextOwner.reset(new ASTContext(PP.getLangOptions(),
+ PP.getSourceManager(),
+ PP.getTargetInfo(),
+ PP.getIdentifierTable(),
+ PP.getSelectorTable(),
+ /* FreeMemory = */ !DisableFree));
+ TranslationUnitOwner.reset(new TranslationUnit(*ContextOwner.get()));
+
+
+ ParseAST(PP, Consumer.get(), *TranslationUnitOwner.get(), Stats);
+
+ // If in -disable-free mode, don't deallocate these when they go out of
+ // scope.
if (DisableFree) {
- ASTContext *Context = new ASTContext(PP.getLangOptions(),
- PP.getSourceManager(),
- PP.getTargetInfo(),
- PP.getIdentifierTable(),
- PP.getSelectorTable(),
- /* FreeMemory = */ false);
- TU = new TranslationUnit(*Context);
+ ContextOwner.take();
+ TranslationUnitOwner.take();
}
- ParseAST(PP, Consumer.get(), TU, Stats);
}
if (VerifyDiagnostics)
OpenPOWER on IntegriCloud