mirror of
https://github.com/github/codeql.git
synced 2026-03-24 00:16:49 +01:00
Python: Make ParameterNode a CfgNode
Add a step from that `CfgNode` to the corresponding `EssaNode`. The intended effect is seen in `ImpliesDataflow.expected`. The efeect seen in other `.expected`-files is that parameter nodes change type, that the extra steps are seen, and that flow from `EssaVar`s is mirrored in flow from `CfgNode`s. There is one surprise, which is the `.0` node in `coverage/localFlow.expected`.
This commit is contained in:
@@ -139,6 +139,11 @@ module EssaFlow {
|
||||
contextManager.strictlyDominates(var)
|
||||
)
|
||||
or
|
||||
exists(ParameterDefinition pd |
|
||||
nodeFrom.asCfgNode() = pd.getDefiningNode() and
|
||||
nodeTo.asVar() = pd.getVariable()
|
||||
)
|
||||
or
|
||||
// First use after definition
|
||||
// `y = 42`
|
||||
// `x = f(y)`
|
||||
|
||||
@@ -176,21 +176,21 @@ ExprNode exprNode(DataFlowExpr e) { result.getNode().getNode() = e }
|
||||
* The value of a parameter at function entry, viewed as a node in a data
|
||||
* flow graph.
|
||||
*/
|
||||
class ParameterNode extends EssaNode {
|
||||
ParameterNode() { var instanceof ParameterDefinition }
|
||||
class ParameterNode extends CfgNode {
|
||||
ParameterDefinition def;
|
||||
|
||||
ParameterNode() { node = def.getDefiningNode() }
|
||||
|
||||
/**
|
||||
* Holds if this node is the parameter of callable `c` at the
|
||||
* (zero-based) index `i`.
|
||||
*/
|
||||
predicate isParameterOf(DataFlowCallable c, int i) {
|
||||
var.(ParameterDefinition).getDefiningNode() = c.getParameter(i)
|
||||
}
|
||||
predicate isParameterOf(DataFlowCallable c, int i) { node = c.getParameter(i) }
|
||||
|
||||
override DataFlowCallable getEnclosingCallable() { this.isParameterOf(result, _) }
|
||||
|
||||
/** Gets the `Parameter` this `ParameterNode` represents. */
|
||||
Parameter getParameter() { result = var.(ParameterDefinition).getParameter() }
|
||||
Parameter getParameter() { result = def.getParameter() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user