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

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] misc-include-cleaner suggests the wrong header for std::ranges::upper_bound
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

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

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

<pre>
    For the following example
```c++
#include <algorithm>

struct Foo {
  int value;
  double bar() const { return value * 2; }
};

int main() {
  std::vector<Foo> v;
  const double to_find = 10;
  std::ranges::upper_bound(v, to_find, std::less{}, &Foo::bar);

  return 0;
}
```
`misc-include-cleaner` emits errors
```
*/sandbox.cpp:57:16: error: no header providing "std::ranges::binary_search" is directly included [misc-include-cleaner,-warnings-as-errors]
   33 | std::ranges::binary_search(v, to_find, std::less{}, &Foo::bar);
```
as well as
```
sandbox.cpp:35:1: error: included header algorithm is not used directly [misc-include-cleaner,-warnings-as-errors]
```

The suggested fix is `#include <bits/ranges_algo.h>` that seems incorrect.

The same function `std::ranges::sort` from this header (`<bits/ranges_algo.h>`) is handled perfectly. 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVN2O8jYQfZrhZgQyNkngIhfs8vEEvV859pC4dezIdtjl7Ssngf0paqXqkyJj7JyZM-dkRsZoWkdUQ_ECxWklx9T5UN-klddgHLm__Krx-laffcDUEV68tf7duBbpQ_aDJWAnYEco2fwo4C_5mU-5ME7ZUROCeJW29cGkrgfxa7mf1pjCqBKevUeoFiSicQmv0o4E4nGm_dhYwkYG4HvgB1TexZRRGCiNwc0IBH5EDuIFoTotmarTI8685vi9NG6J9CVzTBrEEcTxSir5AOL17D2IX3j9QmXOvBBK_u1inEYQJ9yyL289QgXpWorzfhwGCm-NH50Gvr8Cf70HyNsHxFKMmVV1ysfAy4lFvpnqP_yoB-8SfOb_rP7uzuNvb6JaL96slSXpKEDJkHqTIlIIPsTnWH4Efo7S6cZ_bNQwgDgWFYjjtgRxnJF54zx2JDUFHIK_Gp2_GOD8qSCNcTLc3iLJoDrgHE1EbQKpZG-4kNQIxctT1vx1_S6DM66NaxnXC_fidJcFhUCoXp978SP173Dju14y4jtZi_K5nN-FFEUW8puOj_IXNR9NlEVyPuEYSX-q9f9E-unxtP7REcaxbSkm0ngxHzljfudbUzcmReDnWdO3zG7T5f4uGaZOJoxEfcxV-JApbv6RQfaEl9GpZLzL4Z_aFH1IOeQl-B5TZ-Jdjty9JftXHrm7M0A6bUnjQOEyabXBla6FPoiDXFG9rbZVsS_KXbHq6oIVFyWZkJwzofYlqabQjBq-laWuSrUyNWd8x0pWbLes4sWmVLtDxXilDiT3vNnDjlEvjd1Ye-03PrQrE-NI9WG3Kw4rKxuycZq5nCsrXbtORt-A8zyDQ51B62ZsI-yYNTHFzzDJJDtN6y-w4oTPTL-7F6fB_R68a--yXXz4z9m0GoOtu5SG6YqfgZ9bk7qx2SjfAz9nSsvPegj-T1IJ-HkqMzsxV3qt-d8BAAD__yUt77M">