C++: Include the actual number of lower/upper bounds for added context in expected files

This commit is contained in:
Simon Friis Vindum
2026-02-16 13:51:08 +01:00
parent da527ffc19
commit 032c7ea034
3 changed files with 5256 additions and 5234 deletions

View File

@@ -2,8 +2,20 @@ import cpp
import utils.test.InlineExpectationsTest
import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
query predicate estimateNrOfBounds(Expr e, float nrOfBounds) {
nrOfBounds = SimpleRangeAnalysisInternal::estimateNrOfBounds(e)
query predicate estimateNrOfBounds(
Expr e, float nrOfBounds, float actualNrOfLowerBounds, float actualNrOfUpperBounds
) {
nrOfBounds = SimpleRangeAnalysisInternal::estimateNrOfBounds(e) and
(
actualNrOfLowerBounds = SimpleRangeAnalysisInternal::countNrOfLowerBounds(e)
or
not exists(SimpleRangeAnalysisInternal::countNrOfLowerBounds(e)) and actualNrOfLowerBounds = -1
) and
(
actualNrOfUpperBounds = SimpleRangeAnalysisInternal::countNrOfUpperBounds(e)
or
not exists(SimpleRangeAnalysisInternal::countNrOfUpperBounds(e)) and actualNrOfUpperBounds = -1
)
}
/**