-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathSsa.ql
More file actions
57 lines (47 loc) · 1.86 KB
/
Ssa.ql
File metadata and controls
57 lines (47 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import rust
import codeql.rust.controlflow.BasicBlocks
import codeql.rust.controlflow.ControlFlowGraph
import codeql.rust.dataflow.Ssa
import codeql.rust.dataflow.internal.SsaImpl
import Impl::TestAdjacentRefs as RefTest
import TestUtils
query predicate definition(Ssa::Definition def, Variable v) {
toBeTested(v.getEnclosingCfgScope()) and def.getSourceVariable() = v
}
query predicate read(Ssa::Definition def, Variable v, Expr read) {
toBeTested(v.getEnclosingCfgScope()) and def.getSourceVariable() = v and read = def.getARead()
}
query predicate firstRead(Ssa::Definition def, Variable v, Expr read) {
toBeTested(v.getEnclosingCfgScope()) and
def.getSourceVariable() = v and
read = def.getAFirstRead()
}
query predicate adjacentReads(Ssa::Definition def, Variable v, Expr read1, Expr read2) {
toBeTested(v.getEnclosingCfgScope()) and
def.getSourceVariable() = v and
def.hasAdjacentReads(read1, read2)
}
query predicate phi(Ssa::PhiDefinition phi, Variable v, Ssa::Definition input) {
toBeTested(v.getEnclosingCfgScope()) and phi.getSourceVariable() = v and input = phi.getAnInput()
}
query predicate phiReadNode(RefTest::Ref phi, Variable v) {
toBeTested(v.getEnclosingCfgScope()) and phi.isPhiRead() and phi.getSourceVariable() = v
}
query predicate phiReadNodeFirstRead(RefTest::Ref phi, Variable v, CfgNode read) {
toBeTested(v.getEnclosingCfgScope()) and
exists(RefTest::Ref r, BasicBlock bb, int i |
phi.isPhiRead() and
RefTest::adjacentRefRead(phi, r) and
r.accessAt(bb, i, v) and
read = bb.getNode(i)
)
}
query predicate phiReadInput(RefTest::Ref phi, RefTest::Ref inp) {
phi.isPhiRead() and
RefTest::adjacentRefPhi(inp, phi)
}
query predicate ultimateDef(Ssa::Definition def, Definition ult) {
ult = def.getAnUltimateDefinition() and
ult != def
}
query predicate assigns(Ssa::WriteDefinition def, Expr value) { def.assigns(value) }