Skip to content

Commit 9c095bc

Browse files
committed
C#: Deprecate get[L|R]Value predicates.
1 parent 43d002e commit 9c095bc

File tree

81 files changed

+216
-195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+216
-195
lines changed

csharp/ql/lib/Linq/Helpers.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ predicate missedAllOpportunity(ForeachStmtGenericEnumerable fes) {
7777
// The then case of the if assigns false to something and breaks out of the loop.
7878
exists(Assignment a, BoolLiteral bl |
7979
a = is.getThen().getAChild*() and
80-
bl = a.getRValue() and
80+
bl = a.getRightOperand() and
8181
bl.toString() = "false"
8282
) and
8383
is.getThen().getAChild*() instanceof BreakStmt

csharp/ql/lib/definitions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private class MethodUse extends Use, QualifiableExpr {
9696
private class AccessUse extends Access, Use {
9797
AccessUse() {
9898
not this.getTarget().(Parameter).getCallable() instanceof Accessor and
99-
not this = any(LocalVariableDeclAndInitExpr d).getLValue() and
99+
not this = any(LocalVariableDeclAndInitExpr d).getLeftOperand() and
100100
not this.isImplicit() and
101101
not this instanceof MethodAccess and // handled by `MethodUse`
102102
not this instanceof TypeAccess and // handled by `TypeMentionUse`

csharp/ql/lib/semmle/code/csharp/Assignable.qll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ private class RefArg extends AssignableAccess {
235235
module AssignableInternal {
236236
private predicate tupleAssignmentDefinition(AssignExpr ae, Expr leaf) {
237237
exists(TupleExpr te |
238-
ae.getLValue() = te and
238+
ae.getLeftOperand() = te and
239239
te.getAnArgument+() = leaf and
240240
// `leaf` is either an assignable access or a local variable declaration
241241
not leaf instanceof TupleExpr
@@ -249,8 +249,8 @@ module AssignableInternal {
249249
*/
250250
private predicate tupleAssignmentPair(AssignExpr ae, Expr left, Expr right) {
251251
tupleAssignmentDefinition(ae, _) and
252-
left = ae.getLValue() and
253-
right = ae.getRValue()
252+
left = ae.getLeftOperand() and
253+
right = ae.getRightOperand()
254254
or
255255
exists(TupleExpr l, TupleExpr r, int i | tupleAssignmentPair(ae, l, r) |
256256
left = l.getArgument(i) and
@@ -291,7 +291,7 @@ module AssignableInternal {
291291
cached
292292
newtype TAssignableDefinition =
293293
TAssignmentDefinition(Assignment a) {
294-
not a.getLValue() instanceof TupleExpr and
294+
not a.getLeftOperand() instanceof TupleExpr and
295295
not a instanceof AssignCallOperation and
296296
not a instanceof AssignCoalesceExpr
297297
} or
@@ -358,7 +358,7 @@ module AssignableInternal {
358358
// Not defined by dispatch in order to avoid too conservative negative recursion error
359359
cached
360360
AssignableAccess getTargetAccess(AssignableDefinition def) {
361-
def = TAssignmentDefinition(any(Assignment a | a.getLValue() = result))
361+
def = TAssignmentDefinition(any(Assignment a | a.getLeftOperand() = result))
362362
or
363363
def = TTupleAssignmentDefinition(_, result)
364364
or
@@ -381,8 +381,8 @@ module AssignableInternal {
381381
tupleAssignmentPair(ae, ac, result)
382382
)
383383
or
384-
exists(Assignment ass | ac = ass.getLValue() |
385-
result = ass.getRValue() and
384+
exists(Assignment ass | ac = ass.getLeftOperand() |
385+
result = ass.getRightOperand() and
386386
not ass instanceof AssignOperation
387387
)
388388
or
@@ -527,7 +527,7 @@ module AssignableDefinitions {
527527
Assignment getAssignment() { result = a }
528528

529529
override Expr getSource() {
530-
result = a.getRValue() and
530+
result = a.getRightOperand() and
531531
not a instanceof AddOrRemoveEventExpr
532532
}
533533

csharp/ql/lib/semmle/code/csharp/PrintAst.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,10 @@ final class AssignmentNode extends ControlFlowElementNode {
343343
result.(TypeMentionNode).getTarget() = controlFlowElement
344344
or
345345
childIndex = 0 and
346-
result.(ElementNode).getElement() = assignment.getLValue()
346+
result.(ElementNode).getElement() = assignment.getLeftOperand()
347347
or
348348
childIndex = 1 and
349-
result.(ElementNode).getElement() = assignment.getRValue()
349+
result.(ElementNode).getElement() = assignment.getRightOperand()
350350
}
351351
}
352352

csharp/ql/lib/semmle/code/csharp/Property.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,8 @@ class Setter extends Accessor, @setter {
535535
exists(AssignExpr assign |
536536
this.getStatementBody().getNumberOfStmts() = 1 and
537537
assign.getParent() = this.getStatementBody().getAChild() and
538-
assign.getLValue() = result.getAnAccess() and
539-
assign.getRValue() = accessToValue()
538+
assign.getLeftOperand() = result.getAnAccess() and
539+
assign.getRightOperand() = accessToValue()
540540
)
541541
}
542542

csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private module GuardsInput implements
136136
IdExpr() { this instanceof AssignExpr or this instanceof CastExpr }
137137

138138
Expr getEqualChildExpr() {
139-
result = this.(AssignExpr).getRValue()
139+
result = this.(AssignExpr).getRightOperand()
140140
or
141141
result = this.(CastExpr).getExpr()
142142
}
@@ -836,7 +836,7 @@ module Internal {
836836

837837
/** Holds if expression `e2` is a `null` value whenever `e1` is. */
838838
predicate nullValueImpliedUnary(Expr e1, Expr e2) {
839-
e1 = e2.(AssignExpr).getRValue()
839+
e1 = e2.(AssignExpr).getRightOperand()
840840
or
841841
e1 = e2.(Cast).getExpr()
842842
or
@@ -923,7 +923,7 @@ module Internal {
923923
/** Holds if expression `e2` is a non-`null` value whenever `e1` is. */
924924
predicate nonNullValueImpliedUnary(Expr e1, Expr e2) {
925925
e1 = e2.(CastExpr).getExpr() or
926-
e1 = e2.(AssignExpr).getRValue() or
926+
e1 = e2.(AssignExpr).getRightOperand() or
927927
e1 = e2.(NullCoalescingOperation).getAnOperand()
928928
}
929929

csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ module Expressions {
521521
// ```
522522
// need special treatment, because the accesses `[0]`, `[1]`, and `[2]`
523523
// have no qualifier.
524-
this = any(MemberInitializer mi).getLValue()
524+
this = any(MemberInitializer mi).getLeftOperand()
525525
) and
526526
not exists(AssignableDefinitions::OutRefDefinition def | def.getTargetAccess() = this)
527527
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private Expr maybeNullExpr(Expr reason) {
3131
or
3232
result instanceof AsExpr and reason = result
3333
or
34-
result.(AssignExpr).getRValue() = maybeNullExpr(reason)
34+
result.(AssignExpr).getRightOperand() = maybeNullExpr(reason)
3535
or
3636
result.(CastExpr).getExpr() = maybeNullExpr(reason)
3737
or

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ module LocalFlow {
528528
e2 =
529529
any(AssignExpr ae |
530530
ae.getParent() = any(ControlFlowElement cfe | not cfe instanceof ExprStmt) and
531-
e1 = ae.getRValue()
531+
e1 = ae.getRightOperand()
532532
)
533533
or
534534
e1 = e2.(ObjectCreation).getInitializer()
@@ -554,7 +554,7 @@ module LocalFlow {
554554
e2 = we
555555
)
556556
or
557-
exists(AssignExpr ae | ae.getLValue().(TupleExpr) = e2 and ae.getRValue() = e1)
557+
exists(AssignExpr ae | ae.getLeftOperand().(TupleExpr) = e2 and ae.getRightOperand() = e1)
558558
or
559559
exists(ControlFlowElement cfe | cfe = e2.(TupleExpr).(PatternExpr).getPatternMatch() |
560560
cfe.(IsExpr).getExpr() = e1
@@ -795,7 +795,7 @@ private predicate fieldOrPropertyStore(ContentSet c, Expr src, Expr q, boolean p
795795
q = we and
796796
mi = we.getInitializer().getAMemberInitializer() and
797797
f = mi.getInitializedMember() and
798-
src = mi.getRValue() and
798+
src = mi.getRightOperand() and
799799
postUpdate = false
800800
)
801801
or
@@ -804,7 +804,7 @@ private predicate fieldOrPropertyStore(ContentSet c, Expr src, Expr q, boolean p
804804
mi = q.(ObjectInitializer).getAMemberInitializer() and
805805
q.getParent() instanceof ObjectCreation and
806806
f = mi.getInitializedMember() and
807-
src = mi.getRValue() and
807+
src = mi.getRightOperand() and
808808
postUpdate = false
809809
)
810810
or
@@ -879,8 +879,8 @@ private predicate arrayStore(Expr src, Expr a, boolean postUpdate) {
879879
// Member initializer, `new C { Array = { [i] = src } }`
880880
exists(MemberInitializer mi |
881881
mi = a.(ObjectInitializer).getAMemberInitializer() and
882-
mi.getLValue() instanceof ArrayAccess and
883-
mi.getRValue() = src and
882+
mi.getLeftOperand() instanceof ArrayAccess and
883+
mi.getRightOperand() = src and
884884
postUpdate = false
885885
)
886886
}
@@ -2582,7 +2582,7 @@ module PostUpdateNodes {
25822582
call.getExpr() = init.(CollectionInitializer).getAnElementInitializer()
25832583
or
25842584
// E.g. `new Dictionary<int, string>() { [0] = "a", [1] = "b" }`
2585-
call.getExpr() = init.(ObjectInitializer).getAMemberInitializer().getLValue()
2585+
call.getExpr() = init.(ObjectInitializer).getAMemberInitializer().getLeftOperand()
25862586
)
25872587
}
25882588

@@ -2795,7 +2795,7 @@ predicate additionalLambdaFlowStep(Node nodeFrom, Node nodeTo, boolean preserves
27952795
preservesValue = true
27962796
or
27972797
exists(AddEventExpr aee |
2798-
nodeFrom.asExpr() = aee.getRValue() and
2798+
nodeFrom.asExpr() = aee.getRightOperand() and
27992799
nodeTo.asExpr().(EventRead).getTarget() = aee.getTarget() and
28002800
preservesValue = false
28012801
)

csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ private module CallGraph {
337337
pred = succ.(DelegateCreation).getArgument()
338338
or
339339
exists(AddEventExpr ae | succ.(EventAccess).getTarget() = ae.getTarget() |
340-
pred = ae.getRValue()
340+
pred = ae.getRightOperand()
341341
)
342342
}
343343

0 commit comments

Comments
 (0)