| Issue |
75777
|
| Summary |
[clangd][include-cleaner] False warning: Included header X is not used directly
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
tuero
|
```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;
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs