File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -102,19 +102,22 @@ module StringOps {
102
102
override boolean getPolarity ( ) { result = expr .getPolarity ( ) }
103
103
}
104
104
105
+ pragma [ noinline]
106
+ private DataFlow:: ElementReadNode getReadOfFirstChar ( DataFlow:: Node str ) {
107
+ pragma [ only_bind_into ] ( result ) .getIndex ( ) .getIntValue ( ) = 0 and
108
+ str = result .getBase ( ) and
109
+ str .getType ( ) .getUnderlyingType ( ) instanceof StringType
110
+ }
111
+
105
112
/**
106
113
* Holds if `eq` is of the form `str[0] == rhs` or `str[0] != rhs`.
107
114
*/
108
115
pragma [ noinline]
109
116
private predicate comparesFirstCharacter (
110
117
DataFlow:: EqualityTestNode eq , DataFlow:: Node str , DataFlow:: Node rhs
111
118
) {
112
- exists ( DataFlow:: ElementReadNode read |
113
- eq .hasOperands ( globalValueNumber ( read ) .getANode ( ) , rhs ) and
114
- str = read .getBase ( ) and
115
- str .getType ( ) .getUnderlyingType ( ) instanceof StringType and
116
- read .getIndex ( ) .getIntValue ( ) = 0
117
- )
119
+ eq .hasOperands ( globalValueNumber ( pragma [ only_bind_out ] ( getReadOfFirstChar ( str ) ) ) .getANode ( ) ,
120
+ rhs )
118
121
}
119
122
120
123
/**
You can’t perform that action at this time.
0 commit comments