[clang] [compiler-rt] [Sanitizer] add signed-integer-wrap sanitizer (PR #80089)
Nick Desaulniers via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 13 10:41:24 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)) {
----------------
nickdesaulniers wrote:
Should you be using `hasOneOf` here rather than `||`?
https://github.com/llvm/llvm-project/pull/80089
More information about the cfe-commits
mailing list