swiftlang / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. This fork is used to manage Swift’s stable releases of Clang as well as support the Swift project.
https://llvm.org
Other
1.12k stars 331 forks source link

[clang][cache] Work around crash in diagnostics syntax highlighting #9163

Closed jansvoboda11 closed 2 months ago

jansvoboda11 commented 2 months ago

Since https://github.com/llvm/llvm-project/pull/66514 Clang relies on the FileIDs and buffer pointers stored within Preprocessor to perform syntax highlighting in diagnostics. With compilation caching, we round-trip diagnostics through serialization that uses a separate copy of SourceManager. This assigns different FileIDs and allocates buffers anew, breaking invariants of the consumer.

This fix is not easy to test, since we'd rely on the order FileIDs get created, where in memory the buffers get allocated and the checkpoint interval.

rdar://134198448

jansvoboda11 commented 2 months ago

@swift-ci please test llvm