Skip to content

Commit 1252d3e

Browse files
committed
C#: Rename CollectionExpr to EnumerableCollectionExpr.
1 parent 5ab64f4 commit 1252d3e

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,12 +480,17 @@ class DereferenceableExpr extends Expr {
480480
}
481481
}
482482

483+
/**
484+
* DEPRECATED: Use `EnumerableCollectionExpr` instead.
485+
*/
486+
deprecated class CollectionExpr = EnumerableCollectionExpr;
487+
483488
/**
484489
* An expression that evaluates to a collection. That is, an expression whose
485490
* (transitive, reflexive) base type is `IEnumerable`.
486491
*/
487-
class CollectionExpr extends Expr {
488-
CollectionExpr() {
492+
class EnumerableCollectionExpr extends Expr {
493+
EnumerableCollectionExpr() {
489494
this.getType().(ValueOrRefType).getABaseType*() instanceof SystemCollectionsIEnumerableInterface
490495
}
491496

@@ -1431,7 +1436,7 @@ module Internal {
14311436
or
14321437
val.branch(_, _, e)
14331438
or
1434-
e instanceof CollectionExpr and
1439+
e instanceof EnumerableCollectionExpr and
14351440
val = TEmptyCollectionValue(_)
14361441
) and
14371442
not e = any(ExprStmt es).getExpr() and
@@ -1570,7 +1575,9 @@ module Internal {
15701575
(g1 != g2 or v1 != v2)
15711576
)
15721577
or
1573-
exists(boolean isEmpty | g1 = g2.(CollectionExpr).getAnEmptinessCheck(v1, isEmpty) |
1578+
exists(boolean isEmpty |
1579+
g1 = g2.(EnumerableCollectionExpr).getAnEmptinessCheck(v1, isEmpty)
1580+
|
15741581
v2 =
15751582
any(EmptyCollectionValue ecv | if ecv.isEmpty() then isEmpty = true else isEmpty = false) and
15761583
g1 != g2

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,8 @@ module LoopSplitting {
11621162

11631163
/** Holds if `ce` is guarded by a (non-)empty check, as specified by `v`. */
11641164
private predicate emptinessGuarded(
1165-
Guards::Guard g, Guards::CollectionExpr ce, Guards::AbstractValues::EmptyCollectionValue v
1165+
Guards::Guard g, Guards::EnumerableCollectionExpr ce,
1166+
Guards::AbstractValues::EmptyCollectionValue v
11661167
) {
11671168
exists(PreBasicBlock bb | Guards::Internal::preControls(g, bb, v) |
11681169
PreSsa::adjacentReadPairSameVar(g, ce) and

csharp/ql/test/library-tests/controlflow/guards/Collections.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import csharp
22
private import semmle.code.csharp.controlflow.Guards
33

44
query predicate emptinessCheck(
5-
Expr check, CollectionExpr collection, AbstractValue v, boolean isEmpty
5+
Expr check, EnumerableCollectionExpr collection, AbstractValue v, boolean isEmpty
66
) {
77
check = collection.getAnEmptinessCheck(v, isEmpty)
88
}

0 commit comments

Comments
 (0)