[clang] [Clang] Overflow Pattern Exclusions (PR #100272)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 12 13:50:18 PDT 2024
================
@@ -195,13 +196,23 @@ static bool CanElideOverflowCheck(const ASTContext &Ctx, const BinOpInfo &Op) {
if (!Op.mayHaveIntegerOverflow())
return true;
+ const UnaryOperator *UO = dyn_cast<UnaryOperator>(Op.E);
+
+ if (UO && UO->getOpcode() == UO_Minus && UO->isIntegerConstantExpr(Ctx) &&
+ Ctx.getLangOpts().isOverflowPatternExcluded(
+ LangOptions::OverflowPatternExclusionKind::NegUnsignedConst))
----------------
efriedma-quic wrote:
Check isOverflowPatternExcluded() first, since it's cheaper to check.
https://github.com/llvm/llvm-project/pull/100272
More information about the cfe-commits
mailing list