Skip to content

Commit 1355eff

Browse files
committed
Use upperbound/0 and getFullyConverted/0 to more precisely infer sizes
1 parent 1f8083a commit 1355eff

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

‎cpp/misra/src/rules/RULE-9-5-1/LegacyForStatementsShouldBeSimple.ql‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,10 @@ private newtype TAlertType =
185185
/* 4. The type size of the loop counter is smaller than that of the loop bound. */
186186
TLoopCounterSmallerThanLoopBound(ForStmtforLoop,LegacyForLoopConditionforLoopCondition){
187187
forLoopCondition=forLoop.getCondition()and
188-
exists(TypeloopCounterType,TypeloopBoundType|
189-
loopCounterType=forLoopCondition.getLoopCounter().getType()and
190-
loopBoundType=forLoopCondition.getLoopBound().getType()
191-
|
192-
loopCounterType.getSize()<loopBoundType.getSize()
188+
exists(ExprloopCounter,ExprloopBound|
189+
loopCounter=forLoopCondition.getLoopCounter()and
190+
loopBound=forLoopCondition.getLoopBound()and
191+
upperBound(loopCounter.getFullyConverted())<upperBound(loopBound.getFullyConverted())
193192
)
194193
}or
195194
/* 5-1-1. The loop bound is a variable that is mutated in the for loop. */

0 commit comments

Comments
(0)