[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:35:06 PST 2024
================
@@ -8710,3 +8710,103 @@ Declares that a function potentially allocates heap memory, and prevents any pot
of ``nonallocating`` by the compiler.
}];
}
+
+def WrapsDocs : Documentation {
+ let Category = DocCatField;
+ let Content = [{
+The ``wraps`` attribute can be used with type or variable declarations to
+denote that arithmetic containing attributed types or variables have defined
+overflow behavior. Specifically, the behavior is defined as being consistent
+with two's complement wrap-around. For the purposes of sanitizers or warnings
+that concern themselves with the definedness of integer arithmetic, they will
+cease to instrument or warn about arithmetic that directly involves operands
+attributed with the ``wraps`` attribute.
+
+The ``signed-integer-overflow``, ``unsigned-integer-overflow``,
+``implicit-signed-integer-truncation`` and the
----------------
JustinStitt wrote:
The entire intention of `wraps` is to _disable_ instrumentation entirely. We never want a report or trap out of such expressions. Developers who have very intentional wrapping arithmetic should be able to delegate types as "wrapping" and move on with their day.
Furthermore, most of the use of `no_wraps` is in conjunction with SSCLs to further control overflow behavior at the type-level. Sanitizer recovery modes remain separate from all of this.
https://github.com/llvm/llvm-project/pull/115094
More information about the cfe-commits
mailing list