Skip to content

Commit 5fa02d6

Browse files
committed
Un-inline parseAsBigInt
1 parent 78e8de4 commit 5fa02d6

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

cpp/ql/lib/semmle/code/cpp/rangeanalysis/RangeAnalysisUtils.qll

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -484,18 +484,20 @@ QlBuiltins::BigInt varMaxVal(Variable v) { result = typeUpperBound(v.getUnspecif
484484
*/
485485
QlBuiltins::BigInt infinityAsBigInt() { result = 1.toBigInt().bitShiftLeft(1024) }
486486

487-
bindingset[s]
488487
QlBuiltins::BigInt parseAsBigInt(string s) {
489-
result = s.toBigInt()
490-
or
491-
s.toFloat() = 1.0 / 0.0 and result = infinityAsBigInt()
492-
or
493-
s.toFloat() = -(1.0 / 0.0) and result = -infinityAsBigInt()
494-
or
495-
exists(QlBuiltins::BigInt coeff, int base10exp | parseFiniteAsBigInt(s, coeff, base10exp) |
496-
if base10exp < 0
497-
then result = coeff / 10.toBigInt().pow(-base10exp)
498-
else result = coeff * 10.toBigInt().pow(base10exp)
488+
s = any(Expr e).getValue() and
489+
(
490+
result = s.toBigInt()
491+
or
492+
s.toFloat() = 1.0 / 0.0 and result = infinityAsBigInt()
493+
or
494+
s.toFloat() = -(1.0 / 0.0) and result = -infinityAsBigInt()
495+
or
496+
exists(QlBuiltins::BigInt coeff, int base10exp | parseFiniteAsBigInt(s, coeff, base10exp) |
497+
if base10exp < 0
498+
then result = coeff / 10.toBigInt().pow(-base10exp)
499+
else result = coeff * 10.toBigInt().pow(base10exp)
500+
)
499501
)
500502
}
501503

0 commit comments

Comments
 (0)