[clang-tools-extra] [clangd] [C++20] [Modules] Introduce initial support for C++20 Modules (PR #66462)

Chris Elrod via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 4 13:34:05 PDT 2024


chriselrod wrote:

Hi, sorry if this is off topic --
How can I try this PR?

I've done the following:
1. checked out the latest commit on the `clangmodules` branch (16541c8bf44c), and built it from source.
2. Added `clangd` to my path, by sym-linking `$LLVMBUILDDIR/bin/clangd` to `~/.local/bin/clangd`
```
$ clangd --version                                                                                                                (base) 
clangd version 19.0.0git (git at github.com:llvm/llvm-project.git 16541c8bf44cf38497ce6fd7377ee966d61be5aa)
```
3. Built a cmake project after setting `CXX=$LLVMBUILDDIR/bin/clang++`, so that the BMI files that are produced are compatible with clangd.

Is there more I have to do? I'd prefer not to install it, but could if that's the easiest way to get everything needed in place.

I have a few major issues:
1. This branch seems to crash a lot more often than 18.1.6 did; I never noticed the LSP disconnecting when using v18.1.6, but it is a regular occurrence with this PR.
2. I need to run clang++ to see error messages, rather than getting diagnostics from clangd while viewing the files. That is a significant regression compared to using header files. clangd 18.1.6 didn't give diagnostics either, which is why I decided to try this PR.
3. The diagnostics I do get tend to be false positives, e.g.
```c++
import Arena; // - In included file: 'std::ranges::__iswap::_IterSwap' with definition in module 'Allocator.<global>' has different definitions in diffe...
import Array; // - In included file: 'std::fpos' has different definitions in different modules; first difference is definition in module 'Pair.<global>...
import BoxOpt; // - In included file: 'std::array' has different definitions in different modules; first difference is definition in module 'BoxOpt.<glo...
```

Overall, the developer experience has been significantly worse with modules than it is with headers.

https://github.com/llvm/llvm-project/pull/66462


More information about the cfe-commits mailing list