Changes through out the parser and actions/ast interface to return top-level
declarations through the asm streamer.  For a testcase like:

int G;
int H, I, *J;
int func() {}

'clang -parse-print-ast' prints:

Read top-level decl: G
Read top-level decl: H
Read top-level decl: I
Read top-level decl: J
Read top-level decl: func

llvm-svn: 38992
diff --git a/clang/Sema/Sema.cpp b/clang/Sema/Sema.cpp
index 6788496..e6b09c8 100644
--- a/clang/Sema/Sema.cpp
+++ b/clang/Sema/Sema.cpp
@@ -31,16 +31,25 @@
   /// FullLocInfo - If this is true, the ASTBuilder constructs AST Nodes that
   /// capture maximal location information for each source-language construct.
   bool FullLocInfo;
+  
+  /// LastInGroupList - This vector is populated when there are multiple
+  /// declarators in a single decl group (e.g. "int A, B, C").  In this case,
+  /// all but the last decl will be entered into this.  This is used by the
+  /// ASTStreamer.
+  std::vector<Decl*> &LastInGroupList;
 public:
-  ASTBuilder(Preprocessor &pp, bool fullLocInfo)
-    : PP(pp), FullLocInfo(fullLocInfo) {}
+  ASTBuilder(Preprocessor &pp, bool fullLocInfo,
+             std::vector<Decl*> &prevInGroup)
+    : PP(pp), FullLocInfo(fullLocInfo), LastInGroupList(prevInGroup) {}
   
   //===--------------------------------------------------------------------===//
   // Symbol table tracking callbacks.
   //
   virtual bool isTypedefName(const IdentifierInfo &II, Scope *S) const;
-  virtual void ParseDeclarator(SourceLocation Loc, Scope *S, Declarator &D,
-                               ExprTy *Init);
+  virtual DeclTy *ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init,
+                                  DeclTy *LastInGroup);
+  virtual DeclTy *ParseFunctionDefinition(Scope *S, Declarator &D,
+                                          StmtTy *Body);
   virtual void PopScope(SourceLocation Loc, Scope *S);
   
   //===--------------------------------------------------------------------===//
@@ -103,16 +112,17 @@
   return D != 0 && D->getDeclSpec().StorageClassSpec == DeclSpec::SCS_typedef;
 }
 
-void ASTBuilder::ParseDeclarator(SourceLocation Loc, Scope *S, Declarator &D,
-                                 ExprTy *Init) {
+Action::DeclTy *
+ASTBuilder::ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init, 
+                            DeclTy *LastInGroup) {
   IdentifierInfo *II = D.getIdentifier();
   Decl *PrevDecl = II ? II->getFETokenInfo<Decl>() : 0;
 
   Decl *New;
   if (D.isFunctionDeclarator())
-    New = new FunctionDecl(II, D, Loc, PrevDecl);
+    New = new FunctionDecl(II, D, PrevDecl);
   else
-    New = new VarDecl(II, D, Loc, PrevDecl);
+    New = new VarDecl(II, D, PrevDecl);
   
   // If this has an identifier, add it to the scope stack.
   if (II) {
@@ -120,6 +130,17 @@
     II->setFETokenInfo(New);
     S->AddDecl(II);
   }
+  
+  if (LastInGroup) LastInGroupList.push_back((Decl*)LastInGroup);
+  
+  return New;
+}
+
+Action::DeclTy *
+ASTBuilder::ParseFunctionDefinition(Scope *S, Declarator &D, StmtTy *Body) {
+  FunctionDecl *FD = (FunctionDecl *)ParseDeclarator(S, D, 0, 0);
+  // TODO: more stuff.
+  return FD;
 }
 
 void ASTBuilder::PopScope(SourceLocation Loc, Scope *S) {
@@ -359,9 +380,8 @@
 
 /// Interface to the Builder.cpp file.
 ///
-Action *CreateASTBuilderActions(Preprocessor &PP, bool FullLocInfo) {
-  return new ASTBuilder(PP, FullLocInfo);
+Action *CreateASTBuilderActions(Preprocessor &PP, bool FullLocInfo,
+                                std::vector<Decl*> &LastInGroupList) {
+  return new ASTBuilder(PP, FullLocInfo, LastInGroupList);
 }
 
-
-