[cfe-commits] r43659 - in /cfe/trunk: Driver/DiagChecker.cpp Driver/RewriteTest.cpp Driver/clang.cpp Sema/ASTStreamer.cpp include/clang/AST/ASTConsumer.h include/clang/Sema/ASTStreamer.h
Chris Lattner
sabre at nondot.org
Fri Nov 2 23:24:17 PDT 2007
Author: lattner
Date: Sat Nov 3 01:24:16 2007
New Revision: 43659
URL: http://llvm.org/viewvc/llvm-project?rev=43659&view=rev
Log:
Fix ownership model of ParseAST to allow the dtor of
ASTConsumer to process the AST before it is destroyed.
This allows elimination of HandleObjcMetaDataEmission.
Modified:
cfe/trunk/Driver/DiagChecker.cpp
cfe/trunk/Driver/RewriteTest.cpp
cfe/trunk/Driver/clang.cpp
cfe/trunk/Sema/ASTStreamer.cpp
cfe/trunk/include/clang/AST/ASTConsumer.h
cfe/trunk/include/clang/Sema/ASTStreamer.h
Modified: cfe/trunk/Driver/DiagChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/DiagChecker.cpp?rev=43659&r1=43658&r2=43659&view=diff
==============================================================================
--- cfe/trunk/Driver/DiagChecker.cpp (original)
+++ cfe/trunk/Driver/DiagChecker.cpp Sat Nov 3 01:24:16 2007
@@ -227,8 +227,8 @@
/// CheckASTConsumer - Implement diagnostic checking for AST consumers.
bool clang::CheckASTConsumer(Preprocessor &PP, unsigned MainFileID,
ASTConsumer* C) {
-
- ParseAST(PP, MainFileID, *C);
+ // Parse the AST and run the consumer, ultimately deleting C.
+ ParseAST(PP, MainFileID, C);
// Gather the set of expected diagnostics.
DiagList ExpectedErrors, ExpectedWarnings;
Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=43659&r1=43658&r2=43659&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Sat Nov 3 01:24:16 2007
@@ -79,7 +79,6 @@
void SynthGetClassFunctionDecl();
// Metadata emission.
- void HandleObjcMetaDataEmission();
void RewriteObjcClassMetaData(ObjcImplementationDecl *IDecl,
std::string &Result);
@@ -162,6 +161,12 @@
// Get the top-level buffer that this corresponds to.
RewriteTabs();
+ // Rewrite Objective-c meta data*
+ std::string ResultStr;
+ WriteObjcMetaData(ResultStr);
+ // For now just print the string out.
+ printf("%s", ResultStr.c_str());
+
// Get the buffer corresponding to MainFileID. If we haven't changed it, then
// we are done.
if (const RewriteBuffer *RewriteBuf =
@@ -175,16 +180,6 @@
}
-/// HandleObjcMetaDataEmission - main routine to generate objective-c's
-/// metadata.
-void RewriteTest::HandleObjcMetaDataEmission() {
- // Rewrite Objective-c meta data*
- std::string ResultStr;
- WriteObjcMetaData(ResultStr);
- // For now just print the string out.
- printf("%s", ResultStr.c_str());
-}
-
//===----------------------------------------------------------------------===//
// Syntactic (non-AST) Rewriting Code
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=43659&r1=43658&r2=43659&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Sat Nov 3 01:24:16 2007
@@ -821,11 +821,10 @@
if (Consumer) {
if (VerifyDiagnostics)
- exit (CheckASTConsumer(PP, MainFileID, Consumer));
- else
- ParseAST(PP, MainFileID, *Consumer, Stats);
-
- delete Consumer;
+ exit(CheckASTConsumer(PP, MainFileID, Consumer));
+
+ // This deletes Consumer.
+ ParseAST(PP, MainFileID, Consumer, Stats);
}
if (Stats) {
Modified: cfe/trunk/Sema/ASTStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/ASTStreamer.cpp?rev=43659&r1=43658&r2=43659&view=diff
==============================================================================
--- cfe/trunk/Sema/ASTStreamer.cpp (original)
+++ cfe/trunk/Sema/ASTStreamer.cpp Sat Nov 3 01:24:16 2007
@@ -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;
}
Modified: cfe/trunk/include/clang/AST/ASTConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTConsumer.h?rev=43659&r1=43658&r2=43659&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTConsumer.h (original)
+++ cfe/trunk/include/clang/AST/ASTConsumer.h Sat Nov 3 01:24:16 2007
@@ -34,11 +34,6 @@
virtual void HandleTopLevelDecl(Decl *D) {
}
- /// HandleObjcMetaDataEmission - top level routine for objective-c
- /// metadata emission.
- virtual void HandleObjcMetaDataEmission() {
- }
-
/// PrintStats - If desired, print any statistics.
virtual void PrintStats() {
}
Modified: cfe/trunk/include/clang/Sema/ASTStreamer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ASTStreamer.h?rev=43659&r1=43658&r2=43659&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/ASTStreamer.h (original)
+++ cfe/trunk/include/clang/Sema/ASTStreamer.h Sat Nov 3 01:24:16 2007
@@ -21,9 +21,10 @@
class ASTConsumer;
/// ParseAST - Parse the entire file specified, notifying the ASTConsumer as
- /// the file is parsed. This does not take ownership of the ASTConsumer.
+ /// the file is parsed. This takes ownership of the ASTConsumer and
+ /// ultimately deletes it.
void ParseAST(Preprocessor &pp, unsigned MainFileID,
- ASTConsumer &C, bool PrintStats = false);
+ ASTConsumer *C, bool PrintStats = false);
} // end namespace clang
#endif
More information about the cfe-commits
mailing list