Skip to content

Commit 33222ae

Browse files
committed
Debug loopVariableAssignedToNonConstPointOrReferenceType
This is to cover the cases where the pointers are constant but the data behind it can be mutated through it.
1 parent 2aed0f1 commit 33222ae

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ predicate loopVariableAssignedToNonConstPointerOrReferenceType(
9090
strippedType = targetType.stripTopLevelSpecifiers() and
9191
not strippedType.getBaseType().isConst() and
9292
(
93-
targetType instanceof PointerType or
94-
targetType instanceof ReferenceType
93+
strippedType instanceof PointerType or
94+
strippedType instanceof ReferenceType
9595
)
9696
|
9797
assignmentRhs.getEnclosingStmt().getParent*() = forLoop.getStmt() and
@@ -118,7 +118,7 @@ predicate loopVariableAssignedToNonConstPointerOrReferenceType(
118118
* This predicate adds two constraints to the target type, as compared to the original
119119
* portion of the predicate:
120120
*
121-
* 1. This predicate adds type constraint that the target type is a `ReferenceType`.
121+
* 1. This predicate adds a type constraint that the target type is a `ReferenceType`.
122122
* 2. This predicate adds the constraint that the target type is not `const`.
123123
*
124124
* Also, this predicate requires that the call is the body of the given for-loop.

0 commit comments

Comments
 (0)