Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 18e946d

Browse files
committed
Python: Small rearrangement
1 parent 676690a commit 18e946d

6 files changed

Lines changed: 23 additions & 149 deletions

File tree

python/ql/src/experimental/dataflow/internal/DataFlowPrivate.qll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@ private import DataFlowPublic
77
//--------
88
// Nodes
99
//--------
10+
/** A control flow node which is also a dataflow node */
11+
abstract class DataFlowCfgNode extends ControlFlowNode { }
12+
13+
/** Literals contribute to dataflow */
14+
class CfgLiteralNode extends DataFlowCfgNode {
15+
CfgLiteralNode() { this.isLiteral() }
16+
}
17+
18+
/** Variables contribute to dataflow */
19+
class CfgNameNode extends DataFlowCfgNode {
20+
CfgNameNode() { this instanceof NameNode }
21+
}
22+
23+
/** Calls contribute to dataflow */
24+
class CfgCallNode extends DataFlowCfgNode {
25+
CfgCallNode() { this instanceof CallNode }
26+
}
27+
1028
/**
1129
* A node associated with an object after an operation that might have
1230
* changed its state.

python/ql/src/experimental/dataflow/internal/DataFlowPublic.qll

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ newtype TNode =
2020
/** A node corresponding to an SSA variable. */
2121
TEssaNode(EssaVariable var) or
2222
/** A node corresponding to a control flow node. */
23-
TCfgNode(ControlFlowNode node)
23+
TCfgNode(DataFlowCfgNode node)
2424

2525
/**
2626
* An element, viewed as a node in a data flow graph. Either an SSA variable
@@ -68,12 +68,12 @@ class EssaNode extends Node, TEssaNode {
6868
override Location getLocation() { result = var.getDefinition().getLocation() }
6969
}
7070

71-
abstract class CfgNode extends Node, TCfgNode {
72-
ControlFlowNode node;
71+
class CfgNode extends Node, TCfgNode {
72+
DataFlowCfgNode node;
7373

7474
CfgNode() { this = TCfgNode(node) }
7575

76-
ControlFlowNode getNode() { result = node }
76+
DataFlowCfgNode getNode() { result = node }
7777

7878
/** Gets a textual representation of this element. */
7979
override string toString() { result = node.toString() }
@@ -83,24 +83,14 @@ abstract class CfgNode extends Node, TCfgNode {
8383
override Location getLocation() { result = node.getLocation() }
8484
}
8585

86-
class CfgLiteralNode extends CfgNode {
87-
CfgLiteralNode() { node.isLiteral() }
88-
}
89-
9086
/**
9187
* An expression, viewed as a node in a data flow graph.
9288
*
9389
* Note that because of control-flow splitting, one `Expr` may correspond
9490
* to multiple `ExprNode`s, just like it may correspond to multiple
9591
* `ControlFlow::Node`s.
9692
*/
97-
class ExprNode extends CfgNode {
98-
ExprNode() {
99-
// node.isAttribute()
100-
// or
101-
node instanceof NameNode
102-
}
103-
}
93+
class ExprNode extends CfgNode { }
10494

10595
/** Gets a node corresponding to expression `e`. */
10696
ExprNode exprNode(DataFlowExpr e) { none() }

python/ql/test/experimental/dataflow/basic/local.expected

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
| file://:0:0:0:0 | Data flow node | file://:0:0:0:0 | Data flow node |
2-
| file://:0:0:0:0 | Data flow node | file://:0:0:0:0 | Data flow node |
3-
| file://:0:0:0:0 | Data flow node | file://:0:0:0:0 | Data flow node |
4-
| file://:0:0:0:0 | Data flow node | file://:0:0:0:0 | Data flow node |
5-
| file://:0:0:0:0 | Data flow node | file://:0:0:0:0 | Data flow node |
6-
| file://:0:0:0:0 | Data flow node | file://:0:0:0:0 | Data flow node |
71
| test.py:0:0:0:0 | GSSA Variable __name__ | test.py:0:0:0:0 | GSSA Variable __name__ |
82
| test.py:0:0:0:0 | GSSA Variable __package__ | test.py:0:0:0:0 | GSSA Variable __package__ |
93
| test.py:0:0:0:0 | GSSA Variable b | test.py:0:0:0:0 | GSSA Variable b |

python/ql/test/experimental/dataflow/basic/sinks.expected

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
| file://:0:0:0:0 | Data flow node |
2-
| file://:0:0:0:0 | Data flow node |
3-
| file://:0:0:0:0 | Data flow node |
4-
| file://:0:0:0:0 | Data flow node |
5-
| file://:0:0:0:0 | Data flow node |
6-
| file://:0:0:0:0 | Data flow node |
71
| test.py:0:0:0:0 | GSSA Variable __name__ |
82
| test.py:0:0:0:0 | GSSA Variable __package__ |
93
| test.py:0:0:0:0 | GSSA Variable b |

python/ql/test/experimental/dataflow/basic/sources.expected

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
| file://:0:0:0:0 | Data flow node |
2-
| file://:0:0:0:0 | Data flow node |
3-
| file://:0:0:0:0 | Data flow node |
4-
| file://:0:0:0:0 | Data flow node |
5-
| file://:0:0:0:0 | Data flow node |
6-
| file://:0:0:0:0 | Data flow node |
71
| test.py:0:0:0:0 | GSSA Variable __name__ |
82
| test.py:0:0:0:0 | GSSA Variable __package__ |
93
| test.py:0:0:0:0 | GSSA Variable b |

python/ql/test/experimental/dataflow/consistency/dataflow-consistency.expected

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -37,123 +37,7 @@ uniqueEnclosingCallable
3737
| test.py:140:6:140:11 | ControlFlowNode for unsafe | Node should have one enclosing callable but has 0. |
3838
uniqueType
3939
uniqueNodeLocation
40-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
41-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
42-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
43-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
44-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
45-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
46-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
47-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
48-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
49-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
50-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
51-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
52-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
53-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
54-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
55-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
56-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
57-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
58-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
59-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
60-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
61-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
62-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
63-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
64-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
65-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
66-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
67-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
68-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
69-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
70-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
71-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
72-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
73-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
74-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
75-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
76-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
77-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
78-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
79-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
80-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
81-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
82-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
83-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
84-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
85-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
86-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
87-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
88-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
89-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
90-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
91-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
92-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
93-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
94-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
95-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
96-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
97-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
98-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
99-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
100-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
101-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
102-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
103-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
104-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
105-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
106-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
107-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
108-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
109-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
110-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
111-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
112-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
113-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
114-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
115-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
116-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
117-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
118-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
119-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
120-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
121-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
122-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
123-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
124-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
125-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
126-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
127-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
128-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
129-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
130-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
131-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
132-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
133-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
134-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
135-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
136-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
137-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
138-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
139-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
140-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
141-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
142-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
143-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
144-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
145-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
146-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
147-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
148-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
149-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
150-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
151-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
152-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
153-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
154-
| file://:0:0:0:0 | Data flow node | Node should have one location but has 0. |
15540
missingLocation
156-
| Nodes without location: 115 |
15741
uniqueNodeToString
15842
missingToString
15943
parameterCallable

0 commit comments

Comments
 (0)