Skip to content

Commit ca8ca55

Browse files
committed
Java: Deprecate ParityAnalysis.
1 parent 5c53249 commit ca8ca55

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

java/ql/src/filters/ImportAdditionalLibraries.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java
1111

1212
import semmle.code.java.dataflow.Guards
13+
import semmle.code.java.dataflow.ParityAnalysis
1314
import semmle.code.java.security.DataFlow
1415

1516
from File f, string tag

java/ql/src/semmle/code/java/dataflow/ParityAnalysis.qll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/**
2+
* DEPRECATED: semmle.code.java.dataflow.ModulusAnalysis instead.
3+
*
24
* Parity Analysis.
35
*
46
* The analysis is implemented as an abstract interpretation over the
@@ -12,6 +14,7 @@ private import SignAnalysis
1214
private import semmle.code.java.Reflection
1315

1416
/** Gets an expression that is the remainder modulo 2 of `arg`. */
17+
deprecated
1518
private Expr mod2(Expr arg) {
1619
exists(RemExpr rem |
1720
result = rem and
@@ -23,6 +26,7 @@ private Expr mod2(Expr arg) {
2326
}
2427

2528
/** An expression that calculates remainder modulo 2. */
29+
deprecated
2630
private class Mod2 extends Expr {
2731
Mod2() {
2832
this = mod2(_)
@@ -38,6 +42,7 @@ private class Mod2 extends Expr {
3842
* Parity represented as booleans. Even corresponds to `false` and odd
3943
* corresponds to `true`.
4044
*/
45+
deprecated
4146
class Parity extends boolean {
4247
Parity() { this = true or this = false }
4348
predicate isEven() { this = false }
@@ -48,6 +53,7 @@ class Parity extends boolean {
4853
* Gets a condition that performs a parity check on `v`, such that `v` has
4954
* the given parity if the condition evaluates to `testIsTrue`.
5055
*/
56+
deprecated
5157
private Guard parityCheck(SsaVariable v, Parity parity, boolean testIsTrue) {
5258
exists(Mod2 rem, CompileTimeConstantExpr c, int r, boolean polarity |
5359
result.isEquality(rem, c, polarity) and
@@ -65,6 +71,7 @@ private Guard parityCheck(SsaVariable v, Parity parity, boolean testIsTrue) {
6571
/**
6672
* Gets the parity of `e` if it can be directly determined.
6773
*/
74+
deprecated
6875
private Parity certainExprParity(Expr e) {
6976
exists(int i | e.(ConstantIntegerExpr).getIntValue() = i |
7077
if i % 2 = 0 then result.isEven() else result.isOdd()
@@ -92,6 +99,7 @@ private Parity certainExprParity(Expr e) {
9299
/**
93100
* Gets the expression that defines the array length that equals `len`, if any.
94101
*/
102+
deprecated
95103
private Expr arrLenDef(FieldAccess len) {
96104
exists(SsaVariable arr |
97105
len.getField() instanceof ArrayLengthField and
@@ -101,6 +109,7 @@ private Expr arrLenDef(FieldAccess len) {
101109
}
102110

103111
/** Gets a possible parity for `v`. */
112+
deprecated
104113
private Parity ssaParity(SsaVariable v) {
105114
exists(VariableUpdate def | def = v.(SsaExplicitUpdate).getDefiningExpr() |
106115
result = exprParity(def.(VariableAssign).getSource()) or
@@ -115,6 +124,7 @@ private Parity ssaParity(SsaVariable v) {
115124
}
116125

117126
/** Gets a possible parity for `f`. */
127+
deprecated
118128
private Parity fieldParity(Field f) {
119129
result = exprParity(f.getAnAssignedValue()) or
120130
exists(UnaryAssignExpr u | u.getExpr() = f.getAnAccess() and (result = true or result = false)) or
@@ -128,6 +138,7 @@ private Parity fieldParity(Field f) {
128138
}
129139

130140
/** Holds if the parity of `e` is too complicated to determine. */
141+
deprecated
131142
private predicate unknownParity(Expr e) {
132143
e instanceof AssignDivExpr or
133144
e instanceof AssignRShiftExpr or
@@ -144,6 +155,7 @@ private predicate unknownParity(Expr e) {
144155
}
145156

146157
/** Gets a possible parity for `e`. */
158+
deprecated
147159
private Parity exprParity(Expr e) {
148160
result = certainExprParity(e) or
149161
not exists(certainExprParity(e)) and
@@ -207,14 +219,18 @@ private Parity exprParity(Expr e) {
207219
/**
208220
* Gets the parity of `e` if it can be uniquely determined.
209221
*/
222+
deprecated
210223
Parity getExprParity(Expr e) {
211224
result = exprParity(e) and 1 = count(exprParity(e))
212225
}
213226

214227
/**
228+
* DEPRECATED: semmle.code.java.dataflow.ModulusAnalysis instead.
229+
*
215230
* Holds if the parity can be determined for both sides of `comp`. The boolean
216231
* `eqparity` indicates whether the two sides have equal or opposite parity.
217232
*/
233+
deprecated
218234
predicate parityComparison(ComparisonExpr comp, boolean eqparity) {
219235
exists(Expr left, Expr right, boolean lpar, boolean rpar |
220236
comp.getLeftOperand() = left and

0 commit comments

Comments
 (0)