Skip to content

Commit 7c2df87

Browse files
authored
Merge pull request #14247 from hvitved/dataflow/fix-consitency-checks
Data flow: Fix two consistency checks
2 parents 9b35202 + daad69b commit 7c2df87

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

shared/dataflow/codeql/dataflow/internal/DataFlowImplConsistency.qll

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -262,21 +262,33 @@ module MakeConsistency<
262262
not Input::viableImplInCallContextTooLargeExclude(call, ctx, callable)
263263
}
264264

265+
private predicate uniqueParameterNodeAtPositionInclude(
266+
DataFlowCallable c, ParameterPosition pos, Node p
267+
) {
268+
not Input::uniqueParameterNodeAtPositionExclude(c, pos, p) and
269+
isParameterNode(p, c, pos)
270+
}
271+
265272
query predicate uniqueParameterNodeAtPosition(
266273
DataFlowCallable c, ParameterPosition pos, Node p, string msg
267274
) {
268-
not Input::uniqueParameterNodeAtPositionExclude(c, pos, p) and
269-
isParameterNode(p, c, pos) and
270-
not exists(unique(Node p0 | isParameterNode(p0, c, pos))) and
275+
uniqueParameterNodeAtPositionInclude(c, pos, p) and
276+
not exists(unique(Node p0 | uniqueParameterNodeAtPositionInclude(c, pos, p0))) and
271277
msg = "Parameters with overlapping positions."
272278
}
273279

280+
private predicate uniqueParameterNodePositionInclude(
281+
DataFlowCallable c, ParameterPosition pos, Node p
282+
) {
283+
not Input::uniqueParameterNodePositionExclude(c, pos, p) and
284+
isParameterNode(p, c, pos)
285+
}
286+
274287
query predicate uniqueParameterNodePosition(
275288
DataFlowCallable c, ParameterPosition pos, Node p, string msg
276289
) {
277-
not Input::uniqueParameterNodePositionExclude(c, pos, p) and
278-
isParameterNode(p, c, pos) and
279-
not exists(unique(ParameterPosition pos0 | isParameterNode(p, c, pos0))) and
290+
uniqueParameterNodePositionInclude(c, pos, p) and
291+
not exists(unique(ParameterPosition pos0 | uniqueParameterNodePositionInclude(c, pos0, p))) and
280292
msg = "Parameter node with multiple positions."
281293
}
282294

@@ -297,13 +309,14 @@ module MakeConsistency<
297309
msg = "Missing call for argument node."
298310
}
299311

300-
query predicate multipleArgumentCall(ArgumentNode arg, DataFlowCall call, string msg) {
312+
private predicate multipleArgumentCallInclude(ArgumentNode arg, DataFlowCall call) {
301313
isArgumentNode(arg, call, _) and
302-
not Input::multipleArgumentCallExclude(arg, call) and
303-
strictcount(DataFlowCall call0 |
304-
isArgumentNode(arg, call0, _) and
305-
not Input::multipleArgumentCallExclude(arg, call0)
306-
) > 1 and
314+
not Input::multipleArgumentCallExclude(arg, call)
315+
}
316+
317+
query predicate multipleArgumentCall(ArgumentNode arg, DataFlowCall call, string msg) {
318+
multipleArgumentCallInclude(arg, call) and
319+
strictcount(DataFlowCall call0 | multipleArgumentCallInclude(arg, call0)) > 1 and
307320
msg = "Multiple calls for argument node."
308321
}
309322
}

0 commit comments

Comments
 (0)