diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-03-28 01:37:17 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-03-28 01:37:17 +0000 |
| commit | 84bcc4795e5bae96ae547421d8615471bbc87148 (patch) | |
| tree | 0aeb629d592e1851c12783950417597b17799e1e /clang/tools/clang-cc | |
| parent | 8b7b1b1aee8685c34130f7e4a8457a52558af034 (diff) | |
| download | bcm5719-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.cpp | 27 |
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) |

