1+ /**
2+ * Provides classes for loop iteration variables.
3+ */
4+
15import semmle.code.cpp.Variable
26
37/**
@@ -7,14 +11,18 @@ import semmle.code.cpp.Variable
711class LoopCounter extends Variable {
812 LoopCounter ( ) { exists ( ForStmt f | f .getAnIterationVariable ( ) = this ) }
913
10- // Gets an access of this variable within loop `f`.
14+ /**
15+ * Gets an access of this variable within loop `f`.
16+ */
1117 VariableAccess getVariableAccessInLoop ( ForStmt f ) {
1218 this .getALoop ( ) = f and
1319 result .getEnclosingStmt ( ) .getParent * ( ) = f and
1420 this = result .getTarget ( )
1521 }
1622
17- // Gets a loop which uses this variable as its counter.
23+ /**
24+ * Gets a loop which uses this variable as its counter.
25+ */
1826 ForStmt getALoop ( ) { result .getAnIterationVariable ( ) = this }
1927}
2028
@@ -25,14 +33,18 @@ class LoopCounter extends Variable {
2533class LoopControlVariable extends Variable {
2634 LoopControlVariable ( ) { this = loopControlVariable ( _) }
2735
28- // Gets an access of this variable within loop `f`.
36+ /**
37+ * Gets an access of this variable within loop `f`.
38+ */
2939 VariableAccess getVariableAccessInLoop ( ForStmt f ) {
3040 this .getALoop ( ) = f and
3141 result .getEnclosingStmt ( ) .getParent * ( ) = f and
3242 this = result .getTarget ( )
3343 }
3444
35- // Gets a loop which uses this variable as its control variable.
45+ /**
46+ * Gets a loop which uses this variable as its control variable.
47+ */
3648 ForStmt getALoop ( ) { this = loopControlVariable ( result ) }
3749}
3850
0 commit comments