[clang] [Clang] Add wraps attribute (for granular integer overflow handling) (PR #86618)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 10 07:01:08 PDT 2024
================
@@ -282,6 +282,15 @@ Attribute Changes in Clang
This allows the ``_Nullable`` and ``_Nonnull`` family of type attributes to
apply to this class.
+- Introduced ``__attribute((wraps))__`` which can be added to type or variable
+ declarations. Using an attributed type or variable in an arithmetic
+ expression will define the overflow behavior for that expression as having
+ two's complement wrap-around. These expressions cannot trigger integer
+ overflow warnings or sanitizer warnings. They also cannot be optimized away
+ by some eager UB optimizations.
+
+ This attribute is ignored in C++.
----------------
erichkeane wrote:
```suggestion
This attribute is only valid for C, as there are built-in language alternatives for other languages.
```
https://github.com/llvm/llvm-project/pull/86618
More information about the cfe-commits
mailing list