Skip to content

Commit bcf78ac

Browse files
committed
C#: Deprecate the expanded assignment predicate as we no longer extract expanded assignments.
1 parent f28f2b7 commit bcf78ac

File tree

1 file changed

+3
-55
lines changed

1 file changed

+3
-55
lines changed

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

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ExprOrStmtParent extends Element, @exprorstmt_parent {
2020

2121
/** Gets the `i`th child expression of this element (zero-based). */
2222
final Expr getChildExpr(int i) {
23-
expr_parent_adjusted(result, i, this) or
23+
expr_parent(result, i, this) or
2424
expr_parent_top_level_adjusted(result, i, this)
2525
}
2626

@@ -119,66 +119,14 @@ private module Cached {
119119
}
120120

121121
/**
122-
* The `expr_parent()` relation adjusted for expandable assignments. For example,
123-
* the assignment `x += y` is extracted as
124-
*
125-
* ```
126-
* +=
127-
* |
128-
* 2
129-
* |
130-
* =
131-
* / \
132-
* 1 0
133-
* / \
134-
* x +
135-
* / \
136-
* 1 0
137-
* / \
138-
* x y
139-
* ```
140-
*
141-
* in order to be able to retrieve the expanded assignment `x = x + y` as the 2nd
142-
* child. This predicate changes the diagram above into
143-
*
144-
* ```
145-
* +=
146-
* / \
147-
* 1 0
148-
* / \
149-
* x y
150-
* ```
122+
* Use `expr_parent` instead.
151123
*/
152124
cached
153-
predicate expr_parent_adjusted(Expr child, int i, ControlFlowElement parent) {
154-
if parent instanceof AssignOperation
155-
then
156-
parent =
157-
any(AssignOperation ao |
158-
exists(AssignExpr ae | ae = ao.getExpandedAssignment() |
159-
i = 0 and
160-
exists(Expr right |
161-
// right = `x + y`
162-
expr_parent(right, 0, ae)
163-
|
164-
expr_parent(child, 1, right)
165-
)
166-
or
167-
i = 1 and
168-
expr_parent(child, 1, ae)
169-
)
170-
or
171-
not ao.hasExpandedAssignment() and
172-
expr_parent(child, i, parent)
173-
)
174-
else expr_parent(child, i, parent)
175-
}
125+
deprecated predicate expr_parent_adjusted(Expr child, int i, ControlFlowElement parent) { none() }
176126

177127
private Expr getAChildExpr(ExprOrStmtParent parent) {
178128
result = parent.getAChildExpr() and
179129
not result = parent.(DeclarationWithGetSetAccessors).getExpressionBody()
180-
or
181-
result = parent.(AssignOperation).getExpandedAssignment()
182130
}
183131

184132
private ControlFlowElement getAChild(ExprOrStmtParent parent) {

0 commit comments

Comments
 (0)