@@ -31,28 +31,28 @@ private predicate stringConstCompare(CfgNodes::AstCfgNode guard, CfgNode testedN
3131 or
3232 stringConstCaseCompare ( guard , testedNode , branch )
3333 or
34- exists ( Ssa :: Definition def , CfgNodes:: ExprNodes:: BinaryOperationCfgNode g |
34+ exists ( CfgNodes:: ExprNodes:: BinaryOperationCfgNode g |
3535 g = guard and
36- stringConstCompareOr ( guard , def , branch ) and
36+ stringConstCompareOr ( guard , branch ) and
3737 stringConstCompare ( g .getLeftOperand ( ) , testedNode , _)
3838 )
3939}
4040
4141/**
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.
4343 * For example:
4444 *
4545 * ```rb
4646 * x == "foo" or x == "bar"
4747 * ```
4848 */
4949private predicate stringConstCompareOr (
50- CfgNodes:: ExprNodes:: BinaryOperationCfgNode guard , Ssa :: Definition def , boolean branch
50+ CfgNodes:: ExprNodes:: BinaryOperationCfgNode guard , boolean branch
5151) {
5252 guard .getExpr ( ) instanceof LogicalOrExpr and
5353 branch = true and
5454 forall ( CfgNode innerGuard | innerGuard = guard .getAnOperand ( ) |
55- stringConstCompare ( innerGuard , def .getARead ( ) , branch )
55+ stringConstCompare ( innerGuard , any ( Ssa :: Definition def ) .getARead ( ) , branch )
5656 )
5757}
5858
@@ -190,34 +190,35 @@ private predicate stringConstCaseCompare(
190190 exists ( CfgNodes:: ExprNodes:: CaseExprCfgNode case |
191191 case .getValue ( ) = testedNode and
192192 (
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
209201 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+ )
216219 )
217- )
218220 )
219221 )
220- )
221222 or
222223 // in "foo"
223224 exists (
0 commit comments