|
8 | 8 | private import codeql.util.Location |
9 | 9 | private import codeql.util.FileSystem |
10 | 10 | private import codeql.util.Void |
| 11 | +private import SuccessorType |
11 | 12 |
|
12 | 13 | /** Provides the language-specific input specification. */ |
13 | 14 | signature module InputSig<LocationSig Location> { |
@@ -59,27 +60,9 @@ signature module InputSig<LocationSig Location> { |
59 | 60 | /** Holds if `scope` is exited when `last` finishes with completion `c`. */ |
60 | 61 | predicate scopeLast(CfgScope scope, AstNode last, Completion c); |
61 | 62 |
|
62 | | - /** A type of a control flow successor. */ |
63 | | - class SuccessorType { |
64 | | - /** Gets a textual representation of this successor type. */ |
65 | | - string toString(); |
66 | | - } |
67 | | - |
68 | 63 | /** Gets a successor type that matches completion `c`. */ |
69 | 64 | SuccessorType getAMatchingSuccessorType(Completion c); |
70 | 65 |
|
71 | | - /** |
72 | | - * Hold if `t` represents simple (normal) evaluation of a statement or an |
73 | | - * expression. |
74 | | - */ |
75 | | - predicate successorTypeIsSimple(SuccessorType t); |
76 | | - |
77 | | - /** Hold if `t` represents a conditional successor type. */ |
78 | | - predicate successorTypeIsCondition(SuccessorType t); |
79 | | - |
80 | | - /** Holds if `t` is an abnormal exit type out of a CFG scope. */ |
81 | | - predicate isAbnormalExitType(SuccessorType t); |
82 | | - |
83 | 66 | /** |
84 | 67 | * Gets an `id` of `node`. This is used to order the predecessors of a join |
85 | 68 | * basic block. |
@@ -522,7 +505,7 @@ module MakeWithSplitting< |
522 | 505 | private predicate succEntrySplits(CfgScope pred, AstNode succ, Splits succSplits, SuccessorType t) { |
523 | 506 | exists(int rnk | |
524 | 507 | scopeFirst(pred, succ) and |
525 | | - successorTypeIsSimple(t) and |
| 508 | + t instanceof DirectSuccessor and |
526 | 509 | succEntrySplitsFromRank(pred, succ, succSplits, rnk) |
527 | 510 | | |
528 | 511 | rnk = 0 and |
@@ -1016,7 +999,7 @@ module MakeWithSplitting< |
1016 | 999 | exists(CfgScope scope | |
1017 | 1000 | pred = TAnnotatedExitNode(scope, _) and |
1018 | 1001 | result = TExitNode(scope) and |
1019 | | - successorTypeIsSimple(t) |
| 1002 | + t instanceof DirectSuccessor |
1020 | 1003 | ) |
1021 | 1004 | } |
1022 | 1005 |
|
@@ -1117,9 +1100,7 @@ module MakeWithSplitting< |
1117 | 1100 | abstract Location getLocation(); |
1118 | 1101 |
|
1119 | 1102 | /** Holds if this control flow node has conditional successors. */ |
1120 | | - predicate isCondition() { |
1121 | | - exists(this.getASuccessor(any(SuccessorType t | successorTypeIsCondition(t)))) |
1122 | | - } |
| 1103 | + predicate isCondition() { exists(this.getASuccessor(any(ConditionalSuccessor t))) } |
1123 | 1104 |
|
1124 | 1105 | /** Gets the scope of this node. */ |
1125 | 1106 | CfgScope getScope() { result = getNodeCfgScope(this) } |
@@ -1320,7 +1301,7 @@ module MakeWithSplitting< |
1320 | 1301 | label = |
1321 | 1302 | strictconcat(SuccessorType t, string s | |
1322 | 1303 | succ = getASuccessor(pred, t) and |
1323 | | - if successorTypeIsSimple(t) then s = "" else s = t.toString() |
| 1304 | + if t instanceof DirectSuccessor then s = "" else s = t.toString() |
1324 | 1305 | | |
1325 | 1306 | s, ", " order by s |
1326 | 1307 | ) |
@@ -1590,10 +1571,6 @@ module MakeWithSplitting< |
1590 | 1571 | private class NodeAlias = Node; |
1591 | 1572 |
|
1592 | 1573 | private module BasicBlockInputSig implements BB::InputSig<Location> { |
1593 | | - class SuccessorType = Input::SuccessorType; |
1594 | | - |
1595 | | - predicate successorTypeIsCondition = Input::successorTypeIsCondition/1; |
1596 | | - |
1597 | 1574 | class CfgScope = CfgScopeAlias; |
1598 | 1575 |
|
1599 | 1576 | class Node = NodeAlias; |
|
0 commit comments