Open
Description
Originally, I merged the half-baked #95290, but reverted it in #97293.
Based on feedback, I plan to make the following changes before relanding:
- Rather than locking down trylock function return types to a fixed set of types, require that they are contextually convertible to bool. This allows for smart pointers.
- Restrict success expressions to integer/bool literals.
- Clarify in docs that it's not an equality comparison, but a conversion after conversion to bool.
- Explicitly disallow enumerator success expressions? This avoids suggesting that anything other than a bool conversion is happening. More discussion here: [clang][ThreadSafety] Check trylock function success and return types #95290 (comment)
- Explicitly handle each allowed success expr type in
getMutexIDs()
rather than usingEvaluateAsBooleanCondition()
. - Potentially add a flag that disables any new errors/warnings to enable codebases to gradually fix their annotations.