[clang] [Clang] Make the result type of sizeof/pointer subtraction/size_t lit… (PR #136542)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 21 06:45:10 PDT 2025
YexuanXiao wrote:
> Thank you for this!
>
> I'd like to better understand the need for the changes because I have a few concerns. One concern is about compile time performance. But also, this means downstream consumers of the AST are going to have to react because they used to be able to look for a `size_t` node directly and now they have to resolve a qualified type instead. This may be acceptable, but it seems disruptive too.
>
> Also, there should be more test coverage for the changes showing that we actually do get the types correct in all the various circumstances.
The current inlay hint effect of clangd is `auto a: unsigned long = sizeof(int);`, which is misleading. At the same time, it eliminates certain conversions that clang-tidy or other cleanup tools might warn about. The C and C++ standards state that the result type of such expressions is `size_t`, so while this may disrupt some downstream assumptions about prior implementations, it aligns more closely with the standard. I believe this is worthwhile, maybe there's a faster way to implement it.
https://github.com/llvm/llvm-project/pull/136542
More information about the cfe-commits
mailing list