| Issue |
181770
|
| Summary |
[clangd] import from #include not working
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Ignition
|
Code which is valid for C++20 modules being built by `clang` is not working for `clangd`.
If an import is done within a header that gets #include'ed its as if the import didn't happen for that translation unit.
File: compile_commands.json
```
[
{
"directory": "/tmp/module-import-bug",
"command": "clang -fprebuilt-module-path=/tmp/module-import-bug -std=c++20 -I /tmp/module-import-bug
-c Use.cpp",
"file": "Use.cpp"
},
{
"directory": "/tmp/module-import-bug",
"command": "clang -std=c++20 M.cppm --precompile -o M.pcm",
"file": "M.cppm"
}
]
```
File: Header.h
```
import M;
```
File: M.cppm
```
export module M;
export struct MyType {};
```
File: Use.cpp
```
#include "Header.h"
void use() {
MyType t;
}
```
This is perfectly fine to build:
```
clang -std=c++20 M.cppm --precompile -o M.pcm
clang -fprebuilt-module-path=. -std=c++20 -I . -c Use.cpp # <-- builds
```
Yet clangd will error
```
clangd --check=Use.cpp --experimental-modules-support
```
```
[module_unimported_use] Line 3: declaration of 'MyType' must be imported from module 'M' before it is required
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs