[clang] [Serialization] Fix source location data loss during decoding. (PR #145529)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 25 03:20:57 PDT 2025


hokein wrote:

> > Yeah, the current situation conflicts with 64-bit source location. We discussed this. The conclusion is, if we need large source location space, use 48 bits and leave upper 16 bits for module file index. 48 bits should be enough for most cases.

Thanks, this makes sense. In my implementation, `SourceLocation` class would be 64 bits, but the actual used bits is no more than 48 bits (the limit is easy to adjust if needed).

> In this case, I am fine to drop the optimizations. I don't like these small optimization which is hard to maintain and not significant for users.

I had a similar thought when reading through that part of the code -- it’s becoming non-trivial to maintain. Removing the optimization would simplify things quite a bit. I’ll prepare a patch for that.

The downside is that this may increase the on-disk size of PCM/preamble files. Based on [D125403](https://reviews.llvm.org/D125403), the size increase could be up to 10%?, but that might be acceptable given the simplification and better long-term maintainability.

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


More information about the cfe-commits mailing list