Skip to content

Commit a5a31db

Browse files
atorralbaigfoo
authored andcommitted
Rename AnyEqualsExpr and AnyNotEqualsExpr
1 parent 0e3db78 commit a5a31db

File tree

7 files changed

+36
-22
lines changed

7 files changed

+36
-22
lines changed

java/ql/lib/semmle/code/java/Expr.qll

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,12 @@ class CompileTimeConstantExpr extends Expr {
227227
)
228228
or
229229
(
230-
b instanceof AnyEqualsExpr and
230+
b instanceof ValueOrReferenceEqualsExpr and
231231
if left = right then result = true else result = false
232232
)
233233
or
234234
(
235-
b instanceof AnyNotEqualsExpr and
235+
b instanceof ValueOrReferenceNotEqualsExpr and
236236
if left != right then result = true else result = false
237237
)
238238
)
@@ -244,12 +244,12 @@ class CompileTimeConstantExpr extends Expr {
244244
right = b.getRightOperand().(CompileTimeConstantExpr).getBooleanValue()
245245
|
246246
(
247-
b instanceof AnyEqualsExpr and
247+
b instanceof ValueOrReferenceEqualsExpr and
248248
if left = right then result = true else result = false
249249
)
250250
or
251251
(
252-
b instanceof AnyNotEqualsExpr and
252+
b instanceof ValueOrReferenceNotEqualsExpr and
253253
if left != right then result = true else result = false
254254
)
255255
or
@@ -277,12 +277,12 @@ class CompileTimeConstantExpr extends Expr {
277277
*/
278278

279279
(
280-
b instanceof AnyEqualsExpr and
280+
b instanceof ValueOrReferenceEqualsExpr and
281281
if left = right then result = true else result = false
282282
)
283283
or
284284
(
285-
b instanceof AnyNotEqualsExpr and
285+
b instanceof ValueOrReferenceNotEqualsExpr and
286286
if left != right then result = true else result = false
287287
)
288288
)
@@ -366,7 +366,7 @@ class CompileTimeConstantExpr extends Expr {
366366
or
367367
b instanceof XorBitwiseExpr and result = v1.bitXor(v2)
368368
// No `int` value for `AndLogicalExpr` or `OrLogicalExpr`.
369-
// No `int` value for `LTExpr`, `GTExpr`, `LEExpr`, `GEExpr`, `AnyEqualsExpr` or `AnyNotEqualsExpr`.
369+
// No `int` value for `LTExpr`, `GTExpr`, `LEExpr`, `GEExpr`, `ValueOrReferenceEqualsExpr` or `ValueOrReferenceNotEqualsExpr`.
370370
)
371371
or
372372
// Ternary conditional, with compile-time constant condition.
@@ -1006,8 +1006,8 @@ class ValueNEExpr extends BinaryExpr, @valueneexpr {
10061006
* This might test for reference equality or might function like `Objects.equals`. If you
10071007
* need to distinguish them, use `EQExpr` or `ValueEQExpr` instead.
10081008
*/
1009-
class AnyEqualsExpr extends BinaryExpr {
1010-
AnyEqualsExpr() { this instanceof EQExpr or this instanceof ValueEQExpr }
1009+
class ValueOrReferenceEqualsExpr extends BinaryExpr {
1010+
ValueOrReferenceEqualsExpr() { this instanceof EQExpr or this instanceof ValueEQExpr }
10111011
}
10121012

10131013
/**
@@ -1016,8 +1016,8 @@ class AnyEqualsExpr extends BinaryExpr {
10161016
* This might test for reference equality or might function like `Objects.equals`. If you
10171017
* need to distinguish them, use `EQExpr` or `ValueEQExpr` instead.
10181018
*/
1019-
class AnyNotEqualsExpr extends BinaryExpr {
1020-
AnyNotEqualsExpr() { this instanceof NEExpr or this instanceof ValueNEExpr }
1019+
class ValueOrReferenceNotEqualsExpr extends BinaryExpr {
1020+
ValueOrReferenceNotEqualsExpr() { this instanceof NEExpr or this instanceof ValueNEExpr }
10211021
}
10221022

10231023
/**

java/ql/lib/semmle/code/java/controlflow/UnreachableBlocks.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ class ConstantExpr extends Expr {
133133
)
134134
or
135135
(
136-
b instanceof AnyEqualsExpr and
136+
b instanceof ValueOrReferenceEqualsExpr and
137137
if left = right then result = true else result = false
138138
)
139139
or
140140
(
141-
b instanceof AnyNotEqualsExpr and
141+
b instanceof ValueOrReferenceNotEqualsExpr and
142142
if left != right then result = true else result = false
143143
)
144144
)

java/ql/src/Likely Bugs/Arithmetic/BadCheckOdd.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ where
2929
not isDefinitelyPositive(lhs.getLeftOperand()) and
3030
lhs.getRightOperand().(IntegerLiteral).getIntValue() = 2 and
3131
(
32-
t instanceof AnyEqualsExpr and rhs.getIntValue() = 1 and parity = "oddness"
32+
t instanceof ValueOrReferenceEqualsExpr and rhs.getIntValue() = 1 and parity = "oddness"
3333
or
34-
t instanceof AnyNotEqualsExpr and rhs.getIntValue() = 1 and parity = "evenness"
34+
t instanceof ValueOrReferenceNotEqualsExpr and rhs.getIntValue() = 1 and parity = "evenness"
3535
or
3636
t instanceof GTExpr and rhs.getIntValue() = 0 and parity = "oddness"
3737
)

java/ql/src/Likely Bugs/Comparison/CompareIdenticalValues.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ predicate specialCase(EqualityTest comparison, string msg) {
7070
// Name of boxed type corresponding to `fptp`.
7171
(if fptp.getName().toLowerCase() = "float" then boxedName = "Float" else boxedName = "Double") and
7272
// Equality tests are tests for not-`NaN`, inequality tests for `NaN`.
73-
(if comparison instanceof AnyEqualsExpr then neg = "!" else neg = "") and
73+
(if comparison instanceof ValueOrReferenceEqualsExpr then neg = "!" else neg = "") and
7474
msg = "equivalent to " + neg + boxedName + ".isNaN(" + comparison.getLeftOperand() + ")"
7575
)
7676
}

java/ql/src/Likely Bugs/Concurrency/LazyInitStaticField.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import java
1717

1818
/** A comparison (using `==`) with `null`. */
19-
class NullEQExpr extends AnyEqualsExpr {
19+
class NullEQExpr extends ValueOrReferenceEqualsExpr {
2020
NullEQExpr() { exists(NullLiteral l | l.getParent() = this) }
2121
}
2222

java/ql/src/Violations of Best Practice/Boolean Logic/SimplifyBoolExpr.ql

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,25 @@ class BoolCompare extends EqualityTest {
1515

1616
predicate simplify(string pattern, string rewrite) {
1717
exists(boolean b | b = this.getAnOperand().(BooleanLiteral).getBooleanValue() |
18-
this instanceof AnyEqualsExpr and b = true and pattern = "A == true" and rewrite = "A"
18+
this instanceof ValueOrReferenceEqualsExpr and
19+
b = true and
20+
pattern = "A == true" and
21+
rewrite = "A"
1922
or
20-
this instanceof AnyNotEqualsExpr and b = false and pattern = "A != false" and rewrite = "A"
23+
this instanceof ValueOrReferenceNotEqualsExpr and
24+
b = false and
25+
pattern = "A != false" and
26+
rewrite = "A"
2127
or
22-
this instanceof AnyEqualsExpr and b = false and pattern = "A == false" and rewrite = "!A"
28+
this instanceof ValueOrReferenceEqualsExpr and
29+
b = false and
30+
pattern = "A == false" and
31+
rewrite = "!A"
2332
or
24-
this instanceof AnyNotEqualsExpr and b = true and pattern = "A != true" and rewrite = "!A"
33+
this instanceof ValueOrReferenceNotEqualsExpr and
34+
b = true and
35+
pattern = "A != true" and
36+
rewrite = "!A"
2537
)
2638
}
2739
}

java/ql/src/experimental/Security/CWE/CWE-200/SensitiveAndroidFileLeak.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ class AndroidFileLeakConfig extends TaintTracking::Configuration {
4242
OnActivityForResultMethod oafr, ConditionBlock cb, CompileTimeConstantExpr cc,
4343
VarAccess intentVar
4444
|
45-
cb.getCondition().(AnyEqualsExpr).hasOperands(oafr.getParameter(0).getAnAccess(), cc) and
45+
cb.getCondition()
46+
.(ValueOrReferenceEqualsExpr)
47+
.hasOperands(oafr.getParameter(0).getAnAccess(), cc) and
4648
cc.getIntValue() = any(AndroidFileIntentInput fi).getRequestCode() and
4749
intentVar.getType() instanceof TypeIntent and
4850
cb.controls(intentVar.getBasicBlock(), true) and

0 commit comments

Comments
 (0)