diff --git a/clang/AST/StmtPrinter.cpp b/clang/AST/StmtPrinter.cpp index 8d922160b15de3d4aaa538e24490bdd43bc62645..bdf8378caf8888f1332dab449565cc1a89e8c475 100644 --- a/clang/AST/StmtPrinter.cpp +++ b/clang/AST/StmtPrinter.cpp @@ -48,7 +48,8 @@ namespace { void PrintRawCompoundStmt(CompoundStmt *S); void PrintRawDecl(Decl *D); - + void PrintRawIfStmt(IfStmt *If); + void PrintExpr(Expr *E) { if (E) E->visit(*this); @@ -159,8 +160,8 @@ void StmtPrinter::VisitLabelStmt(LabelStmt *Node) { PrintStmt(Node->getSubStmt(), 0); } -void StmtPrinter::VisitIfStmt(IfStmt *If) { - Indent() << "if "; +void StmtPrinter::PrintRawIfStmt(IfStmt *If) { + OS << "if "; PrintExpr(If->getCond()); if (CompoundStmt *CS = dyn_cast(If->getThen())) { @@ -172,7 +173,7 @@ void StmtPrinter::VisitIfStmt(IfStmt *If) { PrintStmt(If->getThen()); if (If->getElse()) Indent(); } - + if (Stmt *Else = If->getElse()) { OS << "else"; @@ -180,6 +181,9 @@ void StmtPrinter::VisitIfStmt(IfStmt *If) { OS << ' '; PrintRawCompoundStmt(CS); OS << '\n'; + } else if (IfStmt *ElseIf = dyn_cast(Else)) { + OS << ' '; + PrintRawIfStmt(ElseIf); } else { OS << '\n'; PrintStmt(If->getElse()); @@ -187,6 +191,11 @@ void StmtPrinter::VisitIfStmt(IfStmt *If) { } } +void StmtPrinter::VisitIfStmt(IfStmt *If) { + Indent(); + PrintRawIfStmt(If); +} + void StmtPrinter::VisitSwitchStmt(SwitchStmt *Node) { Indent() << "switch ("; PrintExpr(Node->getCond());