Skip to content

Commit b0cb654

Browse files
committed
C++: Add range analysis for unary minus.
1 parent 4cb5bea commit b0cb654

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cpp/ql/lib/experimental/semmle/code/cpp/semantic/analysis/RangeAnalysisStage.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,15 @@ module RangeStage<DeltaSig D, BoundSig<D> Bounds, LangSig<D> LangParam, UtilSig<
10201020
or
10211021
upper = false and delta = D::fromFloat(D::toFloat(d1).minimum(D::toFloat(d2)))
10221022
)
1023+
or
1024+
exists(SemExpr mid, D::Delta d, float f |
1025+
e.(SemNegateExpr).getOperand() = mid and
1026+
b instanceof SemZeroBound and
1027+
bounded(mid, b, d, upper.booleanNot(), fromBackEdge, origdelta, reason) and
1028+
f = -D::toFloat(d) and
1029+
delta = D::fromFloat(f) and
1030+
if semPositive(e) then f >= 0 else any()
1031+
)
10231032
)
10241033
}
10251034

0 commit comments

Comments
 (0)