@@ -85,6 +85,21 @@ Expr getLoopStepOfForStmt(ForStmt forLoop) {
85
85
result = forLoop .getUpdate ( ) .( AssignSubExpr ) .getRValue ( )
86
86
}
87
87
88
+ /**
89
+ * Holds if either of the following holds for the given variable access:
90
+ * 1. Another variable access of the same variable as the given variable access is taken an
91
+ * address and is assigned to a non-const pointer variable, i.e. initialization, assignment,
92
+ * and pass-by-value.
93
+ * 2. Another variable access of the same variable as the given variable access is assigned
94
+ * to a non-const reference variable (thus constituting a `T` -> `&T` conversion.), i.e.
95
+ * initialization and assignment.
96
+ */
97
+ /*
98
+ * Note that pass-by-reference is dealt with in a different predicate named
99
+ * `loopVariablePassedAsArgumentToNonConstReferenceParameter`, due to implementation
100
+ * limitations.
101
+ */
102
+
88
103
predicate loopVariableAssignedToNonConstPointerOrReferenceType (
89
104
ForStmt forLoop , VariableAccess loopVariableAccessInCondition
90
105
) {
@@ -121,6 +136,11 @@ predicate loopVariableAssignedToNonConstPointerOrReferenceType(
121
136
* Also, this predicate requires that the call is the body of the given for-loop.
122
137
*/
123
138
139
+ /**
140
+ * Holds if the given variable access has another variable access with the same target
141
+ * variable that is passed as reference to a non-const reference parameter of a function,
142
+ * constituting a `T` -> `&T` conversion.
143
+ */
124
144
predicate loopVariablePassedAsArgumentToNonConstReferenceParameter (
125
145
ForStmt forLoop , VariableAccess loopVariableAccessInCondition
126
146
) {
0 commit comments