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.
This is a backport of core#25109
Notes:
- the changes in versionbits.h are not relevant to us because we removed most of the BIP9 related code
- we have two variants of Misbehaving to annotate because of D384
- m_sock_mutex is still called cs_hSocket in our codebase because of a missing backport
- it makes sens to annotate RelayProof for the same reason as RelayTransaction
- ReceivedAvalancheProof needs to be annotated because it calls Misbehaving and RelayProof