Issue 139189
Summary [clangd] fails to compile the module with transitive module dependency
Labels new issue
Assignees
Reporter SidneyCogdill
    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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to