Skip to content

Commit 96c1b5b

Browse files
committed
C#: Enable type strengthening.
1 parent e8cea79 commit 96c1b5b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,21 @@ private class DataFlowUnknownType extends DataFlowType {
19841984
DataFlowUnknownType() { this = Gvn::getGlobalValueNumber(any(UnknownType ut)) }
19851985
}
19861986

1987+
private predicate uselessTypebound(DataFlowType t) {
1988+
t instanceof DataFlowUnknownType or
1989+
t instanceof Gvn::TypeParameterGvnType
1990+
}
1991+
1992+
pragma[nomagic]
1993+
predicate typeStrongerThan(DataFlowType t1, DataFlowType t2) {
1994+
t1 != t2 and
1995+
t1 = getANonTypeParameterSubTypeRestricted(t2)
1996+
or
1997+
t1 instanceof RelevantDataFlowType and
1998+
not uselessTypebound(t1) and
1999+
uselessTypebound(t2)
2000+
}
2001+
19872002
/**
19882003
* Holds if `t1` and `t2` are compatible, that is, whether data can flow from
19892004
* a node of type `t1` to a node of type `t2`.

0 commit comments

Comments
 (0)