[clang-tools-extra] [clangd] [C++ Modules] Skip PCH when TU imports modules (PR #187432)

Aleksandr Platonov via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 22 22:51:36 PDT 2026


ArcsinX wrote:

I feel like we can't come into agreement here. So, I will shortly sum up my position and maybe someone else can take a look at this:
- this patch is a try to address random crashes of clangd when modules are imported within a header
- these crashes happens inside the clang (but not clangd) and relate to precompiled headers (clangd uses preamble optimization to speedup reparsing at file modification if `include`s section is not modified)
- the author confirms that this is clang (but not clangd) problem, but as he said, this is not easy to fix on the clang side and we don't known when this can be fixed because we have limited resources to support c++20 modules functionality in the clang. So, inacceptable to him.
- this patch hides the problem instead of a real fix by skipping preamble after it was build:
    - this disables preamble optimization in clangd, leading to performance degradation. We reparse the whole file at every file modification. This also affects cases, when we don't have modules import within a header (these cases had no problems before)
    - I think disabling preamble optimization is still an option (because modules import is some kind of replacement for precompiled headers), but we should not build the preamble if we have no plans to use it. But the author also rejects this option, because it's not so easy to implement and needs more complex modification.

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


More information about the cfe-commits mailing list