You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use the proper attribute from Clang's thread safety analysis for
`AssertLockHeld()`:
* if `DEBUG_LOCKORDER` is defined then `AssertLockHeld()` will check if
the caller owns the given mutex and will `abort()` if not. Clang has
an attribute exactly for that - `ASSERT_EXCLUSIVE_LOCK()`, documented
as: "These are attributes on a function or method that does a run-time
test to see whether the calling thread holds the given capability. The
function is assumed to fail (no return) if the capability is not
held." [1]
* if `DEBUG_LOCKORDER` is not defined, then `AssertLockHeld()` does
nothing, thus don't tag it with any attributes (don't fool the
compiler that we do something which we don't).
Replace `LockAssertion` with `AssertLockHeld` and remove the former.
On the places where Clang cannot deduce that a mutex is held, use
`NO_THREAD_SAFETY_ANALYSIS`, intended to be used when a code is "too
complicated for the analysis to understand" [2].
[1] https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#requires-requires-shared
[2] https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#no-thread-safety-analysis
0 commit comments