[clang] [Clang] Make the result type of sizeof/pointer subtraction/size_t lit… (PR #136542)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 22 04:04:47 PDT 2025
AaronBallman wrote:
> Another possibility would be to add a new kind of type sugar for these cases that has the same canonical type but knows that it should print as `size_t` / `ptrdiff_t` etc. That'd allow you to produce an identical AST regardless of whether the typedefs are included, which seems like it'd be better for tooling than having the sugared type depend on which includes are present.
Yeah, this is more inline with what I was thinking. Given that both C and C++ now have `z`-based literals for `size_t`-based types, I think we want to treat `size_t` more like a builtin type than continue to leave it as a magic type.
> When formatting the type, you'd need to decide whether you want to always use `size_t` as the formatted name, or perform some additional check such as performing a name lookup into the global scope or into namespace `std` to see if the type is present and correct, but that's just a type printing policy decision, not something that affects correctness.
+1
https://github.com/llvm/llvm-project/pull/136542
More information about the cfe-commits
mailing list