-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathAnalyzableClass.qll
More file actions
70 lines (58 loc) · 1.86 KB
/
AnalyzableClass.qll
File metadata and controls
70 lines (58 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
58
59
60
61
62
63
64
65
66
67
68
69
70
import cpp
private predicate isUsable(MemberFunction f) {
not f.isDeleted() and
f.isPublic()
}
private predicate isMemberCustomized(MemberFunction f) {
exists(f.getDefinition()) and
not f.isDefaulted() and
not f.isDeleted() and
not f.isCompilerGenerated()
}
newtype TSpecialMember =
TMoveConstructor() or
TMoveAssignmentOperator() or
TCopyConstructor() or
TCopyAssignmentOperator() or
TDestructor()
class AnalyzableClass extends Class {
MoveConstructor moveCtor;
MoveAssignmentOperator moveAssign;
CopyConstructor copyCtor;
CopyAssignmentOperator copyAssign;
Destructor dtor;
AnalyzableClass() {
moveCtor = this.getAConstructor() and
copyCtor = this.getAConstructor() and
moveAssign = this.getAMemberFunction() and
copyAssign = this.getAMemberFunction() and
dtor = this.getDestructor()
}
predicate exposes(TSpecialMember m) {
m instanceof TMoveConstructor and moveConstructible()
or
m instanceof TMoveAssignmentOperator and moveAssignable()
or
m instanceof TCopyConstructor and copyConstructible()
or
m instanceof TCopyAssignmentOperator and copyAssignable()
or
m instanceof TDestructor and destructible()
}
predicate moveConstructible() { isUsable(moveCtor) }
predicate copyConstructible() { isUsable(copyCtor) }
predicate moveAssignable() { isUsable(moveAssign) }
predicate copyAssignable() { isUsable(copyAssign) }
predicate destructible() { isUsable(dtor) }
predicate isCustomized(TSpecialMember s) {
s instanceof TMoveConstructor and isMemberCustomized(moveCtor)
or
s instanceof TMoveAssignmentOperator and isMemberCustomized(moveAssign)
or
s instanceof TCopyConstructor and isMemberCustomized(copyCtor)
or
s instanceof TCopyAssignmentOperator and isMemberCustomized(copyAssign)
or
s instanceof TDestructor and isMemberCustomized(dtor)
}
}