Skip to content

Commit 8878498

Browse files
committed
JS: Replace 'if p() then q() else none()' with a conjunction.
1 parent 7690625 commit 8878498

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

javascript/ql/lib/semmle/javascript/RangeAnalysis.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,9 @@ module RangeAnalysis {
236236
) {
237237
if exists(r.getImmediatePredecessor())
238238
then linearDefinitionSum(r.getImmediatePredecessor(), xroot, xsign, yroot, ysign, bias)
239-
else
240-
if exists(r.asExpr().getIntValue())
241-
then none() // do not model constants as sums
242-
else (
239+
else (
240+
not exists(r.asExpr().getIntValue()) and // do not model constants as sums
241+
(
243242
exists(AddExpr add, int bias1, int bias2 | r.asExpr() = add |
244243
// r = r1 + r2
245244
linearDefinition(add.getLeftOperand().flow(), xroot, xsign, bias1) and
@@ -257,6 +256,7 @@ module RangeAnalysis {
257256
linearDefinitionSum(r.asExpr().(NegExpr).getOperand().flow(), xroot, -xsign, yroot, -ysign,
258257
-bias)
259258
)
259+
)
260260
}
261261

262262
/**

0 commit comments

Comments
 (0)