Added PrintRawDeclStmt; use this method to print out DeclStmt instead of using PrintRawDecl (which falsely assumes DeclStmts have only one Decl).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57191 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index e95b8c8..844a3e8 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -50,6 +50,7 @@
     
     void PrintRawCompoundStmt(CompoundStmt *S);
     void PrintRawDecl(Decl *D);
+    void PrintRawDeclStmt(DeclStmt *S);
     void PrintRawIfStmt(IfStmt *If);
     
     void PrintExpr(Expr *E) {
@@ -144,15 +145,28 @@
   }
 }
 
+void StmtPrinter::PrintRawDeclStmt(DeclStmt *S) {
+  bool isFirst = false;
+  
+  for (DeclStmt::decl_iterator I = S->decl_begin(), E = S->decl_end();
+       I != E; ++I) {
+    
+    if (!isFirst) OS << ", ";
+    else isFirst = false;
+    
+    PrintRawDecl(*I);
+  }
+}
 
 void StmtPrinter::VisitNullStmt(NullStmt *Node) {
   Indent() << ";\n";
 }
 
 void StmtPrinter::VisitDeclStmt(DeclStmt *Node) {
-  for (ScopedDecl *D = Node->getDecl(); D; D = D->getNextDeclarator()) {
+  for (DeclStmt::decl_iterator I = Node->decl_begin(), E = Node->decl_end();
+       I!=E; ++I) {    
     Indent();
-    PrintRawDecl(D);
+    PrintRawDecl(*I);
     OS << ";\n";
   }
 }
@@ -268,7 +282,7 @@
   Indent() << "for (";
   if (Node->getInit()) {
     if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getInit()))
-      PrintRawDecl(DS->getDecl());
+      PrintRawDeclStmt(DS);
     else
       PrintExpr(cast<Expr>(Node->getInit()));
   }
@@ -296,7 +310,7 @@
 void StmtPrinter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *Node) {
   Indent() << "for (";
   if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getElement()))
-    PrintRawDecl(DS->getDecl());
+    PrintRawDeclStmt(DS);
   else
     PrintExpr(cast<Expr>(Node->getElement()));
   OS << " in ";
@@ -418,7 +432,7 @@
     Indent() << "@catch(";
     if (catchStmt->getCatchParamStmt()) {
       if (DeclStmt *DS = dyn_cast<DeclStmt>(catchStmt->getCatchParamStmt()))
-        PrintRawDecl(DS->getDecl());
+        PrintRawDeclStmt(DS);
     }
     OS << ")";
     if (CompoundStmt *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody()))