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
1214private import semmle.code.java.Reflection
1315
1416/** Gets an expression that is the remainder modulo 2 of `arg`. */
17+ deprecated
1518private 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
2630private 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
4146class 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
5157private 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
6875private 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
95103private 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
104113private 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
118128private 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
131142private 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
147159private 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
210223Parity 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
218234predicate parityComparison ( ComparisonExpr comp , boolean eqparity ) {
219235 exists ( Expr left , Expr right , boolean lpar , boolean rpar |
220236 comp .getLeftOperand ( ) = left and
0 commit comments