@@ -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,7 @@ class DefaultMutexType extends MutexType {
171
169
}
172
170
}
173
171
174
- /** Get the mutex argument of a call to lock or unlock. */
172
+ /** Holds if `arg` is the mutex argument of a call to lock or unlock. */
175
173
private predicate lockArg ( Expr arg , MutexType argType , FunctionCall call ) {
176
174
argType = arg .getUnderlyingType ( ) .stripType ( ) and
177
175
(
@@ -184,18 +182,31 @@ private predicate lockArg(Expr arg, MutexType argType, FunctionCall call) {
184
182
// `MutexType.mustlockAccess`.
185
183
}
186
184
185
+ /**
186
+ * Holds if `call` is a call that locks or tries to lock its argument `arg`.
187
+ */
187
188
predicate lockCall ( Expr arg , FunctionCall call ) {
188
189
exists ( MutexType t | lockArg ( arg , t , call ) and call = t .getLockAccess ( ) )
189
190
}
190
191
192
+ /**
193
+ * Holds if `call` is a call that always locks its argument `arg`.
194
+ */
191
195
predicate mustlockCall ( Expr arg , FunctionCall call ) {
192
196
exists ( MutexType t | lockArg ( arg , t , call ) and call = t .getMustlockAccess ( ) )
193
197
}
194
198
199
+ /**
200
+ * Holds if `call` is a call that tries to lock its argument `arg`, but may
201
+ * return without success.
202
+ */
195
203
predicate trylockCall ( Expr arg , FunctionCall call ) {
196
204
exists ( MutexType t | lockArg ( arg , t , call ) and call = t .getTrylockAccess ( ) )
197
205
}
198
206
207
+ /**
208
+ * Holds if `call` is a call that unlocks its argument `arg`.
209
+ */
199
210
predicate unlockCall ( Expr arg , FunctionCall call ) {
200
211
exists ( MutexType t | lockArg ( arg , t , call ) and call = t .getUnlockAccess ( ) )
201
212
}
0 commit comments