@@ -7,20 +7,6 @@ private import cpp
7
7
private import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
8
8
private import semmle.code.cpp.rangeanalysis.RangeAnalysisUtils
9
9
10
- /**
11
- * An operand `e` of a division expression (i.e., `e` is an operand of either a `DivExpr` or
12
- * a `AssignDivExpr`) is bounded when `e` is the left-hand side of the division.
13
- */
14
- pragma [ inline]
15
- private predicate boundedDiv ( Expr e , Expr left ) { e = left }
16
-
17
- /**
18
- * An operand `e` of a remainder expression (i.e., `e` is an operand of either a `RemExpr` or
19
- * a `AssignRemExpr`) is bounded when `e` is the left-hand side of the remainder.
20
- */
21
- pragma [ inline]
22
- private predicate boundedRem ( Expr e , Expr left ) { e = left }
23
-
24
10
/**
25
11
* An operand `e` of a bitwise and expression `andExpr` (i.e., `andExpr` is either an `BitwiseAndExpr`
26
12
* or an `AssignAndExpr`) with operands `operand1` and `operand2` is the operand that is not `e` is upper
@@ -45,9 +31,10 @@ predicate bounded(Expr e) {
45
31
) and
46
32
not convertedExprMightOverflow ( e )
47
33
or
48
- boundedRem ( e , any ( RemExpr rem ) .getLeftOperand ( ) )
34
+ // Optimitically assume that a remainder expression always yields a much smaller value.
35
+ e = any ( RemExpr rem ) .getLeftOperand ( )
49
36
or
50
- boundedRem ( e , any ( AssignRemExpr rem ) .getLValue ( ) )
37
+ e = any ( AssignRemExpr rem ) .getLValue ( )
51
38
or
52
39
exists ( BitwiseAndExpr andExpr |
53
40
boundedBitwiseAnd ( e , andExpr , andExpr .getAnOperand ( ) , andExpr .getAnOperand ( ) )
@@ -58,11 +45,11 @@ predicate bounded(Expr e) {
58
45
)
59
46
or
60
47
// Optimitically assume that a division always yields a much smaller value.
61
- boundedDiv ( e , any ( DivExpr div ) .getLeftOperand ( ) )
48
+ e = any ( DivExpr div ) .getLeftOperand ( )
62
49
or
63
- boundedDiv ( e , any ( AssignDivExpr div ) .getLValue ( ) )
50
+ e = any ( AssignDivExpr div ) .getLValue ( )
64
51
or
65
- boundedDiv ( e , any ( RShiftExpr shift ) .getLeftOperand ( ) )
52
+ e = any ( RShiftExpr shift ) .getLeftOperand ( )
66
53
or
67
- boundedDiv ( e , any ( AssignRShiftExpr div ) .getLValue ( ) )
54
+ e = any ( AssignRShiftExpr div ) .getLValue ( )
68
55
}
0 commit comments