diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-08-31 21:49:40 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-08-31 21:49:40 +0000 |
commit | 805e9a8300af9489ec13cd804c070267b7c4cfec (patch) | |
tree | e3c6bd78cd27e57d6e1de0fce4f0ccc686131dc4 | |
parent | 9e2b75ca9c3fdd03453ffe6b8f41686d3030a92a (diff) |
Cleanups for printing the terminators of CFGBlocks for "?", "||", and "&&" operators.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41654 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | AST/CFG.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/AST/CFG.cpp b/AST/CFG.cpp index 512c69ec5b..83d91ddeb6 100644 --- a/AST/CFG.cpp +++ b/AST/CFG.cpp @@ -960,7 +960,8 @@ public: }; class CFGBlockTerminatorPrint : public StmtVisitor<CFGBlockTerminatorPrint, -void > { + 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'; |