Skip to content

Commit e15481a

Browse files
authored
Merge pull request #702 from hvitved/csharp/remove-deprecated
C#: Remove deprecated predicates
2 parents 5956341 + edf1df1 commit e15481a

38 files changed

+3
-1425
lines changed

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

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -113,49 +113,6 @@ class AssignableRead extends AssignableAccess {
113113
AssignableRead getAReachableRead() {
114114
result = this.getANextRead+()
115115
}
116-
117-
/**
118-
* Gets a next uncertain read of the same underlying assignable. That is,
119-
* a read that can be reached from this read without passing through any other
120-
* reads, and which *may* read the same value. Example:
121-
*
122-
* ```
123-
* int Field;
124-
*
125-
* void SetField(int i) {
126-
* this.Field = i;
127-
* Use(this.Field);
128-
* if (i > 0)
129-
* this.Field = i - 1;
130-
* else if (i < 0)
131-
* SetField(1);
132-
* Use(this.Field);
133-
* Use(this.Field);
134-
* }
135-
* ```
136-
*
137-
* - The read of `i` on line 6 is next to the read on line 4.
138-
* - The reads of `i` on lines 7 and 8 are next to the read on line 6.
139-
* - The read of `this.Field` on line 10 is next to the read on line 5.
140-
* (This is the only truly uncertain read.)
141-
* - The read of `this.Field` on line 11 is next to the read on line 10.
142-
*/
143-
deprecated
144-
AssignableRead getANextUncertainRead() {
145-
Ssa::Internal::adjacentReadPair(this, result)
146-
}
147-
148-
/**
149-
* Gets a next uncertain read of the same underlying assignable. That is,
150-
* a read that can be reached from this read, and which *may* read the same
151-
* value.
152-
*
153-
* This is the transitive closure of `getANextUncertainRead()`.
154-
*/
155-
deprecated
156-
AssignableRead getAReachableUncertainRead() {
157-
result = this.getANextUncertainRead+()
158-
}
159116
}
160117

161118
/**
@@ -484,10 +441,6 @@ class AssignableDefinition extends TAssignableDefinition {
484441
*/
485442
Expr getExpr() { none() }
486443

487-
/** DEPRECATED: Use `getAControlFlowNode()` instead. */
488-
deprecated
489-
ControlFlow::Node getControlFlowNode() { result = this.getAControlFlowNode() }
490-
491444
/** Gets the enclosing callable of this definition. */
492445
Callable getEnclosingCallable() { result = this.getExpr().getEnclosingCallable() }
493446

@@ -560,56 +513,6 @@ class AssignableDefinition extends TAssignableDefinition {
560513
result = this.getAFirstRead().getANextRead*()
561514
}
562515

563-
/**
564-
* Gets a first uncertain read of the same underlying assignable. That is,
565-
* a read that can be reached from this definition without passing through any
566-
* other reads, and which *may* read the value assigned in this definition.
567-
* Example:
568-
*
569-
* ```
570-
* int Field;
571-
*
572-
* void SetField(int i) {
573-
* this.Field = i;
574-
* Use(this.Field);
575-
* if (i > 0)
576-
* this.Field = i - 1;
577-
* else if (i < 0)
578-
* SetField(1);
579-
* Use(this.Field);
580-
* Use(this.Field);
581-
* }
582-
* ```
583-
*
584-
* - The read of `i` on line 4 is a first read of the implicit parameter definition
585-
* on line 3.
586-
* - The read of `this.Field` on line 5 is a first read of the definition on line 4.
587-
* - The read of `this.Field` on line 10 is a first read of the definition on
588-
* line 7. (This is the only truly uncertain read.)
589-
*
590-
* Subsequent uncertain reads can be found by following the steps defined by
591-
* `AssignableRead.getANextUncertainRead()`.
592-
*/
593-
deprecated
594-
AssignableRead getAFirstUncertainRead() {
595-
exists(Ssa::ExplicitDefinition def |
596-
def.getADefinition() = this |
597-
result = def.getAFirstUncertainRead()
598-
)
599-
}
600-
601-
/**
602-
* Gets a reachable uncertain read of the same underlying assignable. That is,
603-
* a read that can be reached from this definition, and which *may* read the
604-
* value assigned in this definition.
605-
*
606-
* This is the equivalent with `getAFirstUncertainRead().getANextUncertainRead*()`.
607-
*/
608-
deprecated
609-
AssignableRead getAReachableUncertainRead() {
610-
result = this.getAFirstUncertainRead().getANextUncertainRead*()
611-
}
612-
613516
/** Gets a textual representation of this assignable definition. */
614517
string toString() { none() }
615518

csharp/ql/src/semmle/code/csharp/Stmt.qll

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,22 +1190,6 @@ class UsingStmt extends Stmt, @using_stmt {
11901190
/** Gets a local variable declaration of this `using` statement. */
11911191
LocalVariableDeclExpr getAVariableDeclExpr() { result = this.getVariableDeclExpr(_) }
11921192

1193-
/** DEPRECATED: Use `getVariable(0)` instead. */
1194-
deprecated
1195-
LocalVariable getVariable() { result = getVariableDeclExpr().getVariable() }
1196-
1197-
/** DEPRECATED: Use `getAVariableDeclExpr()` instead. */
1198-
deprecated
1199-
LocalVariableDeclExpr getVariableDeclExpr() { result.getParent() = this }
1200-
1201-
/** DEPRECATED: Use `getAnExpr()` instead. */
1202-
deprecated Expr getInitializer() {
1203-
if exists(this.getVariableDeclExpr(0)) then
1204-
result = this.getVariableDeclExpr(0).getInitializer()
1205-
else
1206-
result.getParent() = this
1207-
}
1208-
12091193
/**
12101194
* Gets the expression directly used by this `using` statement, if any. For
12111195
* example, `f` on line 2 in
@@ -1389,14 +1373,6 @@ class FixedStmt extends Stmt, @fixed_stmt {
13891373
/** Gets a local variable declaration of this `fixed` statement. */
13901374
LocalVariableDeclExpr getAVariableDeclExpr() { result = this.getVariableDeclExpr(_) }
13911375

1392-
/** DEPRECATED: Use `getVariable(0)` instead. */
1393-
deprecated
1394-
LocalVariable getVariable() { result = getVariableDeclExpr().getVariable() }
1395-
1396-
/** DEPRECATED: Use `getVariableDeclExpr(0) instead. */
1397-
deprecated
1398-
LocalVariableDeclExpr getVariableDeclExpr() { result.getParent() = this }
1399-
14001376
/** Gets the body of this `fixed` statement. */
14011377
Stmt getBody() { result.getParent() = this }
14021378

@@ -1441,10 +1417,6 @@ class LabeledStmt extends Stmt, @labeled_stmt {
14411417
and result = this.getParent().getChild(i+1))
14421418
}
14431419

1444-
/** DEPRECATED: Use `getStmt()` instead. */
1445-
deprecated
1446-
Stmt getReferredStatement() { result = this.getStmt() }
1447-
14481420
/** Gets the label of this statement. */
14491421
string getLabel() { exprorstmt_name(this, result) }
14501422

csharp/ql/src/semmle/code/csharp/Type.qll

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,6 @@ class ValueOrRefType extends DotNet::ValueOrRefType, Type, Attributable, @value_
134134
result.hasName(name)
135135
}
136136

137-
/**
138-
* DEPRECATED: Use `hasMethod()` instead.
139-
*/
140-
deprecated
141-
predicate inheritsMethod(Method m) { this.hasMethod(m) }
142-
143137
/**
144138
* Holds if this type has method `m`, that is, either `m` is declared in this
145139
* type, or `m` is inherited by this type.
@@ -164,14 +158,6 @@ class ValueOrRefType extends DotNet::ValueOrRefType, Type, Attributable, @value_
164158
*/
165159
predicate hasMethod(Method m) { this.hasMember(m) }
166160

167-
/**
168-
* DEPRECATED: Use `hasCallable()` instead.
169-
*/
170-
deprecated
171-
predicate inheritsCallable(Callable c) {
172-
this.hasCallable(c)
173-
}
174-
175161
/**
176162
* Holds if this type has callable `c`, that is, either `c` is declared in this
177163
* type, or `c` is inherited by this type.
@@ -202,14 +188,6 @@ class ValueOrRefType extends DotNet::ValueOrRefType, Type, Attributable, @value_
202188
hasMember(c.(Accessor).getDeclaration())
203189
}
204190

205-
/**
206-
* DEPRECATED: Use `hasMember()` instead.
207-
*/
208-
deprecated
209-
predicate inheritsMember(Member m) {
210-
this.hasMember(m)
211-
}
212-
213191
/**
214192
* Holds if this type has member `m`, that is, either `m` is declared in this
215193
* type, or `m` is inherited by this type.

csharp/ql/src/semmle/code/csharp/XML.qll

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,6 @@ class XMLParent extends @xmlparent {
7878
result = count(int pos | xmlChars(_,_,this,pos,_,_))
7979
}
8080

81-
/**
82-
* DEPRECATED: Internal.
83-
*
84-
* Append the character sequences of this XML parent from left to right, separated by a space,
85-
* up to a specified (zero-based) index.
86-
*/
87-
deprecated
88-
string charsSetUpTo(int n) {
89-
(n = 0 and xmlChars(_,result,this,0,_,_)) or
90-
(n > 0 and exists(string chars | xmlChars(_,chars,this,n,_,_) |
91-
result = this.charsSetUpTo(n-1) + " " + chars))
92-
}
93-
9481
/** Append all the character sequences of this XML parent from left to right, separated by a space. */
9582
string allCharactersString() {
9683
result = concat(string chars, int pos | xmlChars(_, chars, this, pos, _, _) | chars, " " order by pos)

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

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -758,42 +758,6 @@ module Ssa {
758758
ssaRefRank(bb2, i2, v, _) = 1
759759
}
760760

761-
/**
762-
* Holds if the value defined at non-trivial SSA definition `def` can reach `read`
763-
* without passing through any other read, but possibly through pseudo definitions
764-
* and uncertain definitions.
765-
*/
766-
deprecated
767-
predicate firstUncertainRead(TrackedDefinition def, AssignableRead read) {
768-
firstReadSameVar(def, read)
769-
or
770-
exists(TrackedVar v, TrackedDefinition redef, BasicBlock b1, int i1, BasicBlock b2, int i2 |
771-
redef instanceof UncertainDefinition or redef instanceof PseudoDefinition
772-
|
773-
adjacentVarRefs(v, b1, i1, b2, i2) and
774-
definesAt(def, b1, i1, v) and
775-
definesAt(redef, b2, i2, v) and
776-
firstUncertainRead(redef, read)
777-
)
778-
}
779-
780-
/**
781-
* INTERNAL: Use `AssignableRead.getANextUncertainRead()` instead.
782-
*/
783-
deprecated
784-
predicate adjacentReadPair(AssignableRead read1, AssignableRead read2) {
785-
adjacentReadPairSameVar(read1, read2)
786-
or
787-
exists(TrackedVar v, TrackedDefinition def, BasicBlock bb1, int i1, BasicBlock bb2, int i2 |
788-
adjacentVarRefs(v, bb1, i1, bb2, i2) and
789-
variableRead(bb1, i1, v, read1.getAControlFlowNode(), _) and
790-
definesAt(def, bb2, i2, v) and
791-
firstUncertainRead(def, read2) |
792-
def instanceof UncertainDefinition or
793-
def instanceof PseudoDefinition
794-
)
795-
}
796-
797761
private cached module Cached {
798762
/**
799763
* Holds if `read` is a last read of the non-trivial SSA definition `def`.
@@ -2146,47 +2110,6 @@ module Ssa {
21462110
lastRead(this, result)
21472111
}
21482112

2149-
/**
2150-
* Gets a first uncertain read of the source variable underlying this
2151-
* SSA definition. That is, a read that can be reached from this SSA definition
2152-
* without passing through any other reads or SSA definitions, except for
2153-
* phi nodes and uncertain updates. Example:
2154-
*
2155-
* ```
2156-
* int Field;
2157-
*
2158-
* void SetField(int i) {
2159-
* this.Field = i;
2160-
* Use(this.Field);
2161-
* if (i > 0)
2162-
* this.Field = i - 1;
2163-
* else if (i < 0)
2164-
* SetField(1);
2165-
* Use(this.Field);
2166-
* Use(this.Field);
2167-
* }
2168-
* ```
2169-
*
2170-
* - The read of `i` on line 4 can be reached from the explicit SSA
2171-
* definition (wrapping an implicit entry definition) on line 3.
2172-
* - The reads of `i` on lines 6 and 7 are not the first reads of any SSA
2173-
* definition.
2174-
* - The read of `this.Field` on line 5 can be reached from the explicit SSA
2175-
* definition on line 4.
2176-
* - The read of `this.Field` on line 10 can be reached from the explicit SSA
2177-
* definition on line 7, the implicit SSA definition on line 9, and the phi
2178-
* node between lines 9 and 10.
2179-
* - The read of `this.Field` on line 11 is not the first read of any SSA
2180-
* definition.
2181-
*
2182-
* Subsequent uncertain reads can be found by following the steps defined by
2183-
* `AssignableRead.getANextUncertainRead()`.
2184-
*/
2185-
deprecated
2186-
AssignableRead getAFirstUncertainRead() {
2187-
firstUncertainRead(this, result)
2188-
}
2189-
21902113
/**
21912114
* Gets a definition that ultimately defines this SSA definition and is
21922115
* not itself a pseudo node. Example:
@@ -2459,10 +2382,6 @@ module Ssa {
24592382
)
24602383
}
24612384

2462-
override AssignableRead getAFirstUncertainRead() {
2463-
result = this.getARead()
2464-
}
2465-
24662385
override string toString() {
24672386
result = getToStringPrefix(this) + "SSA untracked def(" + getSourceVariable() + ")"
24682387
}

0 commit comments

Comments
 (0)