Skip to content

Commit 661ba1c

Browse files
committed
Python: move restriction into branch predicate
Otherwise we get loads of nodes with missing locations from the brnach nodes that are not matched.
1 parent 5de1725 commit 661ba1c

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,11 +1534,7 @@ class SynthCapturingClosureParameterNode extends ParameterNodeImpl,
15341534
{
15351535
private Function callable;
15361536

1537-
SynthCapturingClosureParameterNode() {
1538-
this = TSynthCapturingClosureParameterNode(callable) and
1539-
// TODO: Remove this restriction when adding proper support for captured variables in the body of the function we generate for comprehensions
1540-
exists(TFunction(callable))
1541-
}
1537+
SynthCapturingClosureParameterNode() { this = TSynthCapturingClosureParameterNode(callable) }
15421538

15431539
final Function getCallable() { result = callable }
15441540

@@ -1661,15 +1657,14 @@ class CapturingClosureArgumentNode extends CfgNode, ArgumentNode {
16611657
CallNode callNode;
16621658

16631659
CapturingClosureArgumentNode() {
1664-
this.getNode() = callNode.getFunction() and
1660+
node = callNode.getFunction() and
16651661
exists(Function target | resolveCall(callNode, target, _) |
16661662
target = any(VariableCapture::CapturedVariable v).getACapturingScope()
16671663
)
16681664
}
16691665

16701666
override string toString() { result = "Capturing closure argument" }
16711667

1672-
// final override Location getLocation() { result = callNode.getLocation() }
16731668
override predicate argumentOf(DataFlowCall call, ArgumentPosition pos) {
16741669
callNode = call.getNode() and
16751670
pos.isLambdaSelf()

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ newtype TNode =
119119
TSynthCaptureNode(VariableCapture::Flow::SynthesizedCaptureNode cn) or
120120
/** A synthetic node representing the heap of a function. Used for variable capture. */
121121
TSynthCapturingClosureParameterNode(Function f) {
122-
f = any(VariableCapture::CapturedVariable v).getACapturingScope()
122+
f = any(VariableCapture::CapturedVariable v).getACapturingScope() and
123+
// TODO: Remove this restriction when adding proper support for captured variables in the body of the function we generate for comprehensions
124+
exists(TFunction(f))
123125
}
124126

125127
private import semmle.python.internal.CachedStages

0 commit comments

Comments
 (0)