]> granicus.if.org Git - clang/commitdiff
Expanded transfer function support for divide-by-zero checking to include
authorTed Kremenek <kremenek@apple.com>
Mon, 25 Feb 2008 18:42:54 +0000 (18:42 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 25 Feb 2008 18:42:54 +0000 (18:42 +0000)
"remainder-by-zero" checking (operator '%').

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47549 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/GRExprEngine.cpp

index 74fadcc9e36fbd25295e01db157e943cff0ebcec..dedeb7b1b709a74206a9b5330f31a9515897804e 100644 (file)
@@ -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.