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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Should we warn on more chained comparisons?
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            clang:diagnostics
      </td>
    </tr>

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

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

<pre>
    #128145 made chained comparisons an error by default, and both there and in #129069, we’ve been having a discussion that there might be other cases that we might want to warn about too; since #129069 is also concerned with the wording of the diagnostic, I’m opening a new issue just for the former.

Currently, the question is what to do with cases such as:
```c++
void f(int a, int b, bool c) {
    if (a < b == c) { /* ... */ }
}
```
This is sound because we’re comparing two `bool`s with `==` here, but if we change the type of `c` to something other than `bool`, then this becomes more questionable. We might want to do something about this case as well (it is worth noting that clang-tidy already warns about this). Currently, we only diagnose chained `<`/`>`/`<=`/`>=`.

See also https://github.com/llvm/llvm-project/issues/129069#issuecomment-2693937679
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVMGOozgQ_ZriUmrkmADhwCGdTKQ990p7NrgAj8DVa5tG-fuVTWeSXe1tJNTtStlV79V7tvLejJaohfIdymum1jCxaz-Mc8poyjrW9xZkcZCnw7HERWnCflLGksael0_ljGfrUVkk59hhd0dNg1rnAPKCymrsOEwYJnKUQmMx1WtE1cQtG8EPCScBTfNF2BFZnNSXsSMq1Mb3q_eGLYZJhe8qixmngB0hxxh75cnv-e2R3JQNGBg35SyqjtcYMRTv6I3t6YkAjUc1e8aebU8u0trMjhc3djri4CGF2qjRsg-mj7D_-IV6Qf4kuwO2tKHxfiX8ufqAA7t0dGC3kMtBnEGcL6tzZMN8j2Vi9u-VfIgcjcct0WTUvOPYyfm1n1B5KOJ5qMT-9SDf4yfOX2w0DiBPxgZUsW5cdHHRMc_Yg2wQ6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