From: Ted Kremenek Date: Fri, 16 May 2008 16:06:00 +0000 (+0000) Subject: Added CFGBlock::hasBinaryBranchTerminator(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c2535a35db35b3a821a0d0c36a01a16f52f1ad0;p=clang Added CFGBlock::hasBinaryBranchTerminator(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51190 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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(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