[clang] [Clang] Add thousands-separator to "cannot allocate array; evaluated array bound [...] exceeds the limit" diagnostic (PR #211785)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 24 07:45:41 PDT 2026


AaronBallman wrote:

> > I don't think we should play whack-a-mole trying to find all the places we could potentially print a large integer value and update the diagnostic call sites. I think this is something the diagnostics engine should handle when deciding how to render an integer so that the behavior is consistent across diagnostics. Otherwise we'll have to do the same dance for `note_constexpr_new_too_large`, `err_attribute_size_too_large`, and so on.
> 
> Can we just enable that by default for all diagnostics? Or is there one where that’s obviously wrong for some reason?

It's not that it's wrong, it's more that it can be distracting depending on the user and the situation. e.g. `1'234'567` is easier to read than `1234567` but not everyone will agree that `1'234` is easier to read than `1234`. There's also the problem that we single quote syntactic constructs and so if you end up with some cases like `'1'234'` the separator can be harder to read.

That said, I'm not certain what a good heuristic is, but "always use separators" isn't it. Also, we emit hex values sometimes, that might have a more obvious heuristic in some ways than decimal values.

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


More information about the cfe-commits mailing list