Skip to content

Commit 3c9c0e9

Browse files
authored
Merge pull request #1459 from hvitved/csharp/remove-deprecated
C#: Remove deprecated predicates
2 parents 07eb0ec + 5443f74 commit 3c9c0e9

File tree

4 files changed

+0
-246
lines changed

4 files changed

+0
-246
lines changed

csharp/ql/src/semmle/code/csharp/controlflow/BasicBlocks.qll

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -62,45 +62,6 @@ class BasicBlock extends TBasicBlockStart {
6262
*/
6363
BasicBlock getAFalseSuccessor() { result.getFirstNode() = getLastNode().getAFalseSuccessor() }
6464

65-
/**
66-
* Gets an immediate `null` successor, if any.
67-
*
68-
* An immediate `null` successor is a successor that is reached when
69-
* the expression that ends this basic block evaluates to `null`.
70-
*
71-
* Example:
72-
*
73-
* ```
74-
* x?.M();
75-
* return;
76-
* ```
77-
*
78-
* The node on line 2 is an immediate `null` successor of the node
79-
* `x` on line 1.
80-
*/
81-
deprecated BasicBlock getANullSuccessor() {
82-
result.getFirstNode() = getLastNode().getANullSuccessor()
83-
}
84-
85-
/**
86-
* Gets an immediate non-`null` successor, if any.
87-
*
88-
* An immediate non-`null` successor is a successor that is reached when
89-
* the expression that ends this basic block evaluates to a non-`null` value.
90-
*
91-
* Example:
92-
*
93-
* ```
94-
* x?.M();
95-
* ```
96-
*
97-
* The node `x?.M()`, representing the call to `M`, is a non-`null` successor
98-
* of the node `x`.
99-
*/
100-
deprecated BasicBlock getANonNullSuccessor() {
101-
result.getFirstNode() = getLastNode().getANonNullSuccessor()
102-
}
103-
10465
/** Gets the control flow node at a specific (zero-indexed) position in this basic block. */
10566
ControlFlow::Node getNode(int pos) { bbIndex(getFirstNode(), result, pos) }
10667

@@ -511,81 +472,4 @@ class ConditionBlock extends BasicBlock {
511472

512473
exists(BasicBlock succ | this.immediatelyControls(succ, s) | succ.dominates(controlled))
513474
}
514-
515-
/**
516-
* Holds if basic block `controlled` is controlled by this basic block with
517-
* nullness check `isNull`. That is, `controlled` can only be reached from
518-
* the callable entry point by going via the `null` edge (`isNull = true`)
519-
* or non-`null` edge (`isNull = false`) out of this basic block.
520-
*/
521-
deprecated predicate controlsNullness(BasicBlock controlled, boolean isNull) {
522-
this.controls(controlled, any(NullnessSuccessor s | s.getValue() = isNull))
523-
}
524-
525-
/**
526-
* Holds if basic block `controlled` is controlled by this basic block with
527-
* Boolean value `testIsTrue`. That is, `controlled` can only be reached from
528-
* the callable entry point by going via the true edge (`testIsTrue = true`)
529-
* or false edge (`testIsTrue = false`) out of this basic block.
530-
*
531-
* Moreover, `cond` is a sub expression of the expression ending this basic
532-
* block that must have evaluated to `condIsTrue`. For example, in
533-
*
534-
* ```
535-
* if (x & !y)
536-
* f(x, y);
537-
* ```
538-
*
539-
* `f(x, y)` is controlled by `x & !y` evaluating to `true`, but also by sub
540-
* conditions `x` and `y` evaluating to `true` and `false`, respectively.
541-
*/
542-
// Note that this is only needed when using non-short-circuit logic. When using
543-
// short-circuit logic, the control flow graph will have appropriate true/false
544-
// edges for the sub conditions:
545-
//
546-
// Short-circuit logic CFG -- `if (x && y) A B`:
547-
// x && y --> x --true--> y --true--> A
548-
// | |
549-
// | false
550-
// | |
551-
// | V
552-
// \--false--> B
553-
//
554-
// Non-short-circuit logic CFG -- `if (x & y) A B`:
555-
// x --> y --> x & y --true--> A
556-
// \--false--> B
557-
//
558-
// In the former case, `x` and `y` control `A`, in the latter case
559-
// only `x & y` controls `A` if we do not take sub conditions into account.
560-
deprecated predicate controlsSubCond(
561-
BasicBlock controlled, boolean testIsTrue, Expr cond, boolean condIsTrue
562-
) {
563-
impliesSub(getLastNode().getElement(), cond, testIsTrue, condIsTrue) and
564-
controls(controlled, any(BooleanSuccessor s | s.getValue() = testIsTrue))
565-
}
566-
}
567-
568-
/**
569-
* Holds if `e2` is a sub expression of (Boolean) expression `e1`, and
570-
* if `e1` has value `b1` then `e2` must have value `b2`.
571-
*/
572-
deprecated private predicate impliesSub(Expr e1, Expr e2, boolean b1, boolean b2) {
573-
if e1 instanceof LogicalNotExpr
574-
then impliesSub(e1.(LogicalNotExpr).getOperand(), e2, b1.booleanNot(), b2)
575-
else
576-
if e1 instanceof BitwiseAndExpr or e1 instanceof LogicalAndExpr
577-
then
578-
impliesSub(e1.(BinaryOperation).getAnOperand(), e2, b1, b2) and
579-
b1 = true
580-
else
581-
if e1 instanceof BitwiseOrExpr or e1 instanceof LogicalOrExpr
582-
then (
583-
impliesSub(e1.(BinaryOperation).getAnOperand(), e2, b1, b2) and
584-
b1 = false
585-
) else (
586-
e1.getType() instanceof BoolType and
587-
e1 = e2 and
588-
b1 = b2 and
589-
(b1 = true or b1 = false)
590-
)
591475
}

csharp/ql/src/semmle/code/csharp/controlflow/ControlFlowGraph.qll

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -233,45 +233,6 @@ module ControlFlow {
233233
result = getASuccessorByType(any(BooleanSuccessor t | t.getValue() = false))
234234
}
235235

236-
/**
237-
* Gets an immediate `null` successor, if any.
238-
*
239-
* An immediate `null` successor is a successor that is reached when
240-
* this expression evaluates to `null`.
241-
*
242-
* Example:
243-
*
244-
* ```
245-
* x?.M();
246-
* return;
247-
* ```
248-
*
249-
* The node on line 2 is an immediate `null` successor of the node
250-
* `x` on line 1.
251-
*/
252-
deprecated Node getANullSuccessor() {
253-
result = getASuccessorByType(any(NullnessSuccessor t | t.isNull()))
254-
}
255-
256-
/**
257-
* Gets an immediate non-`null` successor, if any.
258-
*
259-
* An immediate non-`null` successor is a successor that is reached when
260-
* this expressions evaluates to a non-`null` value.
261-
*
262-
* Example:
263-
*
264-
* ```
265-
* x?.M();
266-
* ```
267-
*
268-
* The node `x?.M()`, representing the call to `M`, is a non-`null` successor
269-
* of the node `x`.
270-
*/
271-
deprecated Node getANonNullSuccessor() {
272-
result = getASuccessorByType(any(NullnessSuccessor t | not t.isNull()))
273-
}
274-
275236
/** Holds if this node has more than one predecessor. */
276237
predicate isJoin() { strictcount(this.getAPredecessor()) > 1 }
277238

@@ -2038,85 +1999,3 @@ module ControlFlow {
20381999
}
20392000
private import Internal
20402001
}
2041-
2042-
// The code below is all for backwards-compatibility; should be deleted eventually
2043-
deprecated class ControlFlowNode = ControlFlow::Node;
2044-
2045-
deprecated class CallableEntryNode = ControlFlow::Nodes::EntryNode;
2046-
2047-
deprecated class CallableExitNode = ControlFlow::Nodes::ExitNode;
2048-
2049-
/**
2050-
* DEPRECATED: Use `ElementNode` instead.
2051-
*
2052-
* A node for a control flow element.
2053-
*/
2054-
deprecated class NormalControlFlowNode extends ControlFlow::Nodes::ElementNode {
2055-
NormalControlFlowNode() {
2056-
forall(ControlFlow::Nodes::FinallySplit s | s = this.getASplit() |
2057-
s.getType() instanceof ControlFlow::SuccessorTypes::NormalSuccessor
2058-
)
2059-
}
2060-
}
2061-
2062-
/**
2063-
* DEPRECATED: Use `ElementNode` instead.
2064-
*
2065-
* A split node for a control flow element that belongs to a `finally` block.
2066-
*/
2067-
deprecated class FinallySplitControlFlowNode extends ControlFlow::Nodes::ElementNode {
2068-
FinallySplitControlFlowNode() {
2069-
exists(ControlFlow::Internal::FinallySplitting::FinallySplitType type |
2070-
type = this.getASplit().(ControlFlow::Nodes::FinallySplit).getType()
2071-
|
2072-
not type instanceof ControlFlow::SuccessorTypes::NormalSuccessor
2073-
)
2074-
}
2075-
2076-
/** Gets the try statement that this `finally` node belongs to. */
2077-
TryStmt getTryStmt() {
2078-
this.getElement() = ControlFlow::Internal::FinallySplitting::getAFinallyDescendant(result)
2079-
}
2080-
}
2081-
2082-
/** DEPRECATED: Use `ControlFlow::SuccessorType` instead. */
2083-
deprecated class ControlFlowEdgeType = ControlFlow::SuccessorType;
2084-
2085-
/** DEPRECATED: Use `ControlFlow::NormalSuccessor` instead. */
2086-
deprecated class ControlFlowEdgeSuccessor = ControlFlow::SuccessorTypes::NormalSuccessor;
2087-
2088-
/** DEPRECATED: Use `ControlFlow::ConditionalSuccessor` instead. */
2089-
deprecated class ControlFlowEdgeConditional = ControlFlow::SuccessorTypes::ConditionalSuccessor;
2090-
2091-
/** DEPRECATED: Use `ControlFlow::BooleanSuccessor` instead. */
2092-
deprecated class ControlFlowEdgeBoolean = ControlFlow::SuccessorTypes::BooleanSuccessor;
2093-
2094-
/** DEPRECATED: Use `ControlFlow::NullnessSuccessor` instead. */
2095-
deprecated class ControlFlowEdgeNullness = ControlFlow::SuccessorTypes::NullnessSuccessor;
2096-
2097-
/** DEPRECATED: Use `ControlFlow::MatchingSuccessor` instead. */
2098-
deprecated class ControlFlowEdgeMatching = ControlFlow::SuccessorTypes::MatchingSuccessor;
2099-
2100-
/** DEPRECATED: Use `ControlFlow::EmptinessSuccessor` instead. */
2101-
deprecated class ControlFlowEdgeEmptiness = ControlFlow::SuccessorTypes::EmptinessSuccessor;
2102-
2103-
/** DEPRECATED: Use `ControlFlow::ReturnSuccessor` instead. */
2104-
deprecated class ControlFlowEdgeReturn = ControlFlow::SuccessorTypes::ReturnSuccessor;
2105-
2106-
/** DEPRECATED: Use `ControlFlow::BreakSuccessor` instead. */
2107-
deprecated class ControlFlowEdgeBreak = ControlFlow::SuccessorTypes::BreakSuccessor;
2108-
2109-
/** DEPRECATED: Use `ControlFlow::ContinueSuccessor` instead. */
2110-
deprecated class ControlFlowEdgeContinue = ControlFlow::SuccessorTypes::ContinueSuccessor;
2111-
2112-
/** DEPRECATED: Use `ControlFlow::GotoLabelSuccessor` instead. */
2113-
deprecated class ControlFlowEdgeGotoLabel = ControlFlow::SuccessorTypes::GotoLabelSuccessor;
2114-
2115-
/** DEPRECATED: Use `ControlFlow::GotoCaseSuccessor` instead. */
2116-
deprecated class ControlFlowEdgeGotoCase = ControlFlow::SuccessorTypes::GotoCaseSuccessor;
2117-
2118-
/** DEPRECATED: Use `ControlFlow::GotoDefaultSuccessor` instead. */
2119-
deprecated class ControlFlowEdgeGotoDefault = ControlFlow::SuccessorTypes::GotoDefaultSuccessor;
2120-
2121-
/** DEPRECATED: Use `ControlFlow::ExceptionSuccessor` instead. */
2122-
deprecated class ControlFlowEdgeException = ControlFlow::SuccessorTypes::ExceptionSuccessor;

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ module AbstractValues {
125125
/** Gets the case. */
126126
Case getCase() { this = TMatchValue(result, _) }
127127

128-
/** Gets the case statement. */
129-
deprecated CaseStmt getCaseStmt() { result = this.getCase() }
130-
131128
/** Holds if this value represents a match. */
132129
predicate isMatch() { this = TMatchValue(_, true) }
133130

csharp/ql/src/semmle/code/csharp/dataflow/SSA.qll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,6 @@ module Ssa {
411411
/** Gets the qualifier of this source variable, if any. */
412412
SourceVariable getQualifier() { none() }
413413

414-
/**
415-
* Gets an SSA definition that has this variable as its underlying
416-
* source variable.
417-
*/
418-
deprecated Definition getAnDefinition() { result.getSourceVariable() = this }
419-
420414
/**
421415
* Gets an SSA definition that has this variable as its underlying
422416
* source variable.

0 commit comments

Comments
 (0)