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");
break;
case ParseSyntaxOnly: // -fsyntax-only
- Consumer = new ASTConsumer();
+ Consumer.reset(new ASTConsumer());
break;
case RewriteMacros:
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) {
/// 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
/// 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);
Decl::CollectingStats(false);
Stmt::CollectingStats(false);
}
-
- if (DeleteConsumer)
- delete Consumer;
}