@@ -49,6 +49,20 @@ private predicate inForUpdate(Expr forUpdate, Expr child) {
49
49
exists ( Expr mid | inForUpdate ( forUpdate , mid ) and child .getParent ( ) = mid )
50
50
}
51
51
52
+ class MemberCrementOperation extends FunctionCall {
53
+ MemberCrementOperation ( ) { this .getTarget ( ) instanceof UserCrementOperator }
54
+
55
+ Expr getOperand ( ) { result = this .getQualifier ( ) }
56
+ }
57
+
58
+ class MemberAssignmentOperation extends FunctionCall {
59
+ MemberAssignmentOperation ( ) { this .getTarget ( ) instanceof AssignmentOperator }
60
+
61
+ Expr getLValue ( ) { result = this .getQualifier ( ) }
62
+
63
+ string getOperator ( ) { result = this .getTarget ( ) .getName ( ) .regexpCapture ( "operator(.+)" , 1 ) }
64
+ }
65
+
52
66
/**
53
67
* Gets a LoopCounter for the given `ForStmt`.
54
68
*
@@ -68,6 +82,21 @@ Variable getALoopCounter(ForStmt fs) {
68
82
va = result .getAnAccess ( )
69
83
)
70
84
or
85
+ exists ( MemberCrementOperation op , VariableAccess va |
86
+ op = updateOp and
87
+ op instanceof MemberCrementOperation and
88
+ op .getOperand ( ) = va and
89
+ va = result .getAnAccess ( )
90
+ )
91
+ or
92
+ exists ( MemberAssignmentOperation op , VariableAccess va |
93
+ op = updateOp and
94
+ op instanceof MemberAssignmentOperation and
95
+ op .getOperator ( ) = [ "+=" , "-=" ] and
96
+ op .getLValue ( ) = va and
97
+ va = result .getAnAccess ( )
98
+ )
99
+ or
71
100
exists ( AssignArithmeticOperation op , VariableAccess va |
72
101
op = updateOp and
73
102
op instanceof AssignArithmeticOperation and
0 commit comments