Python: Implemented return node

but I think they receive no flow
This commit is contained in:
Rasmus Lerchedahl Petersen
2020-06-17 17:41:43 +02:00
parent 25d624d64b
commit a45b5a7d3c
4 changed files with 8 additions and 21 deletions

View File

@@ -88,7 +88,6 @@ class ArgumentNode extends Node {
}
/** Holds if this argument occurs at the given position in the given call. */
cached
predicate argumentOf(DataFlowCall call, int pos) {
this.asCfgNode() = call.getArg(pos)
}
@@ -120,7 +119,7 @@ class ReturnKind extends TReturnKind {
/** A data flow node that represents a value returned by a callable. */
class ReturnNode extends Node {
// ReturnNode() { this.asCfgNode() instanceof TODO }
ReturnNode() { this.asCfgNode().isNormalExit() }
/** Gets the kind of this return node. */
ReturnKind getKind() { result = TNormalReturnKind() }
@@ -128,7 +127,7 @@ class ReturnNode extends Node {
/** A data flow node that represents the output of a call. */
class OutNode extends Node {
OutNode() { this.asCfgNode() instanceof CallNode}
OutNode() { this.asCfgNode() instanceof CallNode }
/** Gets the underlying call, where this node is a corresponding output of kind `kind`. */
cached

View File

@@ -8,10 +8,13 @@ class AllFlowsConfig extends DataFlow::Configuration {
AllFlowsConfig() { this = "AllFlowsConfig" }
override predicate isSource(DataFlow::Node node) {
node.asCfgNode() instanceof CallNode
node.asCfgNode().isEntryNode()
}
override predicate isSink(DataFlow::Node node) {
node.asCfgNode().isNormalExit()
or
node = DataFlow::TEssaNode(_) and
not exists(DataFlow::Node succ |
DataFlow::localFlowStep(node, succ)
)

View File

@@ -1,28 +1,12 @@
| test.py:0:0:0:0 | Entry node for Module test |
| test.py:0:0:0:0 | Exit node for Module test |
| test.py:0:0:0:0 | GSSA Variable __name__ |
| test.py:0:0:0:0 | GSSA Variable __package__ |
| test.py:0:0:0:0 | GSSA Variable c |
| test.py:0:0:0:0 | SSA variable $ |
| test.py:1:1:1:1 | ControlFlowNode for a |
| test.py:2:1:2:1 | ControlFlowNode for b |
| test.py:2:1:2:1 | GSSA Variable b |
| test.py:4:1:4:9 | Entry node for Function f |
| test.py:4:1:4:9 | Exit node for Function f |
| test.py:4:5:4:5 | ControlFlowNode for f |
| test.py:4:5:4:5 | GSSA Variable f |
| test.py:4:7:4:7 | ControlFlowNode for x |
| test.py:4:7:4:7 | SSA variable x |
| test.py:5:3:5:3 | ControlFlowNode for y |
| test.py:5:3:5:3 | SSA variable y |
| test.py:5:7:5:7 | ControlFlowNode for x |
| test.py:5:11:5:11 | ControlFlowNode for IntegerLiteral |
| test.py:6:3:6:14 | ControlFlowNode for Return |
| test.py:6:10:6:10 | ControlFlowNode for y |
| test.py:6:10:6:14 | ControlFlowNode for BinaryExpr |
| test.py:6:14:6:14 | ControlFlowNode for IntegerLiteral |
| test.py:8:1:8:1 | ControlFlowNode for c |
| test.py:8:1:8:1 | GSSA Variable c |
| test.py:8:5:8:5 | ControlFlowNode for f |
| test.py:8:5:8:8 | GSSA Variable a |
| test.py:8:7:8:7 | ControlFlowNode for a |

View File

@@ -1 +1,2 @@
| test.py:8:5:8:8 | ControlFlowNode for f() |
| test.py:0:0:0:0 | Entry node for Module test |
| test.py:4:1:4:9 | Entry node for Function f |