C++: Add number of bounds test to simple range analysis

This commit is contained in:
Simon Friis Vindum
2025-10-15 13:32:05 +02:00
parent 7eacd87343
commit 8896a7210b
3 changed files with 4580 additions and 0 deletions

View File

@@ -2140,4 +2140,7 @@ module SimpleRangeAnalysisInternal {
// bound is `typeUpperBound`. // bound is `typeUpperBound`.
defMightOverflowNegatively(def, v) and result = varMaxVal(v) defMightOverflowNegatively(def, v) and result = varMaxVal(v)
} }
/** Gets the estimate of the number of bounds for `e`. */
float estimateNrOfBounds(Expr e) { result = BoundsEstimate::nrOfBoundsExpr(e) }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
import cpp
import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
from Expr e
select e, SimpleRangeAnalysisInternal::estimateNrOfBounds(e)