diff options
-rw-r--r-- | include/clang/AST/CFG.h | 2 | ||||
-rw-r--r-- | lib/AST/CFG.cpp | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/include/clang/AST/CFG.h b/include/clang/AST/CFG.h index 162240ab1f..9f5d9d0e57 100644 --- a/include/clang/AST/CFG.h +++ b/include/clang/AST/CFG.h @@ -158,6 +158,8 @@ public: return const_cast<CFGBlock*>(this)->getTerminatorCondition(); } + bool hasBinaryBranchTerminator() const; + Stmt* getLabel() { return Label; } const Stmt* getLabel() const { return Label; } diff --git a/lib/AST/CFG.cpp b/lib/AST/CFG.cpp index aa5bbe437d..077f75c384 100644 --- a/lib/AST/CFG.cpp +++ b/lib/AST/CFG.cpp @@ -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 |