This changes LOCK(mutex)
for non-global, non-recursive mutexes to be annotated with the negative capability for the mutex it refers to, to prevent . clang applies negative capabilities recursively, so this helps avoid forgetting to annotate functions.
This can’t reasonably be used for globals, because clang would require every function to be annotated with EXCLUSIVE_LOCKS_REQUIRED(!g_mutex)
for each global mutex; so this introduces a trivial GlobalMutex
subclass of Mutex
, and reduces the annotations for both GlobalMutex
to LOCKS_EXCLUDED
which only catches trivial errors (eg (LOCK(x); LOCK(x);
).