mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
Python: make compile again
also improve comment
This commit is contained in:
@@ -1531,7 +1531,7 @@ abstract class ParameterNodeImpl extends Node {
|
||||
class LambdaSelfReferenceNode extends ParameterNodeImpl, TLambdaSelfReferenceNode {
|
||||
private Function callable;
|
||||
|
||||
LambdaSelfReferenceNode() {
|
||||
LambdaSelfReferenceNode() {
|
||||
this = TLambdaSelfReferenceNode(callable) and
|
||||
// TODO: Remove this restriction when adding proper support for captured variables in the body of the function we generate for comprehensions
|
||||
exists(TFunction(callable))
|
||||
@@ -1624,10 +1624,10 @@ private class SummaryPostUpdateNode extends FlowSummaryNode, PostUpdateNodeImpl
|
||||
override Node getPreUpdateNode() { result = pre }
|
||||
}
|
||||
|
||||
private class CapturePostUpdateNode extends PostUpdateNodeImpl, CaptureNode {
|
||||
private CaptureNode pre;
|
||||
private class SynthCapturePostUpdateNode extends PostUpdateNodeImpl, SynthCaptureNode {
|
||||
private SynthCaptureNode pre;
|
||||
|
||||
CapturePostUpdateNode() {
|
||||
SynthCapturePostUpdateNode() {
|
||||
VariableCapture::Flow::capturePostUpdateNode(this.getSynthesizedCaptureNode(),
|
||||
pre.getSynthesizedCaptureNode())
|
||||
}
|
||||
|
||||
@@ -392,12 +392,13 @@ module VariableCapture {
|
||||
ExprCfgNode() { isExpressionNode(this) }
|
||||
}
|
||||
|
||||
private predicate closureFlowStep(ExprCfgNode fromNode, ExprCfgNode toNode) {
|
||||
// simpleAstFlowStep(e1, e2)
|
||||
// or
|
||||
private predicate closureFlowStep(ExprCfgNode nodeFrom, ExprCfgNode nodeTo) {
|
||||
// TODO: Other languages have an extra case here looking like
|
||||
// simpleAstFlowStep(nodeFrom, nodeTo)
|
||||
// we should investigate the potential benefit of adding that.
|
||||
exists(SsaVariable def |
|
||||
def.getAUse() = e2 and
|
||||
def.getAnUltimateDefinition().getDefinition().(DefinitionNode).getValue() = e1
|
||||
def.getAUse() = nodeTo and
|
||||
def.getAnUltimateDefinition().getDefinition().(DefinitionNode).getValue() = nodeFrom
|
||||
)
|
||||
}
|
||||
|
||||
@@ -492,7 +493,7 @@ module VariableCapture {
|
||||
module Flow = Shared::Flow<Location, CaptureInput>;
|
||||
|
||||
private Flow::ClosureNode asClosureNode(Node n) {
|
||||
result = n.(CaptureNode).getSynthesizedCaptureNode()
|
||||
result = n.(SynthCaptureNode).getSynthesizedCaptureNode()
|
||||
or
|
||||
result.(Flow::ExprNode).getExpr() = n.(CfgNode).getNode()
|
||||
or
|
||||
@@ -665,7 +666,7 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
|
||||
or
|
||||
summaryFlowSteps(nodeFrom, nodeTo)
|
||||
or
|
||||
variableCaptureFlowStep(nodeFrom, nodeTo)
|
||||
variableCaptureLocalFlowStep(nodeFrom, nodeTo)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -481,17 +481,15 @@ class StarPatternElementNode extends Node, TStarPatternElementNode {
|
||||
* A synthesized data flow node representing a closure object that tracks
|
||||
* captured variables.
|
||||
*/
|
||||
class CaptureNode extends Node, TCaptureNode {
|
||||
class SynthCaptureNode extends Node, TSynthCaptureNode {
|
||||
private VariableCapture::Flow::SynthesizedCaptureNode cn;
|
||||
|
||||
CaptureNode() { this = TCaptureNode(cn) }
|
||||
SynthCaptureNode() { this = TSynthCaptureNode(cn) }
|
||||
|
||||
/** Gets the `SynthesizedCaptureNode` that this node represents. */
|
||||
VariableCapture::Flow::SynthesizedCaptureNode getSynthesizedCaptureNode() { result = cn }
|
||||
|
||||
override Scope getScope() {
|
||||
result = cn.getEnclosingCallable()
|
||||
}
|
||||
override Scope getScope() { result = cn.getEnclosingCallable() }
|
||||
|
||||
override Location getLocation() { result = cn.getLocation() }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user