diff options
author | Steve Naroff <snaroff@apple.com> | 2007-11-29 23:05:20 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2007-11-29 23:05:20 +0000 |
commit | 89307ffaf8acf4d6fdffd72b607ca4fbcfdffc9d (patch) | |
tree | bbf0f3ba5d789a183976c58fc486375e4d480bba /Sema/ASTStreamer.cpp | |
parent | 2ff3e691ecc63a5d82d4023b46b5b47ce14ace53 (diff) |
Yesterday, I simplified how we stream top-level decls.
After a discussion with Ted, we both came to the conclusion that adding a "HandleTopLevelDeclaration" hook to ASConsumer is far more elegant. The default implementation of HandleTopLevelDeclaration will be responsible for iterating over the ScopedDecl (which has a chain of the decls:-).
TODO: Once Ted adds HandleTopLevelDeclaration, make sure TagDecls are chainged appropriately...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44445 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Sema/ASTStreamer.cpp')
-rw-r--r-- | Sema/ASTStreamer.cpp | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/Sema/ASTStreamer.cpp b/Sema/ASTStreamer.cpp index 5a372da088..b51874ca35 100644 --- a/Sema/ASTStreamer.cpp +++ b/Sema/ASTStreamer.cpp @@ -24,10 +24,9 @@ ASTConsumer::~ASTConsumer() {} namespace { class ASTStreamer { Parser P; - std::vector<Decl*> TopLevelDeclList; public: ASTStreamer(Preprocessor &pp, ASTContext &ctxt, unsigned MainFileID) - : P(pp, *new Sema(pp, ctxt, TopLevelDeclList)) { + : P(pp, *new Sema(pp, ctxt)) { pp.EnterMainSourceFile(MainFileID); // Initialize the parser. @@ -51,30 +50,14 @@ namespace { Decl *ASTStreamer::ReadTopLevelDecl() { Parser::DeclTy *Result; - /// If the previous time through we read something like 'int X, Y', return - /// the next declarator. - if (!TopLevelDeclList.empty()) { - Result = TopLevelDeclList.back(); - TopLevelDeclList.pop_back(); - return static_cast<Decl*>(Result); - } - do { - if (P.ParseTopLevelDecl()) + 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 (TopLevelDeclList.size() == 0); - - // If we parsed a declspec with multiple declarators, reverse the list and - // return the first one. - if (TopLevelDeclList.size() > 1) - std::reverse(TopLevelDeclList.begin(), TopLevelDeclList.end()); - - Result = TopLevelDeclList.back(); - TopLevelDeclList.pop_back(); + } while (Result == 0); return static_cast<Decl*>(Result); } |