-
Notifications
You must be signed in to change notification settings - Fork 250
/
bindings.qll
99 lines (81 loc) · 2.1 KB
/
bindings.qll
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import cpp
import common
/**
* Library for mojo bindings.
*/
class StrongBinding extends ClassTemplateInstantiation {
StrongBinding() {
getName().matches("StrongBinding%")
}
Type getBindingType() {
result = this.getTemplateArgument(0).(Type).stripType()
}
}
class Binding extends ClassTemplateInstantiation {
Binding() {
getName().matches("Binding<%")
}
Type getBindingType() {
result = this.getTemplateArgument(0).(Type).stripType()
}
}
class MojoReceiver extends ClassTemplateInstantiation {
MojoReceiver() {
getQualifiedName().matches("%mojo::Receiver<%")
}
Type getBindingType() {
result = this.getTemplateArgument(0).(Type).stripType()
}
}
class InterfaceBinding extends Class {
FunctionCall addBinding;
InterfaceBinding() {
addBinding.getTarget().hasName("AddBinding") and
this = generalStripType(addBinding.getArgument(0).getAChild*().getType())
}
FunctionCall getABinding() {
result = addBinding
}
}
class InterfacePtr extends ClassTemplateInstantiation {
InterfacePtr() {
stripType().getName().matches("InterfacePtr<%") or
stripType().getName().matches("InterfacePtrInfo<%")
}
Type getInterfaceType() {
result = getTemplateArgument(0)
}
Type getInterfacePtrType() {
exists(string s | s = getInterfaceType().getName() + "Ptr" and
result.getName() = s
)
}
}
class SetConnectionErrorHandler extends Function {
SetConnectionErrorHandler() {
getName() = "set_connection_error_handler" or
getName() = "set_connection_error_with_reason_handler"
}
}
/**
* `StructPtr` usually use for transporting data in IPC.
*/
class StructPtr extends Class {
StructPtr() {
getName().matches("StructPtr<%") or
getName().matches("InlinedStructPtr<%")
}
Type getStructType() {
result = getTemplateArgument(0)
}
}
Type stripStructPtrType(Type c) {
(
c.getName().matches("vector<%") and
result = stripStructPtrType(c.(Class).getTemplateArgument(0))
) or
exists(StructPtr t | t = c.stripType() and
result = t.getStructType().stripType()
) or
result = c.stripType()
}