llvm / llvm/llvm-project

Clangd reuses old module information after a successful build

Open
#188,919 26 comments 2 reactions 0 assignees View on GitHub
clang:modules clangd
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

After a successful build clangd seems to only use the last compiled program information. This persists even across clangd restarts and weirdly enough it will fix itself if a build fails.

I think the easiest way of me to show the issue is with a video:
- Initially I am editing after a failed build and clangd detects changes without any problem
- After successfully building, clangd seems to get stuck thinking the module `dd` still exists, even though the name has been changed
- After a failed build clangd seems to work correctly again

https://github.com/user-attachments/assets/15fe3018-3636-4de6-a97b-b7c06ac3c297

```
squizel@squizell ~/c/m/build> clang++ --version
Ubuntu clang version 22.1.1 (++20260305112603+e693f0fe6390-1~exp1~20260305232734.42)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-22/bin
squizel@squizell ~/c/m/build> clangd --version
Ubuntu clangd version 22.1.1 (++20260305112603+e693f0fe6390-1~exp1~20260305232734.42)
Features: linux
Platform: x86_64-pc-linux-gnu
```
Here is the code used in the example:
https://github.com/AleXu224/clangd-rebuild-issue-example

Here is a log of when clangd only sees the old compiled information
[clangd2.log](https://github.com/user-attachments/files/26297278/clangd2.log)

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior using the linked clangd-rebuild-issue-example repository and compare clangd2.log with the successful and failed build states shown in the video. Start by tracing how clangd reloads compiled module information after a successful build and restart; done means renamed modules are detected consistently without requiring a failed build.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.