diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-05-16 16:06:00 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-05-16 16:06:00 +0000 |
commit | 9c2535a35db35b3a821a0d0c36a01a16f52f1ad0 (patch) | |
tree | e8487ad8618165715df91008d3e0935cb921a6f5 | |
parent | 861dc46e3c53d64d8685fd9a0f95faac710b61c6 (diff) |
Added CFGBlock::hasBinaryBranchTerminator().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51190 91177308-0d34-0410-b5e6-96231b3b80d8
-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 |