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:
Rasmus Lerchedahl Petersen
2020-11-10 11:35:50 +01:00
parent 26286e534e
commit 109d55eb25
19 changed files with 584 additions and 390 deletions

View File

@@ -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)`

View File

@@ -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() }
}
/**