[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


================
@@ -12504,6 +12514,14 @@ void Sema::CheckImplicitConversion(Expr *E, QualType T, SourceLocation CC,
   IntRange TargetRange = IntRange::forTargetOfCanonicalType(Context, Target);
 
   if (LikelySourceRange->Width > TargetRange.Width) {
+    // Check if target is a wrapping OBT - if so, don't warn about constant
+    // conversion because wrapping behavior is defined for truncation
----------------
efriedma-quic wrote:

Wrapping is always defined for truncation (outside of implicit-unsigned-integer-truncation etc.).  The point of the constant truncation warning is just that it indicates there was likely a mistake.

If there's some specific pattern you're accommodating here, please note it in the comment.

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


More information about the cfe-commits mailing list