<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/75777>75777</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clangd][include-cleaner] False warning: Included header X is not used directly
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tuero
</td>
</tr>
</table>
<pre>
```shell
$ ./clangd --version
clangd version 17.0.3 (https://github.com/llvm/llvm-project 888437e1b60011b8a375dd30928ec925b448da57)
Features: linux+grpc
Platform: x86_64-unknown-linux-gnu
```
If I have a header file which defines a concept, and I include that header file and reuse that concept, I am getting a false `Included header X is not used directly`, i.e., by commenting out that header I get a compile error (because that concept was not previously defined.
I have a reproducible repo here, but will also type out below: https://github.com/tuero/clangd_include_example
util.h
```cpp
#ifndef UTIL_H_
#define UTIL_H_
#include <string>
// Concept for simple states for flat search
template <typename T>
concept SimpleEnv = requires(T t, const T ct, const std::string &s) {
T(s);
{ ct.is_terminal() } -> std::same_as<bool>;
};
#endif // UTIL_H_
```
main.cpp
```cpp
#include <iostream>
#include <string>
#include "util.h" // Included header util.h is not used directly
struct X {
X(const std::string &s) : s(s) {}
bool is_terminal() const {
return false;
}
std::string s;
};
template <typename T>
concept Env = SimpleEnv<T>;
template <Env T>
bool is_terminal(const T &t) {
return t.is_terminal();
}
int main() {
X x("hello");
std::cout << is_terminal(x) << std::endl;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVlGPsjgU_TX15UaCBQUefJjRMWuyD5usm8ybKeUq3S0t25Zx5t9vWkDFMd9-32QCctuennvPuRRmrTgrxDVZvpLldsY6V2uzdh0aPSt19bUmq7j_tzVKSeItiV8ITSEidMclU-cK5vMPNFZo1Y8O0SEGiyyKowQIzWvnWkuSF0J3hO7OwtVdGXHdELqT8mO8zVuj_0buIM_zNMlwUa7ieLEoc5Zky6pK4oLm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