This changes AssertLockNotHeld
so that it is annotated with the negative capability for the mutex it refers to. clang applies negative capabilities recursively, so this helps avoid forgetting to annotate functions.
Note that 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. At present, the only global mutexes that use AssertLockNotHeld
are RecursiveMutex
so we treat that as an exception in order to avoid having to add an excessive number of negative annotations.