Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit25e29e4

Browse files
committed
RefineTLoopCounterMutatedInLoopBody
This refined definition can handle more cases than the previous onethat only looked into the loop body, and better matches the descriptionin the comment above.
1 parentd37bc70 commit25e29e4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,9 @@ private newtype TAlertType =
170170
/* 3-1. The loop counter is mutated somewhere other than its update expression. */
171171
TLoopCounterMutatedInLoopBody(ForStmtforLoop,VariableloopCounterVariable){
172172
loopCounterVariable=getDeclaredVariableInForLoop(forLoop)and
173-
variableModifiedInExpression(forLoop.getStmt().getChildStmt().getAChild*(),
174-
loopCounterVariable.getAnAccess())
173+
exists(ExprmutatingExpr|notmutatingExpr=forLoop.getUpdate().getAChild*()|
174+
variableModifiedInExpression(mutatingExpr,loopCounterVariable.getAnAccess())
175+
)
175176
}or
176177
/* 3-2. The loop counter is not updated using either of `++`, `--`, `+=`, or `-=`. */
177178
TLoopCounterUpdatedNotByCrementOrAddSubAssignmentExpr(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp