<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/139189>139189</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clangd] fails to compile the module with transitive module dependency
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
SidneyCogdill
</td>
</tr>
</table>
<pre>
The reproduction step doesn't fit into an issue description. I've created a tiny project to showcase the bug: https://github.com/SidneyCogdill/clangd_modules_bug_showcase
```
git clone https://github.com/SidneyCogdill/clangd_modules_bug_showcase.git
```
Audit the code because it's good security practice, it's a tiny project and shouldn't be hard.
Basically:
- module `unique_fd` requires `unique_wrapper` as an dependency:
```cpp
// unique_fd.cpp
module;
#include <print>
export module unique_fd;
import unique_wrapper;
export struct UniqueFd { ... };
```
```cpp
// unique_wrapper.cpp
module;
#include <functional>
#include <stdexcept>
#include <type_traits>
export module unique_wrapper;
export template <typename Handle> requires(...)
struct UniqueWrapper { ... };
```
- When `unique_fd` is used in `my_app`, `unique_wrapper` has to be explicitly imported before `unique_fd`, otherwise clangd will fail to compile `unique_fd`:
```cpp
module;
#include <print>
export module my_app;
import unique_wrapper; // <- This is required to make clangd successfully compile `unique_fd`.
import unique_fd;
```
clang can compile the program successfully, but clangd will complain "Module XXX not found`. more importantly it will point at whatever the first import statement is at rather than the problematic module. One can only obtain useful information from the log output.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVU2P2zYQ_TX0ZbCCTPkjPujg3cRoD0UPTZHcDIocSWwpkiGH6_W_LyjJ3ng3uymKAgIMazgz77151IgYdWcRa7a-Z-uPC5God6H-QyuL5wfXKW3MonHqXH_uEQL64FSSpJ2FSOhBOYyW8S1Bqwm0JQfCgo4xISiMMmifDxfwK-PbRwQZUBAqEEDansEH9xdKAnIQe3eSIiJQj9CkjlV76Il8ZNWe8QPjh05Tn5pCuoHxww1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