[clang] Sanitizer: Support -fwrapv with -fsanitize=signed-integer-overflow (PR #82432)

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 20 14:36:07 PST 2024


================
@@ -723,7 +723,9 @@ class ScalarExprEmitter
     if (Ops.Ty->isSignedIntegerOrEnumerationType()) {
       switch (CGF.getLangOpts().getSignedOverflowBehavior()) {
       case LangOptions::SOB_Defined:
-        return Builder.CreateMul(Ops.LHS, Ops.RHS, "mul");
+        if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow))
----------------
vitalybuka wrote:

Is'nt the same as:
````
      case LangOptions::SOB_Defined:
      case LangOptions::SOB_Undefined:
        if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow))
          return Builder.CreateNSWMul(Ops.LHS, Ops.RHS, "mul");
        [[fallthrough]];
      case LangOptions::SOB_Trapping:
```

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


More information about the cfe-commits mailing list