summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-02-25 18:42:54 +0000
committerTed Kremenek <kremenek@apple.com>2008-02-25 18:42:54 +0000
commit3866746569e46c5694074f88ad419bb34b8ca92b (patch)
tree6fe15bcf7f4684e438b8f40a661a3eac03956912
parentb23cc7191f6afb26c987e75220740e02e68b880d (diff)
downloadbcm5719-llvm-3866746569e46c5694074f88ad419bb34b8ca92b.tar.gz
bcm5719-llvm-3866746569e46c5694074f88ad419bb34b8ca92b.zip
Expanded transfer function support for divide-by-zero checking to include
"remainder-by-zero" checking (operator '%'). llvm-svn: 47549
-rw-r--r--clang/Analysis/GRExprEngine.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/Analysis/GRExprEngine.cpp b/clang/Analysis/GRExprEngine.cpp
index 74fadcc9e36..dedeb7b1b70 100644
--- a/clang/Analysis/GRExprEngine.cpp
+++ b/clang/Analysis/GRExprEngine.cpp
@@ -846,11 +846,15 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
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 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
// 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.
OpenPOWER on IntegriCloud