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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54502 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2008-08-08 02:46:37 +00:00
Родитель 909cd267dd
Коммит 7e7e6253d4
3 изменённых файлов: 9 добавлений и 14 удалений

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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

Просмотреть файл

@ -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;
}