[cfe-commits] r57191 - /cfe/trunk/lib/AST/StmtPrinter.cpp

Ted Kremenek kremenek at apple.com
Mon Oct 6 11:39:36 PDT 2008


Author: kremenek
Date: Mon Oct  6 13:39:36 2008
New Revision: 57191

URL: http://llvm.org/viewvc/llvm-project?rev=57191&view=rev
Log:
Added PrintRawDeclStmt; use this method to print out DeclStmt instead of using PrintRawDecl (which falsely assumes DeclStmts have only one Decl).

Modified:
    cfe/trunk/lib/AST/StmtPrinter.cpp

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=57191&r1=57190&r2=57191&view=diff

==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Mon Oct  6 13:39:36 2008
@@ -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())) 





More information about the cfe-commits mailing list