Skip to content

Commit 032c7ea

Browse files
committed
C++: Include the actual number of lower/upper bounds for added context in expected files
1 parent da527ff commit 032c7ea

File tree

3 files changed

+5256
-5234
lines changed

3 files changed

+5256
-5234
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,16 @@ module SimpleRangeAnalysisInternal {
21802180

21812181
/** Gets the estimate of the number of bounds for `e`. */
21822182
float estimateNrOfBounds(Expr e) { result = BoundsEstimate::nrOfBoundsExpr(e) }
2183+
2184+
/** Counts the numbers of lower bounds that are computed internally for `e`. */
2185+
float countNrOfLowerBounds(Expr e) {
2186+
result = strictcount(float lb | lb = getLowerBoundsImpl(e) | lb)
2187+
}
2188+
2189+
/** Counts the numbers of upper bounds that are computed internally for `e`. */
2190+
float countNrOfUpperBounds(Expr e) {
2191+
result = strictcount(float ub | ub = getUpperBoundsImpl(e) | ub)
2192+
}
21832193
}
21842194

21852195
/** Provides predicates for debugging the simple range analysis library. */
@@ -2208,7 +2218,7 @@ private module Debug {
22082218
*/
22092219
predicate countGetLowerBoundsImpl(Expr e, int n) {
22102220
e = getRelevantLocatable() and
2211-
n = strictcount(float lb | lb = getLowerBoundsImpl(e) | lb)
2221+
n = SimpleRangeAnalysisInternal::countNrOfLowerBounds(e)
22122222
}
22132223

22142224
float debugNrOfBounds(Expr e) {

0 commit comments

Comments
 (0)