From 3c8d0c58dba7968810ebe5e1137e2f268a4e5d14 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 25 Feb 2008 18:42:54 +0000 Subject: [PATCH] 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 --- Analysis/GRExprEngine.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp index 74fadcc9e3..dedeb7b1b7 100644 --- a/Analysis/GRExprEngine.cpp +++ b/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. -- 2.50.1