[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:56 PDT 2025


================
@@ -3189,16 +3227,21 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
       // Note that signed integer inc/dec with width less than int can't
       // overflow because of promotion rules; we're just eliding a few steps
       // here.
-    } else if (E->canOverflow() && type->isSignedIntegerOrEnumerationType()) {
+    } else if (type->isSignedIntegerOrEnumerationType() ||
+               type->isUnsignedIntegerType()) {
       value = EmitIncDecConsiderOverflowBehavior(E, value, isInc);
-    } else if (E->canOverflow() && type->isUnsignedIntegerType() &&
-               CGF.SanOpts.has(SanitizerKind::UnsignedIntegerOverflow) &&
-               !excludeOverflowPattern &&
-               !CGF.getContext().isTypeIgnoredBySanitizer(
-                   SanitizerKind::UnsignedIntegerOverflow, E->getType())) {
-      value = EmitOverflowCheckedBinOp(createBinOpInfoFromIncDec(
-          E, value, isInc, E->getFPFeaturesInEffect(CGF.getLangOpts())));
-    } else {
+    }
+    // else if (E->canOverflow() && type->isSignedIntegerOrEnumerationType()) {
----------------
efriedma-quic wrote:

Leftover code?

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


More information about the cfe-commits mailing list