Skip to content

Commit

Permalink
Update detector to check compile-time known constants
Browse files Browse the repository at this point in the history
  • Loading branch information
jgcrosta committed Jul 28, 2024
1 parent 50c9011 commit b8090a1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions detectors/integer-overflow-or-underflow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ pub struct IntegerOverflowUnderflowVisitor<'a, 'tcx> {

impl<'tcx> IntegerOverflowUnderflowVisitor<'_, 'tcx> {
pub fn check_pow(&mut self, expr: &Expr<'tcx>, base: &Expr<'tcx>, exponent: &Expr<'tcx>) {
let is_base_known = self.constant_detector.is_compile_time_known(base);
let is_exponent_known = self.constant_detector.is_compile_time_known(exponent);
let is_base_known = self.constant_detector.is_constant(base);
let is_exponent_known = self.constant_detector.is_constant(exponent);
if is_base_known && is_exponent_known {
return;
}
Expand All @@ -107,7 +107,7 @@ impl<'tcx> IntegerOverflowUnderflowVisitor<'_, 'tcx> {
}

pub fn check_negate(&mut self, expr: &Expr<'tcx>, operand: &Expr<'tcx>) {
let is_operand_known = self.constant_detector.is_compile_time_known(operand);
let is_operand_known = self.constant_detector.is_constant(operand);
if is_operand_known {
return;
}
Expand All @@ -128,8 +128,8 @@ impl<'tcx> IntegerOverflowUnderflowVisitor<'_, 'tcx> {
left: &Expr<'tcx>,
right: &Expr<'tcx>,
) {
let is_left_known = self.constant_detector.is_compile_time_known(left);
let is_right_known = self.constant_detector.is_compile_time_known(right);
let is_left_known = self.constant_detector.is_constant(left);
let is_right_known = self.constant_detector.is_constant(right);
if is_left_known && is_right_known {
return;
}
Expand Down

0 comments on commit b8090a1

Please sign in to comment.