From 7f7dd7602ca2bc070af989a7a7c9cc5da2c9064d Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 31 Aug 2007 21:49:40 +0000 Subject: [PATCH] Cleanups for printing the terminators of CFGBlocks for "?", "||", and "&&" operators. llvm-svn: 41654 --- clang/AST/CFG.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/clang/AST/CFG.cpp b/clang/AST/CFG.cpp index 512c69ec5b80..83d91ddeb6d3 100644 --- a/clang/AST/CFG.cpp +++ b/clang/AST/CFG.cpp @@ -960,7 +960,8 @@ public: }; class CFGBlockTerminatorPrint : public StmtVisitor { + void > +{ std::ostream& OS; StmtPrinterHelper* Helper; public: @@ -974,7 +975,7 @@ public: } // Default case. - void VisitStmt(Stmt* S) { S->printPretty(OS,Helper); } + void VisitStmt(Stmt* S) { S->printPretty(OS); } void VisitForStmt(ForStmt* F) { OS << "for (" ; @@ -1004,6 +1005,31 @@ public: OS << '\n'; } + void VisitConditionalOperator(ConditionalOperator* C) { + C->getCond()->printPretty(OS,Helper); + OS << " ? ... : ...\n"; + } + + void VisitBinaryOperator(BinaryOperator* B) { + if (!B->isLogicalOp()) { + VisitExpr(B); + return; + } + + B->getLHS()->printPretty(OS,Helper); + + switch (B->getOpcode()) { + case BinaryOperator::LOr: + OS << " || ...\n"; + return; + case BinaryOperator::LAnd: + OS << " && ...\n"; + return; + default: + assert(false && "Invalid logical operator."); + } + } + void VisitExpr(Expr* E) { E->printPretty(OS,Helper); OS << '\n';