@@ -23,8 +23,7 @@ abstract class MutexType extends Type {
2323 abstract predicate trylockAccess ( FunctionCall fc , Expr arg ) ;
2424
2525 /**
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.
2827 */
2928 abstract predicate unlockAccess ( FunctionCall fc , Expr arg ) ;
3029
@@ -38,53 +37,52 @@ abstract class MutexType extends Type {
3837 }
3938
4039 /**
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.
4341 */
4442 FunctionCall getLockAccess ( ) {
4543 result = getMustlockAccess ( ) or
4644 result = getTrylockAccess ( )
4745 }
4846
4947 /**
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.
5149 */
5250 FunctionCall getMustlockAccess ( ) { this .mustlockAccess ( result , _) }
5351
5452 /**
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,
5654 * by may return without success.
5755 */
5856 FunctionCall getTrylockAccess ( ) { this .trylockAccess ( result , _) }
5957
6058 /**
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.
6260 */
6361 FunctionCall getUnlockAccess ( ) { this .unlockAccess ( result , _) }
6462
6563 /**
66- * DEPRECATED: use mustlockAccess(fc, arg) instead
64+ * DEPRECATED: use mustlockAccess(fc, arg) instead.
6765 */
6866 deprecated Function getMustlockFunction ( ) { result = getMustlockAccess ( ) .getTarget ( ) }
6967
7068 /**
71- * DEPRECATED: use trylockAccess(fc, arg) instead
69+ * DEPRECATED: use trylockAccess(fc, arg) instead.
7270 */
7371 deprecated Function getTrylockFunction ( ) { result = getTrylockAccess ( ) .getTarget ( ) }
7472
7573 /**
76- * DEPRECATED: use lockAccess(fc, arg) instead
74+ * DEPRECATED: use lockAccess(fc, arg) instead.
7775 */
7876 deprecated Function getLockFunction ( ) { result = getLockAccess ( ) .getTarget ( ) }
7977
8078 /**
81- * DEPRECATED: use unlockAccess(fc, arg) instead
79+ * DEPRECATED: use unlockAccess(fc, arg) instead.
8280 */
8381 deprecated Function getUnlockFunction ( ) { result = getUnlockAccess ( ) .getTarget ( ) }
8482}
8583
8684/**
87- * A function that looks like a lock function.
85+ * Gets a function that looks like a lock function.
8886 */
8987private Function mustlockCandidate ( ) {
9088 exists ( string name | name = result .getName ( ) |
@@ -94,7 +92,7 @@ private Function mustlockCandidate() {
9492}
9593
9694/**
97- * A function that looks like a try-lock function.
95+ * Gets a function that looks like a try-lock function.
9896 */
9997private Function trylockCandidate ( ) {
10098 exists ( string name | name = result .getName ( ) |
@@ -104,7 +102,7 @@ private Function trylockCandidate() {
104102}
105103
106104/**
107- * A function that looks like an unlock function.
105+ * Gets a function that looks like an unlock function.
108106 */
109107private Function unlockCandidate ( ) {
110108 exists ( string name | name = result .getName ( ) |
@@ -171,7 +169,10 @@ class DefaultMutexType extends MutexType {
171169 }
172170}
173171
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+ */
175176private predicate lockArg ( Expr arg , MutexType argType , FunctionCall call ) {
176177 argType = arg .getUnderlyingType ( ) .stripType ( ) and
177178 (
@@ -184,18 +185,31 @@ private predicate lockArg(Expr arg, MutexType argType, FunctionCall call) {
184185 // `MutexType.mustlockAccess`.
185186}
186187
188+ /**
189+ * Holds if `call` is a call that locks or tries to lock its argument `arg`.
190+ */
187191predicate lockCall ( Expr arg , FunctionCall call ) {
188192 exists ( MutexType t | lockArg ( arg , t , call ) and call = t .getLockAccess ( ) )
189193}
190194
195+ /**
196+ * Holds if `call` is a call that always locks its argument `arg`.
197+ */
191198predicate mustlockCall ( Expr arg , FunctionCall call ) {
192199 exists ( MutexType t | lockArg ( arg , t , call ) and call = t .getMustlockAccess ( ) )
193200}
194201
202+ /**
203+ * Holds if `call` is a call that tries to lock its argument `arg`, but may
204+ * return without success.
205+ */
195206predicate trylockCall ( Expr arg , FunctionCall call ) {
196207 exists ( MutexType t | lockArg ( arg , t , call ) and call = t .getTrylockAccess ( ) )
197208}
198209
210+ /**
211+ * Holds if `call` is a call that unlocks its argument `arg`.
212+ */
199213predicate unlockCall ( Expr arg , FunctionCall call ) {
200214 exists ( MutexType t | lockArg ( arg , t , call ) and call = t .getUnlockAccess ( ) )
201215}
0 commit comments