-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathmembers.ql
More file actions
71 lines (55 loc) · 1.83 KB
/
members.ql
File metadata and controls
71 lines (55 loc) · 1.83 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
70
71
import cpp
newtype TMaybeClass =
TClass(Class c) or
TNoClass()
class MaybeClass extends TMaybeClass {
abstract string toString();
abstract Location getLocation();
abstract string relation(Function f);
}
string relation(Class c, Function f) {
exists(int i | f = c.getCanonicalMember(i) and result = "getCanonicalMember(" + i + ")")
or
exists(int i | f = c.getAMember(i) and result = "getAMember(" + i + ")")
or
f = c.getAMember() and result = "getAMember()"
or
f = c.getAMemberFunction() and result = "getAMemberFunction()"
or
f.getDeclaringType() = c and result = "getDeclaringType()"
}
class YesMaybeClass extends MaybeClass {
Class c;
YesMaybeClass() { this = TClass(c) }
override string toString() { result = c.toString() }
override Location getLocation() { result = c.getLocation() }
override string relation(Function f) { result = relation(c, f) }
}
class NoMaybeClass extends MaybeClass {
NoMaybeClass() { this = TNoClass() }
override string toString() { result = "<none>" }
override Location getLocation() { result instanceof UnknownLocation }
override string relation(Function f) {
not exists(relation(_, f)) and
result = "Orphan"
}
}
string functionName(Function f) {
exists(string name, string templateArgs, string args |
result = name + templateArgs + args and
name = f.getQualifiedName() and
(
if exists(f.getATemplateArgument())
then
templateArgs =
"<" + concat(int i | | f.getTemplateArgument(i).toString(), "," order by i) + ">"
else templateArgs = ""
) and
args = "(" + concat(int i | | f.getParameter(i).getType().toString(), "," order by i) + ")"
)
}
from MaybeClass m, Function f
where
not f.getDeclaringType().getName() = "__va_list_tag" and
exists(m.relation(f))
select m, f, functionName(f), concat(m.relation(f), ", ")