<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57674>57674</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clangd cannot find function implementation in C++20 module implementation unit
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          vagran
      </td>
    </tr>
</table>

<pre>
    File `a.cppm`:
```cpp
export module A;

export void
TestFunc(); // <<< Finding implementation from here
```

File `a.cpp`:
```cpp
module A;

void
TestFunc()
{
}
```
Placing cursor on `TestFunc()` declaration in cppm and trying to find its implementation in VSCode with `clangd` connected gives no result.

`compile_commands.json`:
```json
[
{
"directory":"/home/artyom/projects/asio-awaitable-module-problem-demo/build",
"file":"../a.cppm",
"output":"a.pcm",
"command":"/opt/clang-latest/bin/clang++ -c -std=c++20 -stdlib=libc++ -Wall -Werror -g -O0 -fmodules -fimplicit-modules -fmodules-cache-path=modules-cache -DMODULES -fretain-comments-from-system-headers --precompile -x c++-module ../a.cppm -o a.pcm -Xclang -emit-module-interface"
}
,
{
"directory":"/home/artyom/projects/asio-awaitable-module-problem-demo/build",
"file":"../a.cpp",
"output":"a.o",
"command":"/opt/clang-latest/bin/clang++ -c -std=c++20 -stdlib=libc++ -Wall -Werror -g -O0 -fmodules -fimplicit-modules -fmodules-cache-path=modules-cache -DMODULES -fretain-comments-from-system-headers -fmodule-file=a.pcm ../a.cpp -o a.o"
}
]

```

Clangd log:
```
V[22:45:33.175] <<< {"id":8,"jsonrpc":"2.0","method":"textDocument/implementation","params":{"position":{"character":4,"line":3},"textDocument":{"uri":"file:///home/artyom/projects/asio-awaitable-module-problem-demo/a.cppm"}}}

I[22:45:33.175] <-- textDocument/implementation(8)
V[22:45:33.175] ASTWorker running Implementations on version 1 of /home/artyom/projects/asio-awaitable-module-problem-demo/a.cppm
I[22:45:33.175] --> reply:textDocument/implementation(8) 0 ms
V[22:45:33.175] >>> {"id":8,"jsonrpc":"2.0","result":[]}
```

Full log [attached](https://github.com/llvm/llvm-project/files/9541324/clangd.log).

Repository with sample project available [here](https://github.com/vagran/asio-awaitable-modules-problem-demo/tree/clangd-problems).

```
$ /opt/clang-latest/bin/clangd --version
clangd version 16.0.0 (https://github.com/llvm/llvm-project.git ee761374f797a47919ec8f9f49f9b8b1b20573e8)
Features: linux
Platform: x86_64-unknown-linux-gnu
```


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlVktv2zgQ_jXyhaAgUy_r4EMSx0CBXXSx6ba9FRRF2WwlUiApJ_73OxRl-ZE4aYAeChQQJGo4HA6_-Tgzpar2y7VoOAqyiIas61oYBPFNEK2C6MaNhwcmvIQ_dUpb1Kqqh0U3QXw7ap7O7pSovOATN3bdSxaQRUAK0EYBWcODgvjOP2gtZCXkBom2a3jLpaVWKIlqrVq05ZpfeHK63Znjr_t9xeGrnnqd_KCcr15045-GMuc767VRGoHbMHVhKYtQxVlDtT-XkMihjKiskNV7t9oqVAMISFhziQJof364UxVHj8JunXWwJDeVs8qUlJxZXqGN2HGDpEKam76x4ekJ3RLVdoDUN_i2sK0JvxslX4RrmPCi9PYSA0IqoWFDpfcwdovhTdZb1XL4UG33qoVBp9V30DJOZoTC9JEKS8uGYx8DDArw1-KKtwqUyl401WDqbtqoBnenPcLQmfLcPFdTve16OynSsGOXKuOZTx1WHSxZDzjihlqIlvNCyIMwILfwIMwQNrYK4hXzEhINgkaUIIM3Oyh-oU0Db641cABvEP4ImrU_rYGRi6lgwuKjaBxhRtkWEKF2CzbPhAiv_v64-u-v-wdQ19xSIbE7DFDDYHc5sNkbCzBuOa24BqMALB9DjfATGt0bN0UnKCKs0IAVwl-HEyPM28k9LKTluqZsiMAF_SdkfyNWvEUK9edSYjSKB-TilQ_6ETlPBPVCnNPVRQ55nnzvhkSEGrV5nkf872dIIgPISQqvOA7neQqWT3K_oxEhYozFw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