Skip to content

Commit 270dbd2

Browse files
committed
C++: Revert peer review suggestion.
The suggested change has a severe impact on row counts, as cpp does not cache the results for `bbDominates`. Since the `getGuardedUpperBound` predicate the cost of runtime complexity is considered higher than the benefit of this change.
1 parent 6c44b0e commit 270dbd2

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,13 +1546,8 @@ private float getGuardedUpperBound(VariableAccess guardedAccess) {
15461546
// node is attached to the block at the end of the edge and not on
15471547
// the actual edge. It is therefore not possible to determine which
15481548
// edge the guard phi node belongs to. The predicate below ensures
1549-
// that any predecessor other than the guard block is dominated by the
1550-
// guard phi node.
1551-
forall(BasicBlock pred |
1552-
pred = def.(BasicBlock).getAPredecessor() and pred != guard.getBasicBlock()
1553-
|
1554-
bbDominates(def, pred)
1555-
) and
1549+
// that there is one predecessor, albeit somewhat conservative.
1550+
exists(unique(BasicBlock b | b = def.(BasicBlock).getAPredecessor())) and
15561551
guardedAccess = def.getAUse(v) and
15571552
result = max(float ub | upperBoundFromGuard(guard, guardVa, ub, branch))
15581553
)

cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/upperBound.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@
598598
| test.c:671:9:671:9 | y | 2147483647 |
599599
| test.c:675:7:675:7 | y | 2147483647 |
600600
| test.c:684:7:684:7 | x | 2147483647 |
601-
| test.c:689:7:689:7 | x | 9 |
601+
| test.c:689:7:689:7 | x | 15 |
602602
| test.cpp:10:7:10:7 | b | 2147483647 |
603603
| test.cpp:11:5:11:5 | x | 2147483647 |
604604
| test.cpp:13:10:13:10 | x | 2147483647 |

0 commit comments

Comments
 (0)