]> granicus.if.org Git - clang/commitdiff
Cleanups for printing the terminators of CFGBlocks for "?", "||", and "&&" operators.
authorTed Kremenek <kremenek@apple.com>
Fri, 31 Aug 2007 21:49:40 +0000 (21:49 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 31 Aug 2007 21:49:40 +0000 (21:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41654 91177308-0d34-0410-b5e6-96231b3b80d8

AST/CFG.cpp

index 512c69ec5b80221e6bbfe05b866b4e43ecf08dd0..83d91ddeb6d3a5c5b9e1ed38ba10411ceefeedae 100644 (file)
@@ -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';