Skip to content

Commit a175b3b

Browse files
committed
Java: Replace getAUse with getARead.
1 parent 4159ec6 commit a175b3b

File tree

20 files changed

+71
-67
lines changed

20 files changed

+71
-67
lines changed

java/ql/lib/semmle/code/java/dataflow/NullGuards.qll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ Expr enumConstEquality(Expr e, boolean polarity, EnumConstant c) {
2626
}
2727

2828
/** Gets an instanceof expression of `v` with type `type` */
29-
InstanceOfExpr instanceofExpr(SsaVariable v, RefType type) {
29+
InstanceOfExpr instanceofExpr(SsaDefinition v, RefType type) {
3030
result.getCheckedType() = type and
31-
result.getExpr() = v.getAUse()
31+
result.getExpr() = v.getARead()
3232
}
3333

3434
/**
@@ -37,8 +37,8 @@ InstanceOfExpr instanceofExpr(SsaVariable v, RefType type) {
3737
*
3838
* Note this includes Kotlin's `==` and `!=` operators, which are value-equality tests.
3939
*/
40-
EqualityTest varEqualityTestExpr(SsaVariable v1, SsaVariable v2, boolean isEqualExpr) {
41-
result.hasOperands(v1.getAUse(), v2.getAUse()) and
40+
EqualityTest varEqualityTestExpr(SsaDefinition v1, SsaDefinition v2, boolean isEqualExpr) {
41+
result.hasOperands(v1.getARead(), v2.getARead()) and
4242
isEqualExpr = result.polarity()
4343
}
4444

@@ -91,18 +91,18 @@ Expr clearlyNotNullExpr(Expr reason) {
9191
(reason = r1 or reason = r2)
9292
)
9393
or
94-
exists(SsaVariable v, boolean branch, VarRead rval, Guard guard |
94+
exists(SsaDefinition v, boolean branch, VarRead rval, Guard guard |
9595
guard = directNullGuard(v, branch, false) and
9696
guard.controls(rval.getBasicBlock(), branch) and
9797
reason = guard and
98-
rval = v.getAUse() and
98+
rval = v.getARead() and
9999
result = rval and
100100
not result = baseNotNullExpr()
101101
)
102102
or
103-
exists(SsaVariable v |
103+
exists(SsaDefinition v |
104104
clearlyNotNull(v, reason) and
105-
result = v.getAUse() and
105+
result = v.getARead() and
106106
not result = baseNotNullExpr()
107107
)
108108
}

java/ql/lib/semmle/code/java/dataflow/Nullness.qll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ private Expr nonEmptyExpr() {
179179
// An array creation with a known positive size is trivially non-empty.
180180
result.(ArrayCreationExpr).getFirstDimensionSize() > 0
181181
or
182-
exists(SsaVariable v |
182+
exists(SsaDefinition v |
183183
// A use of an array variable is non-empty if...
184-
result = v.getAUse() and
184+
result = v.getARead() and
185185
v.getSourceVariable().getType() instanceof Array
186186
|
187187
// ...its definition is non-empty...
@@ -192,13 +192,13 @@ private Expr nonEmptyExpr() {
192192
cond.controls(result.getBasicBlock(), branch) and
193193
cond.getCondition() = nonZeroGuard(length, branch) and
194194
length.getField().hasName("length") and
195-
length.getQualifier() = v.getAUse()
195+
length.getQualifier() = v.getARead()
196196
)
197197
)
198198
or
199-
exists(SsaVariable v |
199+
exists(SsaDefinition v |
200200
// A use of a Collection variable is non-empty if...
201-
result = v.getAUse() and
201+
result = v.getARead() and
202202
v.getSourceVariable().getType() instanceof CollectionType and
203203
exists(ConditionBlock cond, boolean branch, Expr c |
204204
// ...it is guarded by a condition...
@@ -216,13 +216,13 @@ private Expr nonEmptyExpr() {
216216
// ...and the condition proves that it is non-empty, either by using the `isEmpty` method...
217217
c.(MethodCall).getMethod().hasName("isEmpty") and
218218
branch = false and
219-
c.(MethodCall).getQualifier() = v.getAUse()
219+
c.(MethodCall).getQualifier() = v.getARead()
220220
or
221221
// ...or a check on its `size`.
222222
exists(MethodCall size |
223223
c = nonZeroGuard(size, branch) and
224224
size.getMethod().hasName("size") and
225-
size.getQualifier() = v.getAUse()
225+
size.getQualifier() = v.getARead()
226226
)
227227
)
228228
)

java/ql/lib/semmle/code/java/dataflow/RangeAnalysis.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ module Sem implements Semantic<Location> {
242242

243243
Type getSsaType(SsaVariable var) { result = var.getSourceVariable().getType() }
244244

245-
final private class FinalSsaVariable = SSA::SsaVariable;
245+
final private class FinalSsaVariable = SSA::SsaDefinition;
246246

247247
class SsaVariable extends FinalSsaVariable {
248-
Expr getAUse() { result = super.getAUse() }
248+
Expr getAUse() { result = super.getARead() }
249249
}
250250

251251
class SsaPhiNode extends SsaVariable instanceof SSA::SsaPhiDefinition {

java/ql/lib/semmle/code/java/dataflow/RangeUtils.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ ArrayCreationExpr getArrayDef(SsaVariable v) {
7474
* `arrlen` without going through a back edge.
7575
*/
7676
private predicate arrayLengthDef(FieldRead arrlen, ArrayCreationExpr def) {
77-
exists(SsaVariable arr |
77+
exists(SsaDefinition arr |
7878
arrlen.getField() instanceof ArrayLengthField and
79-
arrlen.getQualifier() = arr.getAUse() and
79+
arrlen.getQualifier() = arr.getARead() and
8080
def = getArrayDef(arr)
8181
)
8282
}

java/ql/lib/semmle/code/java/dataflow/SSA.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,8 @@ private class RefTypeCastingExpr extends CastingExpr {
417417
*
418418
* The `VarAccess` represents the access to `v` that `result` has the same value as.
419419
*/
420-
Expr sameValue(SsaVariable v, VarAccess va) {
421-
result = v.getAUse() and result = va
420+
Expr sameValue(SsaDefinition v, VarAccess va) {
421+
result = v.getARead() and result = va
422422
or
423423
result.(AssignExpr).getDest() = va and result = v.(SsaExplicitWrite).getDefiningExpr()
424424
or

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowUtil.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ predicate localExprFlow(Expr e1, Expr e2) { localFlow(exprNode(e1), exprNode(e2)
9999
* updates.
100100
*/
101101
predicate hasNonlocalValue(FieldRead fr) {
102-
not exists(SsaVariable v | v.getAUse() = fr)
102+
not exists(SsaDefinition v | v.getARead() = fr)
103103
or
104104
exists(SsaDefinition v, SsaDefinition def |
105105
v.getARead() = fr and def = v.getAnUltimateDefinition()

java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/BoundSpecific.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ private import java as J
88
private import semmle.code.java.dataflow.SSA as Ssa
99
private import semmle.code.java.dataflow.RangeUtils as RU
1010

11-
class SsaVariable = Ssa::SsaVariable;
11+
class SsaVariable extends Ssa::SsaDefinition {
12+
Expr getAUse() { result = super.getARead() }
13+
}
1214

1315
class Expr = J::Expr;
1416

java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/ModulusAnalysisSpecific.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ module Private {
1111

1212
class BasicBlock = BB::BasicBlock;
1313

14-
class SsaVariable = Ssa::SsaVariable;
14+
class SsaVariable extends Ssa::SsaDefinition {
15+
Expr getAUse() { result = super.getARead() }
16+
}
1517

1618
class SsaPhiNode = Ssa::SsaPhiDefinition;
1719

java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/SignAnalysisSpecific.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ private module Impl {
324324
result = e.(CastingExpr).getExpr()
325325
}
326326

327-
Expr getARead(SsaVariable v) { result = v.getAUse() }
327+
Expr getARead(SsaDefinition v) { result = v.getARead() }
328328

329329
Field getField(FieldAccess fa) { result = fa.getField() }
330330

java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/SsaReadPositionSpecific.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ private import semmle.code.java.dataflow.SSA as Ssa
88
private import semmle.code.java.controlflow.BasicBlocks as BB
99
private import SsaReadPositionCommon
1010

11-
class SsaVariable = Ssa::SsaVariable;
11+
class SsaVariable = Ssa::SsaDefinition;
1212

1313
class SsaPhiNode = Ssa::SsaPhiDefinition;
1414

1515
class BasicBlock = BB::BasicBlock;
1616

1717
/** Gets a basic block in which SSA variable `v` is read. */
18-
BasicBlock getAReadBasicBlock(SsaVariable v) { result = v.getAUse().getBasicBlock() }
18+
BasicBlock getAReadBasicBlock(SsaVariable v) { result = v.getARead().getBasicBlock() }
1919

2020
private predicate id(BB::ExprParent x, BB::ExprParent y) { x = y }
2121

0 commit comments

Comments
 (0)