File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -866,15 +866,19 @@ module ExprNodes {
866866 final override RelationalOperation getExpr ( ) { result = super .getExpr ( ) }
867867 }
868868
869+ private class SplatExprChildMapping extends ExprChildMapping , SplatExpr {
870+ override predicate relevantChild ( AstNode n ) { n = this .getOperand ( ) }
871+ }
872+
869873 /** A control-flow node that wraps a `SplatExpr` AST expression. */
870874 class SplatExprCfgNode extends ExprCfgNode {
871875 override string getAPrimaryQlClass ( ) { result = "SplatExprCfgNode" }
872876
873- SplatExprCfgNode ( ) { e instanceof SplatExpr }
877+ override SplatExprChildMapping e ;
874878
875879 final override SplatExpr getExpr ( ) { result = super .getExpr ( ) }
876880
877- final ExprCfgNode getOperand ( ) { result . getExpr ( ) = e . ( SplatExpr ) . getOperand ( ) }
881+ final ExprCfgNode getOperand ( ) { e . hasCfgChild ( e . getOperand ( ) , this , result ) }
878882 }
879883
880884 /** A control-flow node that wraps an `ElementReference` AST expression. */
Original file line number Diff line number Diff line change @@ -168,13 +168,12 @@ private predicate stringConstCaseCompare(
168168 // when "foo", "bar"
169169 pattern instanceof ExprNodes:: StringLiteralCfgNode
170170 or
171- // array literals behave weirdly in the CFG so we need to drop down to the AST level for this bit
172- // specifically: `SplatExprCfgNode.getOperand()` does not return results for array literals
173171 exists ( CfgNodes:: ExprNodes:: SplatExprCfgNode splat | splat = pattern |
174172 // when *["foo", "bar"]
175- exists ( ArrayLiteral arr |
176- splat .getExpr ( ) .getOperand ( ) = arr and
177- forall ( Expr elem | elem = arr .getAnElement ( ) | elem instanceof StringLiteral )
173+ forex ( ExprCfgNode elem |
174+ elem = splat .getOperand ( ) .( ExprNodes:: ArrayLiteralCfgNode ) .getAnArgument ( )
175+ |
176+ elem instanceof ExprNodes:: StringLiteralCfgNode
178177 )
179178 or
180179 // when *some_var
You can’t perform that action at this time.
0 commit comments