Fix ownership model of ParseAST to allow the dtor of
ASTConsumer to process the AST before it is destroyed.
This allows elimination of HandleObjcMetaDataEmission.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43659 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/ASTStreamer.cpp b/Sema/ASTStreamer.cpp
index d7f59af..be43289 100644
--- a/Sema/ASTStreamer.cpp
+++ b/Sema/ASTStreamer.cpp
@@ -89,9 +89,10 @@
//===----------------------------------------------------------------------===//
/// ParseAST - Parse the entire file specified, notifying the ASTConsumer as
-/// the file is parsed.
+/// the file is parsed. This takes ownership of the ASTConsumer and
+/// ultimately deletes it.
void clang::ParseAST(Preprocessor &PP, unsigned MainFileID,
- ASTConsumer &Consumer, bool PrintStats) {
+ ASTConsumer *Consumer, bool PrintStats) {
// Collect global stats on Decls/Stmts (until we have a module streamer).
if (PrintStats) {
Decl::CollectingStats(true);
@@ -103,22 +104,22 @@
ASTStreamer Streamer(PP, Context, MainFileID);
- Consumer.Initialize(Context, MainFileID);
+ Consumer->Initialize(Context, MainFileID);
while (Decl *D = Streamer.ReadTopLevelDecl())
- Consumer.HandleTopLevelDecl(D);
+ Consumer->HandleTopLevelDecl(D);
- Consumer.HandleObjcMetaDataEmission();
-
if (PrintStats) {
fprintf(stderr, "\nSTATISTICS:\n");
Streamer.PrintStats();
Context.PrintStats();
Decl::PrintStats();
Stmt::PrintStats();
- Consumer.PrintStats();
+ Consumer->PrintStats();
Decl::CollectingStats(false);
Stmt::CollectingStats(false);
}
+
+ delete Consumer;
}