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 {
102102 override boolean getPolarity ( ) { result = expr .getPolarity ( ) }
103103 }
104104
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+
105112 /**
106113 * Holds if `eq` is of the form `str[0] == rhs` or `str[0] != rhs`.
107114 */
108115 pragma [ noinline]
109116 private predicate comparesFirstCharacter (
110117 DataFlow:: EqualityTestNode eq , DataFlow:: Node str , DataFlow:: Node rhs
111118 ) {
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 )
118121 }
119122
120123 /**
You can’t perform that action at this time.
0 commit comments