aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-02-06 00:15:02 +0000
committerChris Lattner <sabre@nondot.org>2008-02-06 00:15:02 +0000
commita0e328f9953e2d8e83227ffa601f5a606b7aa062 (patch)
tree25951cb069590e232e32917e3d041e94b081c3e6
parentea041758d49215167e473a515b8d46e77b170ccf (diff)
kill the ASTStreamer class, inlining it into its only client: clang::ParseAST
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46785 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Sema/ASTStreamer.cpp64
1 files changed, 14 insertions, 50 deletions
diff --git a/Sema/ASTStreamer.cpp b/Sema/ASTStreamer.cpp
index 11ec72737e..5346a59ae1 100644
--- a/Sema/ASTStreamer.cpp
+++ b/Sema/ASTStreamer.cpp
@@ -21,52 +21,6 @@ using namespace clang;
ASTConsumer::~ASTConsumer() {}
-namespace {
- class ASTStreamer {
- Parser P;
- public:
- ASTStreamer(Preprocessor &pp, ASTContext &ctxt)
- : P(pp, *new Sema(pp, ctxt)) {
-
- pp.EnterMainSourceFile();
-
- // Initialize the parser.
- P.Initialize();
- }
-
- /// ReadTopLevelDecl - Parse and return the next top-level declaration.
- Decl *ReadTopLevelDecl();
-
- void PrintStats() const;
-
- ~ASTStreamer() {
- P.Finalize();
- delete &P.getActions();
- }
- };
-}
-
-/// ReadTopLevelDecl - Parse and return the next top-level declaration.
-///
-Decl *ASTStreamer::ReadTopLevelDecl() {
- Parser::DeclTy *Result;
-
- do {
- if (P.ParseTopLevelDecl(Result))
- return 0; // End of file.
-
- // If we got a null return and something *was* parsed, try again. This
- // is due to a top-level semicolon, an action override, or a parse error
- // skipping something.
- } while (Result == 0);
-
- return static_cast<Decl*>(Result);
-}
-
-void ASTStreamer::PrintStats() const {
- P.getActions().PrintStats();
-}
-
//===----------------------------------------------------------------------===//
// Public interface to the file
//===----------------------------------------------------------------------===//
@@ -84,16 +38,26 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, bool PrintStats) {
ASTContext Context(PP.getSourceManager(), PP.getTargetInfo(),
PP.getIdentifierTable(), PP.getSelectorTable());
- ASTStreamer Streamer(PP, Context);
+ Parser P(PP, *new Sema(PP, Context));
+ PP.EnterMainSourceFile();
+
+ // Initialize the parser.
+ P.Initialize();
Consumer->Initialize(Context);
- while (Decl *D = Streamer.ReadTopLevelDecl())
- Consumer->HandleTopLevelDecl(D);
+ Parser::DeclTy *ADecl;
+ while (!P.ParseTopLevelDecl(ADecl)) { // Not end of file.
+ // If we got a null return and something *was* parsed, ignore it. This
+ // is due to a top-level semicolon, an action override, or a parse error
+ // skipping something.
+ if (ADecl)
+ Consumer->HandleTopLevelDecl(static_cast<Decl*>(ADecl));
+ };
if (PrintStats) {
fprintf(stderr, "\nSTATISTICS:\n");
- Streamer.PrintStats();
+ P.getActions().PrintStats();
Context.PrintStats();
Decl::PrintStats();
Stmt::PrintStats();