]> granicus.if.org Git - clang/commitdiff
Added CFGBlock::hasBinaryBranchTerminator().
authorTed Kremenek <kremenek@apple.com>
Fri, 16 May 2008 16:06:00 +0000 (16:06 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 16 May 2008 16:06:00 +0000 (16:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51190 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/CFG.h
lib/AST/CFG.cpp

index 162240ab1f7994dc867622f6596d5104bcb3a297..9f5d9d0e57a9f090fcf3195cbc9ab9579f1770dc 100644 (file)
@@ -158,6 +158,8 @@ public:
     return const_cast<CFGBlock*>(this)->getTerminatorCondition();
   }
   
+  bool hasBinaryBranchTerminator() const;
+  
   Stmt* getLabel() { return Label; }
   const Stmt* getLabel() const { return Label; }
   
index aa5bbe437dafb500ef29ae0667039c38fec59c3f..077f75c38485999ac637956cde59661f873fc2e9 100644 (file)
@@ -1587,6 +1587,30 @@ Expr* CFGBlock::getTerminatorCondition() {
   return E ? E->IgnoreParens() : NULL;
 }
 
+bool CFGBlock::hasBinaryBranchTerminator() const {
+  
+  if (!Terminator)
+    return false;
+  
+  Expr* E = NULL;
+  
+  switch (Terminator->getStmtClass()) {
+    default:
+      return false;
+      
+    case Stmt::ForStmtClass:      
+    case Stmt::WhileStmtClass:
+    case Stmt::DoStmtClass:
+    case Stmt::IfStmtClass:
+    case Stmt::ChooseExprClass:
+    case Stmt::ConditionalOperatorClass:
+    case Stmt::BinaryOperatorClass:
+      return true;      
+  }
+  
+  return E ? E->IgnoreParens() : NULL;
+}
+
 
 //===----------------------------------------------------------------------===//
 // CFG Graphviz Visualization