[clang] [compiler-rt] [Sanitizer] add signed-integer-wrap sanitizer (PR #80089)

Justin Stitt via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 13 14:48:41 PST 2024


================
@@ -3554,12 +3572,20 @@ Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) {
   const std::string *handlerName =
     &CGF.getLangOpts().OverflowHandler;
   if (handlerName->empty()) {
-    // If the signed-integer-overflow sanitizer is enabled, emit a call to its
-    // runtime. Otherwise, this is a -ftrapv check, so just emit a trap.
-    if (!isSigned || CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) {
+    // If the signed-integer-overflow or signed-integer-wrap sanitizer is
+    // enabled, emit a call to its runtime. Otherwise, this is a -ftrapv check,
+    // so just emit a trap.
+    if (!isSigned || CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow) ||
+        CGF.SanOpts.has(SanitizerKind::SignedIntegerWrap)) {
----------------
JustinStitt wrote:

Yes, fixed in [e964431](https://github.com/llvm/llvm-project/pull/80089/commits/e96443184c6059ab8c5b97badc9ecc7270d4d466)

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


More information about the cfe-commits mailing list