[cfe-commits] r54502 - in /cfe/trunk: Driver/clang.cpp include/clang/Sema/ParseAST.h lib/Sema/ParseAST.cpp
Ted Kremenek
kremenek at apple.com
Thu Aug 7 19:46:38 PDT 2008
Author: kremenek
Date: Thu Aug 7 21:46:37 2008
New Revision: 54502
URL: http://llvm.org/viewvc/llvm-project?rev=54502&view=rev
Log:
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.
Modified:
cfe/trunk/Driver/clang.cpp
cfe/trunk/include/clang/Sema/ParseAST.h
cfe/trunk/lib/Sema/ParseAST.cpp
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=54502&r1=54501&r2=54502&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Thu Aug 7 21:46:37 2008
@@ -1228,14 +1228,14 @@
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 @@
break;
case ParseSyntaxOnly: // -fsyntax-only
- Consumer = new ASTConsumer();
+ Consumer.reset(new ASTConsumer());
break;
case RewriteMacros:
@@ -1294,10 +1294,9 @@
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) {
Modified: cfe/trunk/include/clang/Sema/ParseAST.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParseAST.h?rev=54502&r1=54501&r2=54502&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/ParseAST.h (original)
+++ cfe/trunk/include/clang/Sema/ParseAST.h Thu Aug 7 21:46:37 2008
@@ -21,8 +21,7 @@
/// 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
Modified: cfe/trunk/lib/Sema/ParseAST.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ParseAST.cpp?rev=54502&r1=54501&r2=54502&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/ParseAST.cpp (original)
+++ cfe/trunk/lib/Sema/ParseAST.cpp Thu Aug 7 21:46:37 2008
@@ -27,7 +27,7 @@
/// 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 @@
Decl::CollectingStats(false);
Stmt::CollectingStats(false);
}
-
- if (DeleteConsumer)
- delete Consumer;
}
More information about the cfe-commits
mailing list