[cfe-commits] r41989 - /cfe/trunk/AST/StmtPrinter.cpp
Chris Lattner
sabre at nondot.org
Sat Sep 15 14:49:37 PDT 2007
Author: lattner
Date: Sat Sep 15 16:49:37 2007
New Revision: 41989
URL: http://llvm.org/viewvc/llvm-project?rev=41989&view=rev
Log:
pretty print some nodes more nicely.
Modified:
cfe/trunk/AST/StmtPrinter.cpp
Modified: cfe/trunk/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtPrinter.cpp?rev=41989&r1=41988&r2=41989&view=diff
==============================================================================
--- cfe/trunk/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/AST/StmtPrinter.cpp Sat Sep 15 16:49:37 2007
@@ -243,9 +243,17 @@
}
void StmtPrinter::VisitDoStmt(DoStmt *Node) {
- Indent() << "do\n";
- PrintStmt(Node->getBody());
- Indent() << "while ";
+ Indent() << "do ";
+ if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
+ PrintRawCompoundStmt(CS);
+ OS << " ";
+ } else {
+ OS << "\n";
+ PrintStmt(Node->getBody());
+ Indent();
+ }
+
+ OS << "while ";
PrintExpr(Node->getCond());
OS << ";\n";
}
@@ -258,14 +266,25 @@
else
PrintExpr(cast<Expr>(Node->getInit()));
}
- OS << "; ";
- if (Node->getCond())
+ OS << ";";
+ if (Node->getCond()) {
+ OS << " ";
PrintExpr(Node->getCond());
- OS << "; ";
- if (Node->getInc())
+ }
+ OS << ";";
+ if (Node->getInc()) {
+ OS << " ";
PrintExpr(Node->getInc());
- OS << ")\n";
- PrintStmt(Node->getBody());
+ }
+ OS << ") ";
+
+ if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
+ PrintRawCompoundStmt(CS);
+ OS << "\n";
+ } else {
+ OS << "\n";
+ PrintStmt(Node->getBody());
+ }
}
void StmtPrinter::VisitGotoStmt(GotoStmt *Node) {
More information about the cfe-commits
mailing list