[cfe-commits] r47549 - /cfe/trunk/Analysis/GRExprEngine.cpp

Ted Kremenek kremenek at apple.com
Mon Feb 25 10:42:54 PST 2008


Author: kremenek
Date: Mon Feb 25 12:42:54 2008
New Revision: 47549

URL: http://llvm.org/viewvc/llvm-project?rev=47549&view=rev
Log:
Expanded transfer function support for divide-by-zero checking to include
"remainder-by-zero" checking (operator '%').

Modified:
    cfe/trunk/Analysis/GRExprEngine.cpp

Modified: cfe/trunk/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRExprEngine.cpp?rev=47549&r1=47548&r2=47549&view=diff

==============================================================================
--- cfe/trunk/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/Analysis/GRExprEngine.cpp Mon Feb 25 12:42:54 2008
@@ -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.
             





More information about the cfe-commits mailing list