@@ -23,8 +23,7 @@ abstract class MutexType extends Type {
23
23
abstract predicate trylockAccess ( FunctionCall fc , Expr arg ) ;
24
24
25
25
/**
26
- * Holds if `fc` is a call that unlocks mutex `arg`
27
- * of this type.
26
+ * Holds if `fc` is a call that unlocks mutex `arg` of this type.
28
27
*/
29
28
abstract predicate unlockAccess ( FunctionCall fc , Expr arg ) ;
30
29
@@ -38,53 +37,52 @@ abstract class MutexType extends Type {
38
37
}
39
38
40
39
/**
41
- * Holds if `fc` is a call that locks or tries to lock any
42
- * mutex of this type.
40
+ * Gets a call that locks or tries to lock any mutex of this type.
43
41
*/
44
42
FunctionCall getLockAccess ( ) {
45
43
result = getMustlockAccess ( ) or
46
44
result = getTrylockAccess ( )
47
45
}
48
46
49
47
/**
50
- * Holds if `fc` is a call that always locks any mutex of this type.
48
+ * Gets a call that always locks any mutex of this type.
51
49
*/
52
50
FunctionCall getMustlockAccess ( ) { this .mustlockAccess ( result , _) }
53
51
54
52
/**
55
- * Holds if `fc` is a call that tries to lock any mutex of this type,
53
+ * Gets a call that tries to lock any mutex of this type,
56
54
* by may return without success.
57
55
*/
58
56
FunctionCall getTrylockAccess ( ) { this .trylockAccess ( result , _) }
59
57
60
58
/**
61
- * Holds if `fc` is a call that unlocks any mutex of this type.
59
+ * Gets a call that unlocks any mutex of this type.
62
60
*/
63
61
FunctionCall getUnlockAccess ( ) { this .unlockAccess ( result , _) }
64
62
65
63
/**
66
- * DEPRECATED: use mustlockAccess(fc, arg) instead
64
+ * DEPRECATED: use mustlockAccess(fc, arg) instead.
67
65
*/
68
66
deprecated Function getMustlockFunction ( ) { result = getMustlockAccess ( ) .getTarget ( ) }
69
67
70
68
/**
71
- * DEPRECATED: use trylockAccess(fc, arg) instead
69
+ * DEPRECATED: use trylockAccess(fc, arg) instead.
72
70
*/
73
71
deprecated Function getTrylockFunction ( ) { result = getTrylockAccess ( ) .getTarget ( ) }
74
72
75
73
/**
76
- * DEPRECATED: use lockAccess(fc, arg) instead
74
+ * DEPRECATED: use lockAccess(fc, arg) instead.
77
75
*/
78
76
deprecated Function getLockFunction ( ) { result = getLockAccess ( ) .getTarget ( ) }
79
77
80
78
/**
81
- * DEPRECATED: use unlockAccess(fc, arg) instead
79
+ * DEPRECATED: use unlockAccess(fc, arg) instead.
82
80
*/
83
81
deprecated Function getUnlockFunction ( ) { result = getUnlockAccess ( ) .getTarget ( ) }
84
82
}
85
83
86
84
/**
87
- * A function that looks like a lock function.
85
+ * Gets a function that looks like a lock function.
88
86
*/
89
87
private Function mustlockCandidate ( ) {
90
88
exists ( string name | name = result .getName ( ) |
@@ -94,7 +92,7 @@ private Function mustlockCandidate() {
94
92
}
95
93
96
94
/**
97
- * A function that looks like a try-lock function.
95
+ * Gets a function that looks like a try-lock function.
98
96
*/
99
97
private Function trylockCandidate ( ) {
100
98
exists ( string name | name = result .getName ( ) |
@@ -104,7 +102,7 @@ private Function trylockCandidate() {
104
102
}
105
103
106
104
/**
107
- * A function that looks like an unlock function.
105
+ * Gets a function that looks like an unlock function.
108
106
*/
109
107
private Function unlockCandidate ( ) {
110
108
exists ( string name | name = result .getName ( ) |
@@ -171,7 +169,10 @@ class DefaultMutexType extends MutexType {
171
169
}
172
170
}
173
171
174
- /** Get the mutex argument of a call to lock or unlock. */
172
+ /**
173
+ * Holds if `arg` is the mutex argument of a call to lock or unlock and
174
+ * `argType` is the type of the mutex.
175
+ */
175
176
private predicate lockArg ( Expr arg , MutexType argType , FunctionCall call ) {
176
177
argType = arg .getUnderlyingType ( ) .stripType ( ) and
177
178
(
@@ -184,18 +185,31 @@ private predicate lockArg(Expr arg, MutexType argType, FunctionCall call) {
184
185
// `MutexType.mustlockAccess`.
185
186
}
186
187
188
+ /**
189
+ * Holds if `call` is a call that locks or tries to lock its argument `arg`.
190
+ */
187
191
predicate lockCall ( Expr arg , FunctionCall call ) {
188
192
exists ( MutexType t | lockArg ( arg , t , call ) and call = t .getLockAccess ( ) )
189
193
}
190
194
195
+ /**
196
+ * Holds if `call` is a call that always locks its argument `arg`.
197
+ */
191
198
predicate mustlockCall ( Expr arg , FunctionCall call ) {
192
199
exists ( MutexType t | lockArg ( arg , t , call ) and call = t .getMustlockAccess ( ) )
193
200
}
194
201
202
+ /**
203
+ * Holds if `call` is a call that tries to lock its argument `arg`, but may
204
+ * return without success.
205
+ */
195
206
predicate trylockCall ( Expr arg , FunctionCall call ) {
196
207
exists ( MutexType t | lockArg ( arg , t , call ) and call = t .getTrylockAccess ( ) )
197
208
}
198
209
210
+ /**
211
+ * Holds if `call` is a call that unlocks its argument `arg`.
212
+ */
199
213
predicate unlockCall ( Expr arg , FunctionCall call ) {
200
214
exists ( MutexType t | lockArg ( arg , t , call ) and call = t .getUnlockAccess ( ) )
201
215
}
0 commit comments