C#: Rename CollectionExpr to EnumerableCollectionExpr.

This commit is contained in:
Michael Nebel
2024-01-24 15:24:17 +01:00
parent 5ab64f4a65
commit 1252d3ee89
3 changed files with 14 additions and 6 deletions

View File

@@ -480,12 +480,17 @@ class DereferenceableExpr extends Expr {
}
}
/**
* DEPRECATED: Use `EnumerableCollectionExpr` instead.
*/
deprecated class CollectionExpr = EnumerableCollectionExpr;
/**
* An expression that evaluates to a collection. That is, an expression whose
* (transitive, reflexive) base type is `IEnumerable`.
*/
class CollectionExpr extends Expr {
CollectionExpr() {
class EnumerableCollectionExpr extends Expr {
EnumerableCollectionExpr() {
this.getType().(ValueOrRefType).getABaseType*() instanceof SystemCollectionsIEnumerableInterface
}
@@ -1431,7 +1436,7 @@ module Internal {
or
val.branch(_, _, e)
or
e instanceof CollectionExpr and
e instanceof EnumerableCollectionExpr and
val = TEmptyCollectionValue(_)
) and
not e = any(ExprStmt es).getExpr() and
@@ -1570,7 +1575,9 @@ module Internal {
(g1 != g2 or v1 != v2)
)
or
exists(boolean isEmpty | g1 = g2.(CollectionExpr).getAnEmptinessCheck(v1, isEmpty) |
exists(boolean isEmpty |
g1 = g2.(EnumerableCollectionExpr).getAnEmptinessCheck(v1, isEmpty)
|
v2 =
any(EmptyCollectionValue ecv | if ecv.isEmpty() then isEmpty = true else isEmpty = false) and
g1 != g2

View File

@@ -1162,7 +1162,8 @@ module LoopSplitting {
/** Holds if `ce` is guarded by a (non-)empty check, as specified by `v`. */
private predicate emptinessGuarded(
Guards::Guard g, Guards::CollectionExpr ce, Guards::AbstractValues::EmptyCollectionValue v
Guards::Guard g, Guards::EnumerableCollectionExpr ce,
Guards::AbstractValues::EmptyCollectionValue v
) {
exists(PreBasicBlock bb | Guards::Internal::preControls(g, bb, v) |
PreSsa::adjacentReadPairSameVar(g, ce) and

View File

@@ -2,7 +2,7 @@ import csharp
private import semmle.code.csharp.controlflow.Guards
query predicate emptinessCheck(
Expr check, CollectionExpr collection, AbstractValue v, boolean isEmpty
Expr check, EnumerableCollectionExpr collection, AbstractValue v, boolean isEmpty
) {
check = collection.getAnEmptinessCheck(v, isEmpty)
}