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
diff --git a/Parse/Parser.cpp b/Parse/Parser.cpp
index 6e03328..8a0d8c7 100644
--- a/Parse/Parser.cpp
+++ b/Parse/Parser.cpp
@@ -259,10 +259,11 @@
 
 /// ParseTopLevelDecl - Parse one top-level declaration, return whatever the
 /// action tells us to.  This returns true if the EOF was encountered.
-bool Parser::ParseTopLevelDecl() {
+bool Parser::ParseTopLevelDecl(DeclTy*& Result) {
+  Result = 0;
   if (Tok.is(tok::eof)) return true;
   
-  ParseExternalDeclaration();
+  Result = ParseExternalDeclaration();
   return false;
 }
 
@@ -280,7 +281,8 @@
 void Parser::ParseTranslationUnit() {
   Initialize();
   
-  while (!ParseTopLevelDecl())
+  DeclTy *Res;
+  while (!ParseTopLevelDecl(Res))
     /*parse them all*/;
   
   Finalize();