[clang] [Clang] add wraps and no_wraps attributes (PR #115094)

Justin Stitt via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 8 14:49:58 PST 2024


================
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple x86_64-pc-linux-gnu
+typedef int __attribute__((wraps)) wrapping_int;
----------------
JustinStitt wrote:

> Can we test more types?

Yes, I'll add some more tests 😄 

> 
> Can the attributes be applied to pointers? Both the pointer itself and the pointee? It's worth adding tests, just to ensure nothing regresses here.

Pointers no:
```
warning: using attribute 'wraps' with non-integer type 'char *' has no function and is potentially misleading [-Wuseless-wraps-attribute]
    2 |   char *A __attribute__((wraps));
```

pointees yes:
```
  char B __attribute__((wraps)) = 127;
  char *A = &B;
  (++B); // no -fsanitize=implicit-signed-integer-truncation splat!
```



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


More information about the cfe-commits mailing list