<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/97333>97333</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang][ThreadSafety] Improve errors for trylock functions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          dmcardle
      </td>
    </tr>
</table>

<pre>
    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](https://eel.is/c++draft/conv.general#def:conversion,contextual_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: https://github.com/llvm/llvm-project/pull/95290#discussion_r1660323127
* [ ] Explicitly handle each allowed success expr type in `getMutexIDs()` rather than using `EvaluateAsBooleanCondition()`.
* [ ] Potentially add a flag that disables any new errors/warnings to enable codebases to gradually fix their annotations.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlEGPozgQhX-NcylNREwD4cAh6Z5IcxjtanfurQIX4G3HZspFOvn3K5O0ktnpy14SGXDV81fvGWO0gydqVLFXxcsKZxkDN-bYIRtHqzaYS_MH28F6dO6i9DN8gyPxQAZkJBjR9V9afCMDSud1oessfdPOAkwnYiEDVsD65XWl63ytsheV7a6_e4xkIHjoiUyL3du1weTQgwQ44hstbfrgXHi3foBuRD9QhJb6wARMDr2xflD57rGw0jtQxR5U8QJ_oYzEICN6cKF7S2VMePcgfElr6GffiQ0emGRmD3KZKKb-CL09k4FIAqG_Pk8KmX7OlpM0lKTvAsiU-nXBC51lTqygCz4RsK2jVKwNwaniRentKDLFJFgflD4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