forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconflated.cpp
More file actions
62 lines (51 loc) · 1.37 KB
/
conflated.cpp
File metadata and controls
62 lines (51 loc) · 1.37 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
int user_input();
void sink(int);
struct A {
int* p;
int x;
};
void pointer_without_allocation(const A& ra) {
*ra.p = user_input();
sink(*ra.p); // $ MISSING: ast,ir
}
void argument_source(void*);
void sink(void*);
void pointer_without_allocation_2() {
char *raw;
argument_source(raw);
sink(raw); // $ ast MISSING: ir
}
A* makeA() {
return new A;
}
void no_InitializeDynamicAllocation_instruction() {
A* pa = makeA();
pa->x = user_input();
sink(pa->x); // $ ast MISSING: ir
}
void fresh_or_arg(A* arg, bool unknown) {
A* pa;
pa = unknown ? arg : new A;
pa->x = user_input();
sink(pa->x); // $ ast MISSING: ir
}
struct LinkedList {
LinkedList* next;
int y;
LinkedList() = default;
LinkedList(LinkedList* next) : next(next) {}
};
// Note: This example also suffers from #113: there is no ChiInstruction that merges the result of the
// InitializeDynamicAllocation instruction into {AllAliasedMemory}. But even when that's fixed there's
// still no dataflow because `ll->next->y = user_input()` writes to {AllAliasedMemory}.
void too_many_indirections() {
LinkedList* ll = new LinkedList;
ll->next = new LinkedList;
ll->next->y = user_input();
sink(ll->next->y); // $ ast MISSING: ir
}
void too_many_indirections_2(LinkedList* next) {
LinkedList* ll = new LinkedList(next);
ll->next->y = user_input();
sink(ll->next->y); // $ ast MISSING: ir
}