Expanded transfer function support for divide-by-zero checking to include
"remainder-by-zero" checking (operator '%').
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47549 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp
index 74fadcc..dedeb7b 100644
--- a/Analysis/GRExprEngine.cpp
+++ b/Analysis/GRExprEngine.cpp
@@ -846,11 +846,15 @@
NodeTy* N2 = *I2;
StateTy St = N2->getState();
- RVal RightV = GetRVal(St, B->getRHS());
+ Expr* RHS = B->getRHS();
+ RVal RightV = GetRVal(St, RHS);
BinaryOperator::Opcode Op = B->getOpcode();
- if (Op == BinaryOperator::Div) { // Check for divide-by-zero.
+ if ((Op == BinaryOperator::Div || Op == BinaryOperator::Rem)
+ && RHS->getType()->isIntegerType()) {
+
+ // Check for divide/remaindner-by-zero.
// First, "assume" that the denominator is 0.
@@ -992,7 +996,10 @@
// Evaluate operands and promote to result type.
- if (Op == BinaryOperator::Div) { // Check for divide-by-zero.
+ if ((Op == BinaryOperator::Div || Op == BinaryOperator::Rem)
+ && RHS->getType()->isIntegerType()) {
+
+ // Check for divide/remainder-by-zero.
// First, "assume" that the denominator is 0.