[clang] [Clang] Add wraps attribute (for granular integer overflow handling) (PR #86618)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 23 14:07:57 PDT 2024


efriedma-quic wrote:

If you have a select with both wrapping and non-wrapping operands, is the result wrapping?  If you declare a variable as both wrapping and non-wrapping, is it wrapping?  If you declare a function parameter both wrapping and non-wrapping, is it wrapping?  If you assign to a wrapping variable, is the result wrapping?  If you mark a `short` wrapping, is the type after promotion wrapping?  If the operands of an equality operation are wrapping, is the resulting boolean wrapping?  If you mark a bitfield wrapping, does it wrap?

The fact that with this patch, a wrapping int is "just" an int is both the strength and weakness: you don't need to write out all these interactions... but the result is just based on clang's internal preferences for preserving type sugar, which are not documented.

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


More information about the cfe-commits mailing list