Skip to content

Commit 93a6e56

Browse files
committed
Java: Delete old deprecated SSA classes and predicates.
1 parent 350cd9b commit 93a6e56

3 files changed

Lines changed: 0 additions & 388 deletions

File tree

‎java/ql/lib/semmle/code/java/dataflow/IntegerGuards.qll‎

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,6 @@ private import SSA
99
private import RangeUtils
1010
private import RangeAnalysis
1111

12-
/** Gets an expression that might have the value `i`. */
13-
deprecated private Expr exprWithIntValue(int i) {
14-
result.(ConstantIntegerExpr).getIntValue() = i or
15-
result.(ChooseExpr).getAResultExpr() = exprWithIntValue(i)
16-
}
17-
18-
/**
19-
* An expression for which the predicate `integerGuard` is relevant.
20-
* This includes `VarRead` and `MethodCall`.
21-
*/
22-
deprecated class IntComparableExpr extends Expr {
23-
IntComparableExpr() { this instanceof VarRead or this instanceof MethodCall }
24-
25-
/** Gets an integer that is directly assigned to the expression in case of a variable; or zero. */
26-
deprecated int relevantInt() {
27-
exists(SsaExplicitUpdate ssa, SsaSourceVariable v |
28-
this = v.getAnAccess() and
29-
ssa.getSourceVariable() = v and
30-
ssa.getDefiningExpr().(VariableAssign).getSource() = exprWithIntValue(result)
31-
)
32-
or
33-
result = 0
34-
}
35-
}
36-
3712
/**
3813
* Holds if `comp` evaluating to `branch` ensures that `e1` is less than `e2`.
3914
* When `strict` is true, `e1` is strictly less than `e2`, otherwise it is less
@@ -111,79 +86,3 @@ Expr nonZeroGuard(Expr e, boolean branch) {
11186
upper = false and val > 0 // e >= val > 0 ==> e != 0
11287
)
11388
}
114-
115-
/**
116-
* DEPRECATED.
117-
*
118-
* An expression that directly tests whether a given expression is equal to `k` or not.
119-
* The set of `k`s is restricted to those that are relevant for the expression or
120-
* have a direct comparison with the expression.
121-
*
122-
* If `result` evaluates to `branch`, then `e` is guaranteed to be equal to `k` if `is_k`
123-
* is true, and different from `k` if `is_k` is false.
124-
*/
125-
pragma[nomagic]
126-
deprecated Expr integerGuard(IntComparableExpr e, boolean branch, int k, boolean is_k) {
127-
exists(EqualityTest eqtest, boolean polarity |
128-
eqtest = result and
129-
eqtest.hasOperands(e, any(ConstantIntegerExpr c | c.getIntValue() = k)) and
130-
polarity = eqtest.polarity() and
131-
(
132-
branch = true and is_k = polarity
133-
or
134-
branch = false and is_k = polarity.booleanNot()
135-
)
136-
)
137-
or
138-
exists(int val, boolean upper |
139-
rangeGuard(result, branch, e, val, upper) and
140-
k = e.relevantInt() and
141-
is_k = false
142-
|
143-
upper = true and val < k // e <= val < k ==> e != k
144-
or
145-
upper = false and val > k // e >= val > k ==> e != k
146-
)
147-
}
148-
149-
/**
150-
* DEPRECATED: Use `rangeGuard` instead.
151-
*
152-
* A guard that splits the values of a variable into one range with an upper bound of `k-1`
153-
* and one with a lower bound of `k`.
154-
*
155-
* If `branch_with_lower_bound_k` is true then `result` is equivalent to `k <= x`
156-
* and if it is false then `result` is equivalent to `k > x`.
157-
*/
158-
deprecated Expr intBoundGuard(VarRead x, boolean branch_with_lower_bound_k, int k) {
159-
exists(ComparisonExpr comp, ConstantIntegerExpr c, int val |
160-
comp = result and
161-
comp.hasOperands(x, c) and
162-
c.getIntValue() = val and
163-
x.getVariable().getType() instanceof IntegralType
164-
|
165-
// c < x
166-
comp.getLesserOperand() = c and
167-
comp.isStrict() and
168-
branch_with_lower_bound_k = true and
169-
val + 1 = k
170-
or
171-
// c <= x
172-
comp.getLesserOperand() = c and
173-
not comp.isStrict() and
174-
branch_with_lower_bound_k = true and
175-
val = k
176-
or
177-
// x < c
178-
comp.getGreaterOperand() = c and
179-
comp.isStrict() and
180-
branch_with_lower_bound_k = false and
181-
val = k
182-
or
183-
// x <= c
184-
comp.getGreaterOperand() = c and
185-
not comp.isStrict() and
186-
branch_with_lower_bound_k = false and
187-
val + 1 = k
188-
)
189-
}

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

Lines changed: 0 additions & 240 deletions
Original file line numberDiff line numberDiff line change
@@ -188,178 +188,6 @@ class SsaImplicitQualifierDefinition extends SsaImplicitWrite {
188188
*/
189189
VarRead ssaGetAFirstUse(SsaDefinition def) { firstUse(def, result) }
190190

191-
/**
192-
* DEPRECATED: use `SsaDefinition` instead.
193-
*
194-
* An SSA variable.
195-
*/
196-
deprecated class SsaVariable extends Definition {
197-
/** Gets the SSA source variable underlying this SSA variable. */
198-
SsaSourceVariable getSourceVariable() { result = super.getSourceVariable() }
199-
200-
/**
201-
* DEPRECATED: Use `getControlFlowNode()` instead.
202-
*
203-
* Gets the `ControlFlowNode` at which this SSA variable is defined.
204-
*/
205-
pragma[nomagic]
206-
deprecated ControlFlowNode getCfgNode() {
207-
exists(BasicBlock bb, int i |
208-
this.definesAt(_, bb, i) and
209-
// phi nodes are inserted at position `-1`
210-
result = bb.getNode(0.maximum(i))
211-
)
212-
}
213-
214-
/** Gets a textual representation of this SSA variable. */
215-
string toString() { none() }
216-
217-
/** Gets the source location for this element. */
218-
Location getLocation() { result = this.getCfgNode().getLocation() }
219-
220-
/** Gets the `BasicBlock` in which this SSA variable is defined. */
221-
BasicBlock getBasicBlock() { result = super.getBasicBlock() }
222-
223-
/**
224-
* DEPRECATED: Use `getARead()` instead.
225-
*
226-
* Gets an access of this SSA variable.
227-
*/
228-
deprecated VarRead getAUse() { result = getAUse(this) }
229-
230-
/**
231-
* DEPRECATED: Use `ssaGetAFirstUse(SsaDefinition)` instead.
232-
*
233-
* Gets an access of the SSA source variable underlying this SSA variable
234-
* that can be reached from this SSA variable without passing through any
235-
* other uses, but potentially through phi nodes and uncertain implicit
236-
* updates.
237-
*
238-
* Subsequent uses can be found by following the steps defined by
239-
* `adjacentUseUse`.
240-
*/
241-
deprecated VarRead getAFirstUse() { firstUse(this, result) }
242-
243-
/** Holds if this SSA variable is live at the end of `b`. */
244-
predicate isLiveAtEndOfBlock(BasicBlock b) { ssaDefReachesEndOfBlock(b, this) }
245-
246-
/**
247-
* DEPRECATED.
248-
*
249-
* Gets an SSA variable whose value can flow to this one in one step. This
250-
* includes inputs to phi nodes, the prior definition of uncertain updates,
251-
* and the captured ssa variable for a closure variable.
252-
*/
253-
deprecated SsaVariable getAPhiInputOrPriorDef() {
254-
result = this.(SsaPhiNode).getAPhiInput() or
255-
result = this.(SsaUncertainImplicitUpdate).getPriorDef() or
256-
this.(SsaImplicitInit).captures(result)
257-
}
258-
259-
/**
260-
* DEPRECATED: Use `SsaCapturedDefinition::getAnUltimateCapturedDefinition()`
261-
* and/or `SsaDefinition::getAnUltimateDefinition()` instead.
262-
*
263-
* Gets a definition that ultimately defines this variable and is not itself a phi node.
264-
*/
265-
deprecated SsaVariable getAnUltimateDefinition() {
266-
result = this.getAPhiInputOrPriorDef*() and not result instanceof SsaPhiNode
267-
}
268-
}
269-
270-
/**
271-
* DEPRECATED: use `SsaWriteDefinition` instead.
272-
*
273-
* An SSA variable that either explicitly or implicitly updates the variable.
274-
*/
275-
deprecated class SsaUpdate extends SsaVariable instanceof WriteDefinition {
276-
SsaUpdate() { not this instanceof SsaImplicitInit }
277-
}
278-
279-
/**
280-
* DEPRECATED: Use `SsaExplicitWrite` instead.
281-
*
282-
* An SSA variable that is defined by a `VariableUpdate`.
283-
*/
284-
deprecated class SsaExplicitUpdate extends SsaUpdate {
285-
private VariableUpdate upd;
286-
287-
SsaExplicitUpdate() { ssaExplicitUpdate(this, upd) }
288-
289-
override string toString() { result = "SSA def(" + this.getSourceVariable() + ")" }
290-
291-
/** Gets the `VariableUpdate` defining the SSA variable. */
292-
VariableUpdate getDefiningExpr() { result = upd }
293-
}
294-
295-
/**
296-
* DEPRECATED: Use `SsaImplicitWrite` instead.
297-
*
298-
* An SSA variable that represents any sort of implicit update. This can be a
299-
* `Call` that might reach a non-local update of the field, an explicit or
300-
* implicit update of the qualifier of the field, or the implicit update that
301-
* occurs just prior to a `FieldRead` of an untracked field.
302-
*/
303-
deprecated class SsaImplicitUpdate extends SsaUpdate {
304-
SsaImplicitUpdate() { not this instanceof SsaExplicitUpdate }
305-
306-
override string toString() {
307-
result = "SSA impl upd[" + this.getKind() + "](" + this.getSourceVariable() + ")"
308-
}
309-
310-
private predicate hasExplicitQualifierUpdate() {
311-
exists(SsaUpdate qdef, BasicBlock bb, int i |
312-
qdef.definesAt(this.getSourceVariable().getQualifier(), bb, i) and
313-
this.definesAt(_, bb, i) and
314-
not qdef instanceof SsaUncertainImplicitUpdate
315-
)
316-
}
317-
318-
private predicate hasImplicitQualifierUpdate() {
319-
exists(SsaUncertainImplicitUpdate qdef, BasicBlock bb, int i |
320-
qdef.definesAt(this.getSourceVariable().getQualifier(), bb, i) and
321-
this.definesAt(_, bb, i)
322-
)
323-
}
324-
325-
private string getKind() {
326-
this.hasExplicitQualifierUpdate() and
327-
result = "explicit qualifier" // -> SSA qualifier def
328-
or
329-
if this.hasImplicitQualifierUpdate()
330-
then
331-
if isNonLocal(this)
332-
then result = "nonlocal + nonlocal qualifier" // -> SSA qualifier def
333-
else result = "nonlocal qualifier" // -> SSA qualifier def
334-
else (
335-
isNonLocal(this) and result = "nonlocal" // -> SSA call def
336-
)
337-
}
338-
339-
/**
340-
* DEPRECATED: Use `SsaImplicitCallDefinition.getANonLocalUpdate()` instead.
341-
*
342-
* Gets a reachable `FieldWrite` that might represent this ssa update, if any.
343-
*/
344-
overlay[global]
345-
deprecated FieldWrite getANonLocalUpdate() { result = getANonLocalUpdate(this) }
346-
347-
/**
348-
* DEPRECATED: Use `SsaImplicitQualifierDefinition` instead.
349-
*
350-
* Holds if this ssa variable might change the value to something unknown.
351-
*
352-
* Examples include updates that might change the value of the qualifier, or
353-
* reads from untracked variables, for example those where the field or one
354-
* of its qualifiers is volatile.
355-
*/
356-
deprecated predicate assignsUnknownValue() {
357-
this.hasExplicitQualifierUpdate()
358-
or
359-
this.hasImplicitQualifierUpdate()
360-
}
361-
}
362-
363191
private predicate hasQualifierUpdate(SsaImplicitWrite def) {
364192
exists(SsaWriteDefinition qdef, BasicBlock bb, int i |
365193
qdef.definesAt(def.getSourceVariable().getQualifier(), bb, i) and
@@ -384,74 +212,6 @@ private predicate isNonLocalImpl(SsaImplicitWrite calldef) { exists(getANonLocal
384212

385213
private predicate isNonLocal(SsaImplicitWrite calldef) = forceLocal(isNonLocalImpl/1)(calldef)
386214

387-
/**
388-
* DEPRECATED: Use `SsaUncertainWrite` instead.
389-
*
390-
* An SSA variable that represents an uncertain implicit update of the value.
391-
* This is a `Call` that might reach a non-local update of the field or one of
392-
* its qualifiers.
393-
*/
394-
deprecated class SsaUncertainImplicitUpdate extends SsaImplicitUpdate {
395-
SsaUncertainImplicitUpdate() { ssaUncertainImplicitUpdate(this) }
396-
397-
/**
398-
* DEPRECATED: Use `getPriorDefinition()` instead.
399-
*
400-
* Gets the immediately preceding definition. Since this update is uncertain
401-
* the value from the preceding definition might still be valid.
402-
*/
403-
deprecated SsaVariable getPriorDef() { ssaDefReachesUncertainDef(result, this) }
404-
}
405-
406-
/**
407-
* DEPRECATED: Use `SsaParameterInit`, `SsaImplicitEntryDefinition`, or `SsaCapturedDefinition` instead.
408-
*
409-
* An SSA variable that is defined by its initial value in the callable. This
410-
* includes initial values of parameters, fields, and closure variables.
411-
*/
412-
deprecated class SsaImplicitInit extends SsaVariable instanceof WriteDefinition {
413-
SsaImplicitInit() { ssaImplicitInit(this) }
414-
415-
override string toString() { result = "SSA init(" + this.getSourceVariable() + ")" }
416-
417-
/** Holds if this is a closure variable that captures the value of `capturedvar`. */
418-
predicate captures(SsaVariable capturedvar) { captures(this, capturedvar) }
419-
420-
/**
421-
* DEPRECATED: Use `SsaParameterInit::getParameter()` instead.
422-
*
423-
* Holds if the SSA variable is a parameter defined by its initial value in the callable.
424-
*/
425-
deprecated predicate isParameterDefinition(Parameter p) {
426-
this.getSourceVariable() = TLocalVar(p.getCallable(), p) and
427-
p.getCallable().getBody().getControlFlowNode() = this.getCfgNode()
428-
}
429-
}
430-
431-
/**
432-
* DEPRECATED: Use `SsaPhiDefinition` instead.
433-
*
434-
* An SSA phi node.
435-
*/
436-
deprecated class SsaPhiNode extends SsaVariable instanceof PhiNode {
437-
override string toString() { result = "SSA phi(" + this.getSourceVariable() + ")" }
438-
439-
/**
440-
* DEPRECATED: Use `getAnInput()` instead.
441-
*
442-
* Gets an input to the phi node defining the SSA variable.
443-
*/
444-
deprecated SsaVariable getAPhiInput() { this.hasInputFromBlock(result, _) }
445-
446-
/** Gets an input to the phi node defining the SSA variable. */
447-
SsaVariable getAnInput() { this.hasInputFromBlock(result, _) }
448-
449-
/** Holds if `inp` is an input to the phi node along the edge originating in `bb`. */
450-
predicate hasInputFromBlock(SsaVariable inp, BasicBlock bb) {
451-
phiHasInputFromBlock(this, inp, bb)
452-
}
453-
}
454-
455215
private class RefTypeCastingExpr extends CastingExpr {
456216
RefTypeCastingExpr() {
457217
this.getType() instanceof RefType and

0 commit comments

Comments
 (0)