diff options
| author | Ted Kremenek <kremenek@apple.com> | 2008-08-08 02:46:37 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2008-08-08 02:46:37 +0000 |
| commit | dcb5e38927a9ffd7daa82ac205e8a8ee06b8321c (patch) | |
| tree | e63bc93c5c5dd551415e370b000271ad585d5c9b /clang | |
| parent | 4a35180f6d07bc2af7d8901a04d68d47bfccc8ee (diff) | |
| download | bcm5719-llvm-dcb5e38927a9ffd7daa82ac205e8a8ee06b8321c.tar.gz bcm5719-llvm-dcb5e38927a9ffd7daa82ac205e8a8ee06b8321c.zip | |
ParseAST now never releases the passed ASTConsumer. This is the responsibility of the client.
The motivation is that clients may either:
(a) query the ASTConsumer object after AST parsing to collect data/etc.
(b) reuse the ASTConsumer.
llvm-svn: 54502
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/Driver/clang.cpp | 15 | ||||
| -rw-r--r-- | clang/include/clang/Sema/ParseAST.h | 3 | ||||
| -rw-r--r-- | clang/lib/Sema/ParseAST.cpp | 5 |
3 files changed, 9 insertions, 14 deletions
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp index 28ec5ffbb78..8bafbd50789 100644 --- a/clang/Driver/clang.cpp +++ b/clang/Driver/clang.cpp @@ -1228,14 +1228,14 @@ static ASTConsumer* CreateASTConsumer(const std::string& InFile, static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, const std::string &InFile) { - ASTConsumer* Consumer = NULL; + llvm::OwningPtr<ASTConsumer> Consumer; bool ClearSourceMgr = false; switch (ProgAction) { default: - Consumer = CreateASTConsumer(InFile, PP.getDiagnostics(), - PP.getFileManager(), PP.getLangOptions(), &PP, - &PPF); + Consumer.reset(CreateASTConsumer(InFile, PP.getDiagnostics(), + PP.getFileManager(), PP.getLangOptions(), + &PP, &PPF)); if (!Consumer) { fprintf(stderr, "Unexpected program action!\n"); @@ -1283,7 +1283,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, break; case ParseSyntaxOnly: // -fsyntax-only - Consumer = new ASTConsumer(); + Consumer.reset(new ASTConsumer()); break; case RewriteMacros: @@ -1294,10 +1294,9 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, if (Consumer) { if (VerifyDiagnostics) - exit(CheckASTConsumer(PP, Consumer)); + exit(CheckASTConsumer(PP, Consumer.get())); - // This deletes Consumer. - ParseAST(PP, Consumer, Stats); + ParseAST(PP, Consumer.get(), Stats); } if (Stats) { diff --git a/clang/include/clang/Sema/ParseAST.h b/clang/include/clang/Sema/ParseAST.h index 4d77a58abd8..907372ddef4 100644 --- a/clang/include/clang/Sema/ParseAST.h +++ b/clang/include/clang/Sema/ParseAST.h @@ -21,8 +21,7 @@ namespace clang { /// ParseAST - Parse the entire file specified, notifying the ASTConsumer as /// the file is parsed. This takes ownership of the ASTConsumer and /// ultimately deletes it. - void ParseAST(Preprocessor &pp, ASTConsumer *C, bool PrintStats = false, - bool DeleteConsumer = true); + void ParseAST(Preprocessor &pp, ASTConsumer *C, bool PrintStats = false); } // end namespace clang diff --git a/clang/lib/Sema/ParseAST.cpp b/clang/lib/Sema/ParseAST.cpp index 6b9b8d5804d..43736e32ac5 100644 --- a/clang/lib/Sema/ParseAST.cpp +++ b/clang/lib/Sema/ParseAST.cpp @@ -27,7 +27,7 @@ using namespace clang; /// ParseAST - Parse the entire file specified, notifying the ASTConsumer as /// the file is parsed. This takes ownership of the ASTConsumer and /// ultimately deletes it. -void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, bool PrintStats, bool DeleteConsumer) { +void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, bool PrintStats) { // Collect global stats on Decls/Stmts (until we have a module streamer). if (PrintStats) { Decl::CollectingStats(true); @@ -77,7 +77,4 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, bool PrintStats, b Decl::CollectingStats(false); Stmt::CollectingStats(false); } - - if (DeleteConsumer) - delete Consumer; } |

