-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathpoints_to.ql
More file actions
69 lines (58 loc) · 2.46 KB
/
points_to.ql
File metadata and controls
69 lines (58 loc) · 2.46 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
58
59
60
61
62
63
64
65
66
67
68
69
import cpp
private import utils.test.InlineExpectationsTest
private import semmle.code.cpp.ir.internal.IntegerConstant as Ints
private predicate ignoreAllocation(string name) {
name = ["i", "p", "q", "s", "t", "?{AllAliased}"]
}
private predicate ignoreFile(File file) {
// Ignore standard headers.
file.getBaseName() = ["memory.h", "type_traits.h", "utility.h"] or
not file.fromSource()
}
module Raw {
private import semmle.code.cpp.ir.implementation.raw.IR
private import semmle.code.cpp.ir.implementation.unaliased_ssa.internal.SimpleSSA
private MemoryLocation getAMemoryAccess(Instruction instr) {
result = getResultMemoryLocation(instr) or
result = getOperandMemoryLocation(instr.getAnOperand())
}
module RawPointsToTest implements TestSig {
string getARelevantTag() { result = "raw" }
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(Instruction instr, MemoryLocation memLocation |
memLocation = getAMemoryAccess(instr) and
tag = "raw" and
not ignoreAllocation(memLocation.getAllocation().getAllocationString()) and
value = memLocation.toString() and
element = instr.toString() and
location = instr.getLocation() and
not ignoreFile(location.getFile())
)
}
}
}
module UnaliasedSsa {
private import semmle.code.cpp.ir.implementation.unaliased_ssa.IR
private import semmle.code.cpp.ir.implementation.aliased_ssa.internal.AliasedSSA
private MemoryLocation getAMemoryAccess(Instruction instr) {
result = getResultMemoryLocation(instr) or
result = getOperandMemoryLocation(instr.getAnOperand())
}
module UnaliasedSsaPointsToTest implements TestSig {
string getARelevantTag() { result = "ussa" }
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(Instruction instr, MemoryLocation memLocation |
memLocation = getAMemoryAccess(instr) and
not memLocation.getVirtualVariable() instanceof AliasedVirtualVariable and
not memLocation instanceof AllNonLocalMemory and
tag = "ussa" and
not ignoreAllocation(memLocation.getAnAllocation().getAllocationString()) and
value = memLocation.toString() and
element = instr.toString() and
location = instr.getLocation() and
not ignoreFile(location.getFile())
)
}
}
}
import MakeTest<MergeTests<Raw::RawPointsToTest, UnaliasedSsa::UnaliasedSsaPointsToTest>>