mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Support to keep bounds derived on implicit integer casts.
This commit is contained in:
@@ -187,6 +187,13 @@ private predicate boundFlowStepSsa(
|
||||
guard.controls(op2.getUse().getBlock(), testIsTrue) and
|
||||
reason = TCondReason(guard)
|
||||
)
|
||||
or
|
||||
exists(IRGuardCondition guard, boolean testIsTrue, SafeCastInstruction cast |
|
||||
valueNumberOfOperand(op2) = valueNumber(cast.getUnary()) and
|
||||
guard = boundFlowCond(valueNumber(cast), op1, delta, upper, testIsTrue) and
|
||||
guard.controls(op2.getUse().getBlock(), testIsTrue) and
|
||||
reason = TCondReason(guard)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -192,3 +192,19 @@ int test16(int i) {
|
||||
long l;
|
||||
l = i;
|
||||
}
|
||||
|
||||
// implicit integer casts
|
||||
void test17(int i, long l) {
|
||||
if (i < l) {
|
||||
sink(i);
|
||||
}
|
||||
if (i < l - 2) {
|
||||
sink (i);
|
||||
}
|
||||
}
|
||||
|
||||
void test18(int x, int y) {
|
||||
if (x < y - 2) {
|
||||
sink(x);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user