[clang] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 26 15:42:55 PDT 2025


================
@@ -199,6 +233,19 @@ static bool CanElideOverflowCheck(const ASTContext &Ctx, const BinOpInfo &Op) {
   if (!Op.mayHaveIntegerOverflow())
     return true;
 
+  const UnaryOperator *UO = dyn_cast<UnaryOperator>(Op.E);
+  if (UO && Ctx.isUnaryOverflowPatternExcluded(UO))
+    return true;
+
+  const auto *BO = dyn_cast<BinaryOperator>(Op.E);
+  if (BO && BO->hasExcludedOverflowPattern())
----------------
efriedma-quic wrote:

Should explicit wrap/nowrap types take precedence over heuristics here?

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


More information about the cfe-commits mailing list