Skip to content

Commit ffb302d

Browse files
committed
WIP instantiate shared basic blocks lib
1 parent cdd0fbe commit ffb302d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

go/ql/lib/semmle/go/controlflow/BasicBlocks.qll

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,47 @@
44

55
import go
66
private import ControlFlowGraphImpl
7+
private import codeql.controlflow.BasicBlock as BB
8+
private import codeql.controlflow.SuccessorType
9+
10+
private module Input implements BB::InputSig<Location> {
11+
// /** Hold if `t` represents a conditional successor type. */
12+
// predicate successorTypeIsCondition(SuccessorType t) { none() }
13+
/** A delineated part of the AST with its own CFG. */
14+
class CfgScope = ControlFlow::Root;
15+
16+
/** The class of control flow nodes. */
17+
class Node = ControlFlowNode;
18+
19+
/** Gets the CFG scope in which this node occurs. */
20+
CfgScope nodeGetCfgScope(Node node) { node.getRoot() = result }
21+
22+
/** Gets an immediate successor of this node. */
23+
Node nodeGetASuccessor(Node node, SuccessorType t) { result = node.getASuccessor(t) }
24+
// /**
25+
// * Holds if `node` represents an entry node to be used when calculating
26+
// * dominance.
27+
// */
28+
// predicate nodeIsDominanceEntry(Node node) {
29+
// exists(Stmt entrystmt | entrystmt = node.asStmt() |
30+
// exists(Callable c | entrystmt = c.getBody())
31+
// or
32+
// // This disjunct is technically superfluous, but safeguards against extractor problems.
33+
// entrystmt instanceof BlockStmt and
34+
// not exists(entrystmt.getEnclosingCallable()) and
35+
// not entrystmt.getParent() instanceof Stmt
36+
// )
37+
// }
38+
// /**
39+
// * Holds if `node` represents an exit node to be used when calculating
40+
// * post dominance.
41+
// */
42+
// predicate nodeIsPostDominanceExit(Node node) { node instanceof ControlFlow::NormalExitNode }
43+
}
44+
45+
private module BbImpl = BB::Make<Location, Input>;
746

47+
// import BbImpl
848
/**
949
* Holds if `nd` starts a new basic block.
1050
*/

0 commit comments

Comments
 (0)