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

    <tr>
        <th>Summary</th>
        <td>
            clangd suggests I delete the required <ranges> include
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    Clang version is

```text
Ubuntu clang version 17.0.0 (++20230724042330+c48ed93cf8c9-1~exp1~20230724042441.1077)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
```

The following example produces the bug. It compiles fine with `clang++ -std=c++23 test.cpp -o test`

```c++
#include <iostream>
#include <ranges>
int main()
{
    const int MAGIC {5};
    for (auto i : std::ranges::views::iota(0) | std::ranges::views::take(MAGIC))
    {
        std::cout << i << '\n';
    }
    return 0;
}
```

clangd however produces this diagnostic for line 2 (`#include <ranges>`)

```text
Included header ranges is not used directly (fix available) (clangd unused-includes)
──────────────────────────────────────────────────────────────────────────────
https://clangd.llvm.org/guides/include-cleaner
```

The suggested "fix" is to delete the line, which causes the program to not compile anymore.

Since <ranges> is a standard library feature, I don't think any of the solutions outlined in the provided link are particularly doable, like adding `// IWYU` comments to the ranges header file. A workaround is to include an exception for the ranges header, but I think it should work out of the box for standard library features.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVs2O2zgMfhrlQsRQZMeODzlkMk2Rw562xWJPC1libO3Iklc_SebSZ19I8aSZboueF2gQxIxJkR8p8pO496o3iFuyfiLr5wWPYbBue-Ba2I_oFp2Vr9u95qaHMzqvrAHlCX0mdDf_1vT2DXgNt1efu2hCBPFu1aopaEGBsA1hT4Q9McpK2rCKVqwsKWFPotqgbEtx2oh2ufqC12n15cGoqlbFijYNYe0tyifuegyk3MF1U_9VV8tJLLUy8brsTZxNBodcwmgl6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