Skip to content

Commit bb7ba78

Browse files
authored
Merge pull request #14203 from hvitved/ruby/semantic-merge-fix
Ruby: Fix semantic merge conflict
2 parents e722e32 + f3a78ef commit bb7ba78

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

ruby/ql/consistency-queries/DataFlowConsistency.ql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ private module Input implements InputSig<RubyDataFlow> {
4343
arg.asExpr().getASuccessor(any(SuccessorTypes::ConditionalSuccessor c)).getASuccessor*() = n and
4444
n.getASplit() instanceof Split::ConditionalCompletionSplit
4545
)
46+
or
47+
// Synthetic block parameter nodes are passed directly as lambda-self reference
48+
// arguments to all `yield` calls
49+
arg instanceof ArgumentNodes::BlockParameterArgumentNode
4650
}
4751
}
4852

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ private module ParameterNodes {
916916
* The value of a block parameter at function entry, viewed as a node in a data
917917
* flow graph.
918918
*/
919-
class BlockParameterNode extends ParameterNodeImpl, ArgumentNode, TBlockParameterNode {
919+
class BlockParameterNode extends ParameterNodeImpl, TBlockParameterNode {
920920
private MethodBase method;
921921

922922
BlockParameterNode() { this = TBlockParameterNode(method) }
@@ -935,16 +935,6 @@ private module ParameterNodes {
935935
this.getMethod() = result.getExpr().(YieldCall).getEnclosingMethod()
936936
}
937937

938-
// needed for variable capture flow
939-
override predicate sourceArgumentOf(CfgNodes::ExprNodes::CallCfgNode call, ArgumentPosition pos) {
940-
call = this.getAYieldCall() and
941-
pos.isLambdaSelf()
942-
}
943-
944-
override predicate argumentOf(DataFlowCall call, ArgumentPosition pos) {
945-
this.sourceArgumentOf(call.asCall(), pos)
946-
}
947-
948938
override CfgScope getCfgScope() { result = method }
949939

950940
override Location getLocationImpl() {
@@ -1199,7 +1189,7 @@ abstract class ArgumentNode extends Node {
11991189
final DataFlowCall getCall() { this.argumentOf(result, _) }
12001190
}
12011191

1202-
private module ArgumentNodes {
1192+
module ArgumentNodes {
12031193
/** A data-flow node that represents an explicit call argument. */
12041194
class ExplicitArgumentNode extends ArgumentNode {
12051195
Argument arg;
@@ -1215,6 +1205,20 @@ private module ArgumentNodes {
12151205
}
12161206
}
12171207

1208+
class BlockParameterArgumentNode extends BlockParameterNode, ArgumentNode {
1209+
BlockParameterArgumentNode() { exists(this.getAYieldCall()) }
1210+
1211+
// needed for variable capture flow
1212+
override predicate sourceArgumentOf(CfgNodes::ExprNodes::CallCfgNode call, ArgumentPosition pos) {
1213+
call = this.getAYieldCall() and
1214+
pos.isLambdaSelf()
1215+
}
1216+
1217+
override predicate argumentOf(DataFlowCall call, ArgumentPosition pos) {
1218+
this.sourceArgumentOf(call.asCall(), pos)
1219+
}
1220+
}
1221+
12181222
private class SummaryArgumentNode extends FlowSummaryNode, ArgumentNode {
12191223
private DataFlowCall call_;
12201224
private ArgumentPosition pos_;

0 commit comments

Comments
 (0)