Skip to content

Commit 95d579d

Browse files
committed
Data flow: Fix bad join
``` Evaluated relational algebra for predicate _DataFlowImpl::Impl<HardcodedDataInterpretedAsCodeQuery::HardcodedDataInterpretedAsCodeFlow::C>::ret__#count_range@d112335l with tuple counts: 285176 ~2% {3} r1 = SCAN `_DataFlowDispatch::DataFlowCall.getEnclosingCallable/0#dispred#b7b78b19_DataFlowImpl::Impl<Hardcoded__#shared` OUTPUT In.1, In.0, In.2 3265592261 ~3% {5} | JOIN WITH `DataFlowImpl::Impl<HardcodedDataInterpretedAsCodeQuery::HardcodedDataInterpretedAsCodeFlow::C>::returnCallEdge1/4#d02cae42_2301#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Lhs.2, Rhs.2, Lhs.1, Rhs.3 39070 ~8% {6} | JOIN WITH `DataFlowImplCommon::Cached::viableImplInCallContextExt/2#58e931ad` ON FIRST 3 OUTPUT Lhs.0, Lhs.3, Lhs.1, Lhs.2, Lhs.4, _ 39070 ~0% {6} | REWRITE WITH Out.5 := 1 return r1 ```
1 parent 037114b commit 95d579d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll

+9-2
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,14 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
11421142
)
11431143
}
11441144

1145+
pragma[nomagic]
1146+
private predicate returnCallEdgeInCtx1(
1147+
DataFlowCallable c, SndLevelScopeOption scope, DataFlowCall call, NodeEx out, DataFlowCall ctx
1148+
) {
1149+
returnCallEdge1(c, scope, call, out) and
1150+
c = viableImplInCallContextExt(call, ctx)
1151+
}
1152+
11451153
private int ctxDispatchFanoutOnReturn(NodeEx out, DataFlowCall ctx) {
11461154
exists(DataFlowCall call, DataFlowCallable c |
11471155
simpleDispatchFanoutOnReturn(call, out) > 1 and
@@ -1151,8 +1159,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
11511159
mayBenefitFromCallContextExt(call, _) and
11521160
result =
11531161
count(DataFlowCallable tgt, SndLevelScopeOption scope |
1154-
tgt = viableImplInCallContextExt(call, ctx) and
1155-
returnCallEdge1(tgt, scope, call, out)
1162+
returnCallEdgeInCtx1(tgt, scope, call, out, ctx)
11561163
)
11571164
)
11581165
}

0 commit comments

Comments
 (0)