[cfe-commits] r39538 - /cfe/cfe/trunk/AST/StmtPrinter.cpp
clattner at cs.uiuc.edu
clattner at cs.uiuc.edu
Wed Jul 11 09:45:23 PDT 2007
Author: clattner
Date: Wed Jul 11 11:45:23 2007
New Revision: 39538
URL: http://llvm.org/viewvc/llvm-project?rev=39538&view=rev
Log:
more minor improvements to pretty printer.
Modified:
cfe/cfe/trunk/AST/StmtPrinter.cpp
Modified: cfe/cfe/trunk/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/StmtPrinter.cpp?rev=39538&r1=39537&r2=39538&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/StmtPrinter.cpp (original)
+++ cfe/cfe/trunk/AST/StmtPrinter.cpp Wed Jul 11 11:45:23 2007
@@ -20,24 +20,6 @@
using namespace llvm;
using namespace clang;
-namespace {
- struct VISIBILITY_HIDDEN IsExprStmtVisitor : public StmtVisitor {
- bool &Result;
- IsExprStmtVisitor(bool &R) : Result(R) { Result = false; }
-
- virtual void VisitExpr(Expr *Node) {
- Result = true;
- }
- };
-}
-
-static bool isExpr(Stmt *S) {
- bool Val = false;
- IsExprStmtVisitor V(Val);
- S->visit(V);
- return Val;
-}
-
//===----------------------------------------------------------------------===//
// StmtPrinter Visitor
//===----------------------------------------------------------------------===//
@@ -51,7 +33,7 @@
void PrintStmt(Stmt *S, int SubIndent = 1) {
IndentLevel += SubIndent;
- if (S && isExpr(S)) {
+ if (S && isa<Expr>(S)) {
// If this is an expr used in a stmt context, indent and newline it.
Indent();
S->visit(*this);
@@ -151,9 +133,8 @@
}
void StmtPrinter::VisitIfStmt(IfStmt *If) {
- Indent() << "if (";
+ Indent() << "if ";
PrintExpr(If->getCond());
- OS << ')';
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(If->getThen())) {
OS << ' ';
@@ -205,9 +186,9 @@
void StmtPrinter::VisitDoStmt(DoStmt *Node) {
Indent() << "do\n";
PrintStmt(Node->getBody());
- Indent() << "while (";
+ Indent() << "while ";
PrintExpr(Node->getCond());
- OS << ");\n";
+ OS << ";\n";
}
void StmtPrinter::VisitForStmt(ForStmt *Node) {
@@ -310,7 +291,7 @@
void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
OS << "(";
PrintExpr(Node->getSubExpr());
- OS << ")'";
+ OS << ")";
}
void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
if (!Node->isPostfix())
More information about the cfe-commits
mailing list