Add a new ChooseExpr::isConditionTrue method to unify
some code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43322 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/Expr.cpp b/AST/Expr.cpp
index d6960d3..0c631df 100644
--- a/AST/Expr.cpp
+++ b/AST/Expr.cpp
@@ -894,6 +894,14 @@
RBracloc = RBrac;
}
+
+bool ChooseExpr::isConditionTrue(ASTContext &C) const {
+ llvm::APSInt CondVal(32);
+ bool IsConst = getCond()->isIntegerConstantExpr(CondVal, C);
+ assert(IsConst && "Condition of choose expr must be i-c-e"); IsConst=IsConst;
+ return CondVal != 0;
+}
+
//===----------------------------------------------------------------------===//
// Child Iterators for iterating over subexpressions/substatements
//===----------------------------------------------------------------------===//