@@ -31,28 +31,28 @@ private predicate stringConstCompare(CfgNodes::AstCfgNode guard, CfgNode testedN
31
31
or
32
32
stringConstCaseCompare ( guard , testedNode , branch )
33
33
or
34
- exists ( Ssa :: Definition def , CfgNodes:: ExprNodes:: BinaryOperationCfgNode g |
34
+ exists ( CfgNodes:: ExprNodes:: BinaryOperationCfgNode g |
35
35
g = guard and
36
- stringConstCompareOr ( guard , def , branch ) and
36
+ stringConstCompareOr ( guard , branch ) and
37
37
stringConstCompare ( g .getLeftOperand ( ) , testedNode , _)
38
38
)
39
39
}
40
40
41
41
/**
42
- * Holds if `guard` is an `or` expression whose operands are string comparison guards that test `def` .
42
+ * Holds if `guard` is an `or` expression whose operands are string comparison guards.
43
43
* For example:
44
44
*
45
45
* ```rb
46
46
* x == "foo" or x == "bar"
47
47
* ```
48
48
*/
49
49
private predicate stringConstCompareOr (
50
- CfgNodes:: ExprNodes:: BinaryOperationCfgNode guard , Ssa :: Definition def , boolean branch
50
+ CfgNodes:: ExprNodes:: BinaryOperationCfgNode guard , boolean branch
51
51
) {
52
52
guard .getExpr ( ) instanceof LogicalOrExpr and
53
53
branch = true and
54
54
forall ( CfgNode innerGuard | innerGuard = guard .getAnOperand ( ) |
55
- stringConstCompare ( innerGuard , def .getARead ( ) , branch )
55
+ stringConstCompare ( innerGuard , any ( Ssa :: Definition def ) .getARead ( ) , branch )
56
56
)
57
57
}
58
58
@@ -190,34 +190,35 @@ private predicate stringConstCaseCompare(
190
190
exists ( CfgNodes:: ExprNodes:: CaseExprCfgNode case |
191
191
case .getValue ( ) = testedNode and
192
192
(
193
- exists ( CfgNodes:: ExprNodes:: WhenClauseCfgNode branchNode |
194
- guard = branchNode and
195
- branchNode = case .getBranch ( _) and
196
- // For simplicity, consider patterns that contain only string literals or arrays of string literals
197
- forall ( ExprCfgNode pattern | pattern = branchNode .getPattern ( _) |
198
- // when "foo"
199
- // when "foo", "bar"
200
- pattern instanceof ExprNodes:: StringLiteralCfgNode
201
- or
202
- exists ( CfgNodes:: ExprNodes:: SplatExprCfgNode splat | splat = pattern |
203
- // when *["foo", "bar"]
204
- forex ( ExprCfgNode elem |
205
- elem = splat .getOperand ( ) .( ExprNodes:: ArrayLiteralCfgNode ) .getAnArgument ( )
206
- |
207
- elem instanceof ExprNodes:: StringLiteralCfgNode
208
- )
193
+ guard =
194
+ any ( CfgNodes:: ExprNodes:: WhenClauseCfgNode branchNode |
195
+ branchNode = case .getBranch ( _) and
196
+ // For simplicity, consider patterns that contain only string literals or arrays of string literals
197
+ forall ( ExprCfgNode pattern | pattern = branchNode .getPattern ( _) |
198
+ // when "foo"
199
+ // when "foo", "bar"
200
+ pattern instanceof ExprNodes:: StringLiteralCfgNode
209
201
or
210
- // when *some_var
211
- // when *SOME_CONST
212
- exists ( ExprNodes:: ArrayLiteralCfgNode arr |
213
- isArrayConstant ( splat .getOperand ( ) , arr ) and
214
- forall ( ExprCfgNode elem | elem = arr .getAnArgument ( ) |
215
- elem instanceof ExprNodes:: StringLiteralCfgNode
202
+ pattern =
203
+ any ( CfgNodes:: ExprNodes:: SplatExprCfgNode splat |
204
+ // when *["foo", "bar"]
205
+ forex ( ExprCfgNode elem |
206
+ elem = splat .getOperand ( ) .( ExprNodes:: ArrayLiteralCfgNode ) .getAnArgument ( )
207
+ |
208
+ elem instanceof ExprNodes:: StringLiteralCfgNode
209
+ )
210
+ or
211
+ // when *some_var
212
+ // when *SOME_CONST
213
+ exists ( ExprNodes:: ArrayLiteralCfgNode arr |
214
+ isArrayConstant ( splat .getOperand ( ) , arr ) and
215
+ forall ( ExprCfgNode elem | elem = arr .getAnArgument ( ) |
216
+ elem instanceof ExprNodes:: StringLiteralCfgNode
217
+ )
218
+ )
216
219
)
217
- )
218
220
)
219
221
)
220
- )
221
222
or
222
223
// in "foo"
223
224
exists (
0 commit comments