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

2024-04-11 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 10ee32826fc2acb6bd993c88bdb7142360b6f263 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH 01/10] implement wraps attribute Signed-off-by: Justin Stitt -

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

2024-06-13 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 6152bd26438a32711589424f705281291475d548 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH] implement wraps attribute Signed-off-by: Justin Stitt --- cl

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

2024-05-29 Thread Justin Stitt via cfe-commits
JustinStitt wrote: Hi, gentle ping. @efriedma-quic, do you still have concerns with the current implementation (as an attribute attached to typedefs)? After limiting `wraps` to C and adding warnings to let users know when the attribute may be stripped, I think it's in a good spot. ```c type

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

2024-04-22 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 10ee32826fc2acb6bd993c88bdb7142360b6f263 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH 01/11] implement wraps attribute Signed-off-by: Justin Stitt -

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

2024-04-22 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 50e7b1039e514dacc05bb8cd9ff9a3e3df9ed24d Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH 01/11] implement wraps attribute Signed-off-by: Justin Stitt -

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

2024-04-22 Thread Justin Stitt via cfe-commits
JustinStitt wrote: Ping! I've rebased this PR onto bcd150d2906ac83ea0ab680e981770a71c021a03 and fixed the issues with the docs not building because of faulty code-blocks. Bigger picture, for the Linux Kernel, the current plan is to only enable certain integer sanitizers if support for this wr

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

2024-04-22 Thread Justin Stitt via cfe-commits
@@ -4093,6 +4109,11 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &op) { op.RHS->getType()->isPointerTy()) return emitPointerArithmetic(CGF, op, CodeGenFunction::NotSubtraction); + if ((op.Ty->isSignedIntegerOrEnumerationType() || JustinStitt

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

2024-04-22 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/86618 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-04-22 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 50e7b1039e514dacc05bb8cd9ff9a3e3df9ed24d Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH 01/12] implement wraps attribute Signed-off-by: Justin Stitt -

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

2024-04-22 Thread Justin Stitt via cfe-commits
@@ -4077,6 +4077,9 @@ class BinaryOperator : public Expr { static unsigned sizeOfTrailingObjects(bool HasFPFeatures) { return HasFPFeatures * sizeof(FPOptionsOverride); } + + /// Do one of the subexpressions have the wraps attribute? JustinStitt wrote:

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

2024-04-22 Thread Justin Stitt via cfe-commits
@@ -156,6 +156,10 @@ struct BinOpInfo { } return false; } + + /// Does the BinaryOperator have the wraps attribute? + /// If so, we can ellide overflow sanitizer checks. JustinStitt wrote: fixed in [872e5d6](https://github.com/llvm/llvm-project/pu

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

2024-04-22 Thread Justin Stitt via cfe-commits
@@ -2831,6 +2840,9 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, } else if (type->isIntegerType()) { QualType promotedType; bool canPerformLossyDemotionCheck = false; +BinOpInfo Ops = (createBinOpInfoFromIncDec(

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

2024-04-22 Thread Justin Stitt via cfe-commits
@@ -4093,6 +4109,11 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &op) { op.RHS->getType()->isPointerTy()) return emitPointerArithmetic(CGF, op, CodeGenFunction::NotSubtraction); + if ((op.Ty->isSignedIntegerOrEnumerationType() || JustinStitt

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

2024-04-22 Thread Justin Stitt via cfe-commits
@@ -4455,6 +4455,14 @@ void Sema::AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E) { D->addAttr(::new (Context) AlignValueAttr(Context, CI, E)); } +static void handleWrapsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { + S.AddWrapsAttr(D, AL); +} + +void S

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

2024-04-22 Thread Justin Stitt via cfe-commits
@@ -4249,6 +4270,10 @@ Value *ScalarExprEmitter::EmitFixedPointBinOp(const BinOpInfo &op) { Value *ScalarExprEmitter::EmitSub(const BinOpInfo &op) { // The LHS is always a pointer if either side is. if (!op.LHS->getType()->isPointerTy()) { +if ((op.Ty->isSignedIntegerO

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

2024-04-22 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 50e7b1039e514dacc05bb8cd9ff9a3e3df9ed24d Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH 01/13] implement wraps attribute Signed-off-by: Justin Stitt -

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

2024-04-22 Thread Justin Stitt via cfe-commits
@@ -0,0 +1,9 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only -triple x86_64-pc-linux-gnu +// expected-no-diagnostics +typedef int __attribute__((wraps)) wrapping_int; + +void foo(void) { + const wrapping_int A = 1; + int D = 2147483647 + A; JustinStitt wrote: O

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

2024-04-22 Thread Justin Stitt via cfe-commits
JustinStitt wrote: @efriedma-quic said: > I'm still not happy with the AST representation here. The current > representation is likely to cause unpredictable results in edge cases, and > compatibility constraints mean whatever result the current version happens to > produce for those cases is

[clang] [Clang] Overflow Idiom Exclusions (PR #100272)

2024-07-23 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt created https://github.com/llvm/llvm-project/pull/100272 ## Summary Introduce `-fno-sanitize-overflow-idioms` which disables sanitizer instrumentation for common overflow-dependent code idioms. ## Background For a wide selection of projects, proper overflow sanit

[clang] [Clang] Overflow Idiom Exclusions (PR #100272)

2024-07-23 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/100272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Overflow Idiom Exclusions (PR #100272)

2024-07-23 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/100272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Overflow Idiom Exclusions (PR #100272)

2024-07-23 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/100272 >From 06b702cd38943314b2e6f873e64d70baed6f57f7 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 23 Jul 2024 20:21:49 + Subject: [PATCH 1/3] implement idiom exclusions Add flag `-fno-sanitize-overf

[clang] [Clang] Overflow Idiom Exclusions (PR #100272)

2024-07-23 Thread Justin Stitt via cfe-commits
@@ -312,6 +312,38 @@ This attribute may not be supported by other compilers, so consider using it together with ``#if defined(__clang__)``. +Disabling instrumentation of common overflow idioms += + +There are certain overflow

[clang] [Clang] Overflow Idiom Exclusions (PR #100272)

2024-07-23 Thread Justin Stitt via cfe-commits
JustinStitt wrote: > Actually stuff like unsigned overflows are not UB. > > Maybe instead of `-fno-sanitize-overflow-idioms` we convert into > `unsigned-integer-overflow` into ` check group` so user can > -fno-sanitize=-unsigned-integer-overflow Right, unsigned overflow is well-defined. This

[clang] [Clang] Overflow Idiom Exclusions (PR #100272)

2024-07-23 Thread Justin Stitt via cfe-commits
JustinStitt wrote: > I assume you are going to change fronted to avoid compiler abusing these UBs? Well, like you said, none of this is really undefined behavior and isn't getting optimized away. The exception being `if ( a + b < a )` which can definitely have some unexpected results with high

[clang] [Clang] Overflow Idiom Exclusions (PR #100272)

2024-07-23 Thread Justin Stitt via cfe-commits
JustinStitt wrote: > > Right, unsigned overflow is well-defined. This isn't about the semantics of > > "undefined-ness". We want the unsigned sanitizer ON but some of the things > > it reports are noisy -- that's what this PR is about > > "Idiom" seems to vague to me. kernel has own opinion on

[clang] [Clang] Overflow Idiom Exclusions (PR #100272)

2024-07-25 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/100272 >From 06b702cd38943314b2e6f873e64d70baed6f57f7 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 23 Jul 2024 20:21:49 + Subject: [PATCH 1/4] implement idiom exclusions Add flag `-fno-sanitize-overf

[clang] [Clang] Overflow Idiom Exclusions (PR #100272)

2024-07-25 Thread Justin Stitt via cfe-commits
JustinStitt wrote: @kees @vitalybuka 3ef8d3c implements `-fsanitize=pattern-exclusion=`. It supports the following values: `all` - turn all supported pattern exclusions ON `none` - turn them all off (has precedence over others, I will add a warning soon if users try to use this with "all" or an

[clang] [Clang] Overflow Idiom Exclusions (PR #100272)

2024-07-29 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/100272 >From 06b702cd38943314b2e6f873e64d70baed6f57f7 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 23 Jul 2024 20:21:49 + Subject: [PATCH 1/5] implement idiom exclusions Add flag `-fno-sanitize-overf

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

2024-04-24 Thread Justin Stitt via cfe-commits
JustinStitt wrote: Hi @efriedma-quic, thanks for dumping all these cases! I will respond to each one individually. I understand you think adding a type would be better so I am exploring that option (I am thinking something similar to [extended vectors](https://clang.llvm.org/docs/LanguageExte

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

2024-04-24 Thread Justin Stitt via cfe-commits
JustinStitt wrote: > > > If you declare a variable as both wrapping and non-wrapping, is it > > > wrapping? > > > > > > I am not sure how to do this. I am sure that with the magic of C anything > > is possible but I can't conceive a way to have a variable both have the > > attribute and not

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

2024-04-25 Thread Justin Stitt via cfe-commits
JustinStitt wrote: @efriedma-quic: > This is declaring, then defining, a global variable; sorry if that wasn't > clear. Gotcha. > Probably should be an error? It'll be confusing no matter what we do. I think it's OK for a global variable to be declared then later defined with additional att

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

2024-04-25 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 50e7b1039e514dacc05bb8cd9ff9a3e3df9ed24d Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH 01/15] implement wraps attribute Signed-off-by: Justin Stitt -

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

2024-04-25 Thread Justin Stitt via cfe-commits
JustinStitt wrote: @efriedma-quic: > Attributes mostly do modify the type. The few that don't, like "aligned" and > "may_alias", are a constant source of problems because they get accidentally > stripped off. (I don't have any personal experience with "noderef".) So do you believe the current

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

2024-04-26 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 50e7b1039e514dacc05bb8cd9ff9a3e3df9ed24d Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH 01/16] implement wraps attribute Signed-off-by: Justin Stitt -

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

2024-04-26 Thread Justin Stitt via cfe-commits
JustinStitt wrote: In an effort to appease the build bot, I am adding a `-W` flag to turn of `warn_wraps_attr_var_decl_type_not_integer` which yells at users for trying to add `__attribute__((wraps))` to things that don't really wrap in the traditional sense. https://github.com/llvm/llvm-proj

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

2024-04-26 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 50e7b1039e514dacc05bb8cd9ff9a3e3df9ed24d Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH 01/17] implement wraps attribute Signed-off-by: Justin Stitt -

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

2024-04-26 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 50e7b1039e514dacc05bb8cd9ff9a3e3df9ed24d Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH 01/18] implement wraps attribute Signed-off-by: Justin Stitt -

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

2024-09-03 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From e73df4dedbb2e2be8b72ca3a8e847d5cbca29bed Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH] implement wraps attribute Signed-off-by: Justin Stitt --- cl

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

2024-05-02 Thread Justin Stitt via cfe-commits
JustinStitt wrote: Ping! Any chance we could land this soon? I know @efriedma-quic has some different ideas for the implementation of this feature. However, adding a new type is most likely overkill for what is needed out of `wraps`. I think the implementation/documentation and testing has la

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

2024-05-17 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 238e3242d12473a072d0d2adc51f18fbeaa927a8 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH] implement wraps attribute Signed-off-by: Justin Stitt --- cl

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

2024-05-20 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 1df2f520f6a8ab0e45b80f7a1d680d34f8ab37c9 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH] implement wraps attribute Signed-off-by: Justin Stitt --- cl

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

2024-05-20 Thread Justin Stitt via cfe-commits
JustinStitt wrote: FYI: I've rebased and handled merge conflicts (mainly in ReleaseNotes.rst). This, of course, required a force push. https://github.com/llvm/llvm-project/pull/86618 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://list

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

2024-05-24 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 1df2f520f6a8ab0e45b80f7a1d680d34f8ab37c9 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH] implement wraps attribute Signed-off-by: Justin Stitt --- cl

[clang] [Clang] Overflow Idiom Exclusions (PR #100272)

2024-08-01 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/100272 >From 154d3505ab13275086b3dffed67bcdcac52f79a3 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 23 Jul 2024 20:21:49 + Subject: [PATCH 1/6] implement idiom exclusions Add flag `-fno-sanitize-overf

[clang] [Clang] Overflow Idiom Exclusions (PR #100272)

2024-08-01 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/100272 >From 154d3505ab13275086b3dffed67bcdcac52f79a3 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 23 Jul 2024 20:21:49 + Subject: [PATCH 1/7] implement idiom exclusions Add flag `-fno-sanitize-overf

[clang] [Clang] Overflow Idiom Exclusions (PR #100272)

2024-08-06 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/100272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-06 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/100272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Re-land Overflow Pattern Exclusions (PR #104889)

2024-08-20 Thread Justin Stitt via cfe-commits
@@ -119,6 +119,10 @@ static SanitizerMask parseArgValues(const Driver &D, const llvm::opt::Arg *A, static int parseCoverageFeatures(const Driver &D, const llvm::opt::Arg *A, bool DiagnoseErrors); +static int parseOverflowPatternExclusionValues

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

2024-08-20 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 97de8998e2efd2362f9119c3ceea0938347278f4 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH] implement wraps attribute Signed-off-by: Justin Stitt --- cl

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-21 Thread Justin Stitt via cfe-commits
JustinStitt wrote: @nico > The test added here was tweaked a bit and then deleted in > [07a8cba](https://github.com/llvm/llvm-project/commit/07a8cbaf8dc16bebf6e875173d20299d9cc47cc5) > > What gives? > > Instead of deleting tests, we should revert the PR that adds them and then > reland the P

[clang] [Clang] Re-land Overflow Pattern Exclusions (PR #104889)

2024-08-21 Thread Justin Stitt via cfe-commits
@@ -438,6 +438,36 @@ Moved checkers Sanitizers -- +- Added the ``-fsanitize-undefined-ignore-overflow-pattern`` flag which can be + used to disable specific overflow-dependent code patterns. The supported + patterns are: ``add-overflow-test``, ``negated-unsigned-cons

[clang] [Clang] Re-land Overflow Pattern Exclusions (PR #104889)

2024-08-21 Thread Justin Stitt via cfe-commits
@@ -293,6 +293,48 @@ To silence reports from unsigned integer overflow, you can set ``-fsanitize-recover=unsigned-integer-overflow``, is particularly useful for providing fuzzing signal without blowing up logs. +Disabling instrumentation for common overflow patterns +

[clang] [Clang] Re-land Overflow Pattern Exclusions (PR #104889)

2024-08-21 Thread Justin Stitt via cfe-commits
@@ -293,6 +293,48 @@ To silence reports from unsigned integer overflow, you can set ``-fsanitize-recover=unsigned-integer-overflow``, is particularly useful for providing fuzzing signal without blowing up logs. +Disabling instrumentation for common overflow patterns +

[clang] [Clang] Re-land Overflow Pattern Exclusions (PR #104889)

2024-08-21 Thread Justin Stitt via cfe-commits
@@ -293,6 +293,48 @@ To silence reports from unsigned integer overflow, you can set ``-fsanitize-recover=unsigned-integer-overflow``, is particularly useful for providing fuzzing signal without blowing up logs. +Disabling instrumentation for common overflow patterns +

[clang] [Clang] Re-land Overflow Pattern Exclusions (PR #104889)

2024-08-21 Thread Justin Stitt via cfe-commits
@@ -438,6 +438,36 @@ Moved checkers Sanitizers -- +- Added the ``-fsanitize-undefined-ignore-overflow-pattern`` flag which can be + used to disable specific overflow-dependent code patterns. The supported + patterns are: ``add-overflow-test``, ``negated-unsigned-cons

[clang] [Clang] Re-land Overflow Pattern Exclusions (PR #104889)

2024-08-21 Thread Justin Stitt via cfe-commits
@@ -293,6 +293,48 @@ To silence reports from unsigned integer overflow, you can set ``-fsanitize-recover=unsigned-integer-overflow``, is particularly useful for providing fuzzing signal without blowing up logs. +Disabling instrumentation for common overflow patterns +

[clang] [Clang] Re-land Overflow Pattern Exclusions (PR #104889)

2024-08-21 Thread Justin Stitt via cfe-commits
@@ -293,6 +293,48 @@ To silence reports from unsigned integer overflow, you can set ``-fsanitize-recover=unsigned-integer-overflow``, is particularly useful for providing fuzzing signal without blowing up logs. +Disabling instrumentation for common overflow patterns +

[clang] [Clang] Re-land Overflow Pattern Exclusions (PR #104889)

2024-08-21 Thread Justin Stitt via cfe-commits
@@ -293,6 +293,48 @@ To silence reports from unsigned integer overflow, you can set ``-fsanitize-recover=unsigned-integer-overflow``, is particularly useful for providing fuzzing signal without blowing up logs. +Disabling instrumentation for common overflow patterns +

[clang] [Clang] Re-land Overflow Pattern Exclusions (PR #104889)

2024-08-21 Thread Justin Stitt via cfe-commits
@@ -0,0 +1,63 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-undefined-ignore-overflow-pattern=all %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsanitize

[clang] [Clang] Re-land Overflow Pattern Exclusions (PR #104889)

2024-08-21 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/104889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Re-land Overflow Pattern Exclusions (PR #104889)

2024-08-21 Thread Justin Stitt via cfe-commits
@@ -293,6 +293,48 @@ To silence reports from unsigned integer overflow, you can set ``-fsanitize-recover=unsigned-integer-overflow``, is particularly useful for providing fuzzing signal without blowing up logs. +Disabling instrumentation for common overflow patterns +

[clang] [Clang] Overflow Pattern Exclusion - rename some patterns, enhance docs (PR #105709)

2024-08-22 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/105709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Overflow Pattern Exclusion - rename some patterns, enhance docs (PR #105709)

2024-08-22 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt created https://github.com/llvm/llvm-project/pull/105709 >From @vitalybuka's review on https://github.com/llvm/llvm-project/pull/104889: - [x] remove unused variable in tests - [x] rename `post-decr-while` --> `unsigned-post-decr-while` - [x] split `add-overflow-te

[clang] [Clang] Overflow Pattern Exclusion - rename some patterns, enhance docs (PR #105709)

2024-08-22 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/105709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-08-22 Thread Justin Stitt via cfe-commits
JustinStitt wrote: > Regarding there not being a `no-wraps` attribute. What happens with code like > this? Is the attribute lost / casted away during the addition? > > ``` > wrapping_int a = INT_MAX; > a = (int) a + 1; > ``` Good question, the attribute is cast away (intentionally so). Additio

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

2024-08-22 Thread Justin Stitt via cfe-commits
JustinStitt wrote: > I’m a little concerned about not allowing the attribute in C++ - the > existence of other options in C++ does not mean they are an option (due to > various and sundry restrictions of C++ version upgrades different projects > have), but also you trivially end up in cases wh

[clang] [Clang] Overflow Pattern Exclusion - rename some patterns, enhance docs (PR #105709)

2024-08-25 Thread Justin Stitt via cfe-commits
@@ -4806,6 +4806,34 @@ getOverflowPatternBinOp(const BinaryOperator *E) { return {}; } +/// Compute and set the OverflowPatternExclusion bit based on whether the JustinStitt wrote: I wanted to avoid calling `getOverflowPatternBinOp()` as it is more expensiv

[clang] [Clang] Overflow Pattern Exclusion - rename some patterns, enhance docs (PR #105709)

2024-08-25 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/105709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-06-27 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From af16c497b1323983d55f92d6cfb9ab2c99a21639 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH] implement wraps attribute Signed-off-by: Justin Stitt --- cl

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

2024-06-27 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 58df542edf7d1a9f65fc804f23a2b209a49f5c5f Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH] implement wraps attribute Signed-off-by: Justin Stitt --- cl

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

2024-09-12 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/86618 >From 6fb8f6841795c44471a326a9d096a226cea9f4a8 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 5 Mar 2024 03:14:49 + Subject: [PATCH] implement wraps attribute Signed-off-by: Justin Stitt --- cl

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-09-16 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/107332 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-04 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/107332 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-29 Thread Justin Stitt via cfe-commits
JustinStitt wrote: @vitalybuka Can we move forward with this? The most recent commit uses the `=sanitize` `=no_sanitize` wording that you preferred. https://github.com/llvm/llvm-project/pull/107332 ___ cfe-commits mailing list cfe-commits@lists.llvm.o

[clang] [ubsan] Suppression by type for `-fsanitize=enum` (PR #114754)

2024-11-04 Thread Justin Stitt via cfe-commits
JustinStitt wrote: Hi Vitaly, thanks for expanding the usefulness of type suppression through SCLs. LGTM https://github.com/llvm/llvm-project/pull/114754 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/li

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-11-04 Thread Justin Stitt via cfe-commits
JustinStitt wrote: @vitalybuka any idea how lldb-server is failing with `UNRESOLVED`? How in the world are any of the changes here affecting lldb-server? https://github.com/llvm/llvm-project/pull/107332 ___ cfe-commits mailing list cfe-commits@lists.l

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

2024-11-05 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt created https://github.com/llvm/llvm-project/pull/115094 > [!NOTE] > Expansion of https://github.com/llvm/llvm-project/pull/86618, with a larger > scope including `no_wraps` and > [SSCL](https://clang.llvm.org/docs/SanitizerSpecialCaseList.html) > integration.

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-30 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/107332 >From 548efc6414503f8ae005f1bd9ef2c7f15ad16241 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 3 Sep 2024 18:28:53 -0700 Subject: [PATCH 1/6] hook up sscl categories with overflow/truncation sanitize

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-31 Thread Justin Stitt via cfe-commits
@@ -831,6 +831,28 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( return CanonTTP; } +/// Check if a type can have its sanitizer instrumentation elided. +/// Determine this by its presence in a SCL alongside its specified categories. +/// For example: +/// ignorelist.tx

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-31 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/107332 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-31 Thread Justin Stitt via cfe-commits
@@ -831,6 +831,28 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( return CanonTTP; } +/// Check if a type can have its sanitizer instrumentation elided. +/// Determine this by its presence in a SCL alongside its specified categories. +/// For example: +/// ignorelist.tx

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-31 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/107332 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-31 Thread Justin Stitt via cfe-commits
@@ -831,6 +831,28 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( return CanonTTP; } +/// Check if a type can have its sanitizer instrumentation elided. +/// Determine this by its presence in a SCL alongside its specified categories. +/// For example: +/// ignorelist.tx

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-31 Thread Justin Stitt via cfe-commits
JustinStitt wrote: BTW doc build failures linked to here: https://github.com/llvm/llvm-project/pull/109220 unrelated to my changes šŸ‘ https://github.com/llvm/llvm-project/pull/107332 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lis

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-30 Thread Justin Stitt via cfe-commits
@@ -831,6 +831,28 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( return CanonTTP; } +/// Check if a type can have its sanitizer instrumentation elided. +/// Determine this by its presence in a SCL alongside its specified categories. +/// For example: +/// ignorelist.tx

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-30 Thread Justin Stitt via cfe-commits
@@ -831,6 +831,28 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( return CanonTTP; } +/// Check if a type can have its sanitizer instrumentation elided. +/// Determine this by its presence in a SCL alongside its specified categories. +/// For example: +/// ignorelist.tx

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-30 Thread Justin Stitt via cfe-commits
JustinStitt wrote: @melver > Oh nice. If you have that almost done, why do you still want the filterlist? > For the Linux kernel usecase, wouldn't the attribute be preferrable? My > intuition tells me that maintaining a filterlist detached from the code will > cause headaches, esp. during ref

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-30 Thread Justin Stitt via cfe-commits
JustinStitt wrote: @vitalybuka > Is "Test documentation build" error related? I am noticing this documentation build failing in other [un-related Clang patchsets](https://github.com/llvm/llvm-project/actions/runs/11598884769/job/32295763452?pr=114281) (related to `ClangFormattedStatus`?). I d

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-30 Thread Justin Stitt via cfe-commits
@@ -0,0 +1,105 @@ +// RUN: rm -rf %t +// RUN: split-file %s %t + +// Verify ubsan doesn't emit checks for ignorelisted types +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-ignorelist=%t/int.ignorelist -emit-ll

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-30 Thread Justin Stitt via cfe-commits
@@ -15,8 +15,9 @@ file at compile-time. Goal and usage == -Users of sanitizer tools, such as :doc:`AddressSanitizer`, :doc:`ThreadSanitizer` -or :doc:`MemorySanitizer` may want to disable or alter some checks for +Users of sanitizer tools, such as :doc:`AddressSan

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-30 Thread Justin Stitt via cfe-commits
@@ -1,23 +0,0 @@ -// Verify ubsan vptr does not check down-casts on ignorelisted types. -// RUN: echo "type:_ZTI3Foo" > %t-type.ignorelist -// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=vptr -fsanitize-recover=vptr -emit-llvm %s -o - | FileCheck %s --check-prefix=DEFAULT

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-30 Thread Justin Stitt via cfe-commits
@@ -831,6 +831,28 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( return CanonTTP; } +/// Check if a type can have its sanitizer instrumentation elided. +/// Determine this by its presence in a SCL alongside its specified categories. +/// For example: +/// ignorelist.tx

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-30 Thread Justin Stitt via cfe-commits
JustinStitt wrote: > I wished that we could just attach attributes to type, e.g. `typedef int > __attribute__((no_sanitize("signed-integer-overflow")) wrapping_int` or > something. One thing here is that this should _not_ be a type modifier (like > volatile and such), so it does not change the

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-30 Thread Justin Stitt via cfe-commits
@@ -197,6 +197,18 @@ static bool CanElideOverflowCheck(const ASTContext &Ctx, const BinOpInfo &Op) { if (!Op.mayHaveIntegerOverflow()) return true; + if (Op.Ty->isSignedIntegerType() && JustinStitt wrote: I'll add a comment, good idea :) https://gith

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-30 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/107332 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-30 Thread Justin Stitt via cfe-commits
@@ -831,6 +831,28 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( return CanonTTP; } +/// Check if a type can have its sanitizer instrumentation elided. +/// Determine this by its presence in a SCL alongside its specified categories. +/// For example: +/// ignorelist.tx

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-11-01 Thread Justin Stitt via cfe-commits
https://github.com/JustinStitt updated https://github.com/llvm/llvm-project/pull/107332 >From 548efc6414503f8ae005f1bd9ef2c7f15ad16241 Mon Sep 17 00:00:00 2001 From: Justin Stitt Date: Tue, 3 Sep 2024 18:28:53 -0700 Subject: [PATCH 01/13] hook up sscl categories with overflow/truncation saniti

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-11-01 Thread Justin Stitt via cfe-commits
@@ -48,6 +48,64 @@ Example $ clang -fsanitize=address -fsanitize-ignorelist=ignorelist.txt foo.c ; ./a.out # No error report here. +Usage with UndefinedBehaviorSanitizer += + +The arithmetic overflow sanitizers ``unsigned-integer-overfl

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-11-01 Thread Justin Stitt via cfe-commits
@@ -831,6 +831,28 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( return CanonTTP; } +/// Check if a type can have its sanitizer instrumentation elided. +/// Determine this by its presence in a SCL alongside its specified categories. +/// For example: +/// ignorelist.tx

<    1   2   3   >