Python: bit more local flow and fix ql docs

This commit is contained in:
Rasmus Lerchedahl Petersen
2020-06-16 08:21:32 +02:00
parent ad04ec554a
commit 0abba238cc
2 changed files with 22 additions and 1 deletions

View File

@@ -76,7 +76,6 @@ class DataFlowExpr = Expr;
* excludes SSA flow through instance fields.
*/
predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
exists(EssaEdgeRefinement r |
nodeTo.asEssaNode() = r.getVariable() and
nodeFrom.asEssaNode() = r.getInput()
@@ -86,6 +85,16 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
nodeTo.asEssaNode() = r.getVariable() and
nodeFrom.asEssaNode() = r.getInput()
)
or
exists(PhiFunction p |
nodeTo.asEssaNode() = p.getVariable() and
nodeFrom.asEssaNode() = p.getShortCircuitInput()
)
or
exists(EssaNodeDefinition d |
nodeTo.asEssaNode() = d.getVariable() and
nodeFrom.asEssaNode().getDefinition().getLocation() = d.(AssignmentDefinition).getValue().getLocation() // TODO: A better way to tie these together
)
}
//--------

View File

@@ -5,7 +5,13 @@
import python
private import DataFlowPrivate
/**
* IPA type for dta flow nodes.
*/
newtype TNode =
/**
* A node corresponding to local flow as computed via SSA.
*/
TEssaNode(EssaVariable var)
/**
@@ -14,8 +20,14 @@ newtype TNode =
*/
class Node extends TNode {
/**
* Get the underlying SSA variable if this is such a node.
*/
EssaVariable asEssaNode() { this = TEssaNode(result) }
/**
* Get a string representation of this data flow node.
*/
string toString() { result = this.asEssaNode().toString() }
/** Gets the enclosing callable of this node. */