@@ -17,34 +17,32 @@ import semmle.code.csharp.controlflow.Guards
1717import semmle.code.csharp.commons.ComparisonTest
1818
1919/** A comparison of an index variable with the length of an array. */
20- class IndexGuard extends Expr {
21- ComparisonTest ct ;
20+ class IndexGuard extends ComparisonTest {
2221 VariableAccess indexAccess ;
2322 Variable array ;
2423
2524 IndexGuard ( ) {
26- ct .getExpr ( ) = this and
27- ct .getFirstArgument ( ) = indexAccess and
28- ct .getSecondArgument ( ) = any ( PropertyAccess lengthAccess |
25+ this .getFirstArgument ( ) = indexAccess and
26+ this .getSecondArgument ( ) = any ( PropertyAccess lengthAccess |
2927 lengthAccess .getQualifier ( ) = array .getAnAccess ( ) and
3028 lengthAccess .getTarget ( ) .hasName ( "Length" )
3129 )
3230 }
3331
34- /** This comparison applies to array `arr` and index `ind`. */
32+ /** Holds if this comparison applies to array `arr` and index `ind`. */
3533 predicate controls ( Variable arr , Variable ind ) {
3634 arr = array and
3735 ind .getAnAccess ( ) = indexAccess
3836 }
3937
40- /** This comparison guards `expr`. */
38+ /** Holds if this comparison guards `expr`. */
4139 predicate guards ( GuardedExpr expr , boolean condition ) {
42- expr .isGuardedBy ( this , indexAccess , condition )
40+ expr .isGuardedBy ( this . getExpr ( ) , indexAccess , condition )
4341 }
4442
45- /** This comparison is an incorrect `<=` or equivalent. */
43+ /** Holds if this comparison is an incorrect `<=` or equivalent. */
4644 predicate isIncorrect ( ) {
47- ct .getComparisonKind ( ) .isLessThanEquals ( )
45+ this .getComparisonKind ( ) .isLessThanEquals ( )
4846 }
4947}
5048
0 commit comments