Skip to content

Commit e410244

Browse files
committed
Python: Implement ParameterPosition et al
1 parent bb8f4bb commit e410244

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,29 @@ private import semmle.python.essa.SsaCompute
66
/** Gets the callable in which this node occurs. */
77
DataFlowCallable nodeGetEnclosingCallable(Node n) { result = n.getEnclosingCallable() }
88

9+
/** A parameter position represented by an integer. */
10+
class ParameterPosition extends int {
11+
ParameterPosition() { exists(any(DataFlowCallable c).getParameter(this)) }
12+
}
13+
14+
/** An argument position represented by an integer. */
15+
class ArgumentPosition extends int {
16+
ArgumentPosition() { exists(any(DataFlowCall c).getArg(this)) }
17+
}
18+
19+
/** Holds if arguments at position `apos` match parameters at position `ppos`. */
20+
pragma[inline]
21+
predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) { ppos = apos }
22+
923
/** Holds if `p` is a `ParameterNode` of `c` with position `pos`. */
10-
predicate isParameterNode(ParameterNode p, DataFlowCallable c, int pos) { p.isParameterOf(c, pos) }
24+
predicate isParameterNode(ParameterNode p, DataFlowCallable c, ParameterPosition pos) {
25+
p.isParameterOf(c, pos)
26+
}
27+
28+
/** Holds if `arg` is an `ArgumentNode` of `c` with position `pos`. */
29+
predicate isArgumentNode(ArgumentNode arg, DataFlowCall c, ArgumentPosition pos) {
30+
arg.argumentOf(c, pos)
31+
}
1132

1233
//--------
1334
// Data flow graph

0 commit comments

Comments
 (0)