Avoid bad join in compatibleTypesCached

This is identical to the code in Ruby and seems to prevent a bad join ordering
in a cached version of this predicate in DataFlowCommon
This commit is contained in:
Asger F
2024-06-25 15:27:30 +02:00
parent fc7c2c5b17
commit 88edc06517

View File

@@ -373,13 +373,19 @@ predicate neverSkipInPathGraph(Node node) {
string ppReprType(DataFlowType t) { none() }
pragma[inline]
private predicate compatibleTypesNonSymRefl(DataFlowType t1, DataFlowType t2) {
t1 != TAnyType() and
t2 = TAnyType()
}
pragma[inline]
predicate compatibleTypes(DataFlowType t1, DataFlowType t2) {
t1 = t2
or
t1 instanceof TAnyType and exists(t2)
compatibleTypesNonSymRefl(t1, t2)
or
t2 instanceof TAnyType and exists(t1)
compatibleTypesNonSymRefl(t2, t1)
}
predicate forceHighPrecision(Content c) { none() }