[clang] [clang-tools-extra] WIP: Extend SourceLocation to 64 bits. (PR #146314)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 30 12:28:46 PDT 2025


hokein wrote:

> Sorry for being dumb... how are we getting away with only storing 40 bits? Does that not just artificially limit our source-location size for statements? And, frankly, then our entire space? I guess 8 2x-increases in source-location size are nice, but I was sort of hoping the switch to 64 bits meant we never had to discuss this again for the rest of my life:D

Yeah, kind of. We can actually use up to 48 bits for `SourceLocation`, based on how we encode it for modules-- see the PR description for details.

The entire space will be `2^(SourceLocation::Bits-1)`. In the current implementation, adjusting the number of bits used is straightforward — it just changes `SourceLocation::Bits`. So I figured we could start with a “small” number (40 bits in this case, so that most Stmt's `Loc` can stay inside the `StmtBits`) and see if that’s sufficient in practice. If we ever need more, increasing it is relatively easy.

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


More information about the cfe-commits mailing list