[clang] [Clang][Sema] Switch diagnostics from toString to operator<< for APSInt/APInt (PR #161474)

Samarth Narang via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 1 09:11:12 PDT 2025


================
@@ -14883,14 +14880,12 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
 
       // Diag message shows element size in bits and in "bytes" (platform-
       // dependent CharUnits)
-      DiagRuntimeBehavior(BaseExpr->getBeginLoc(), BaseExpr,
-                          PDiag(DiagID)
-                              << toString(index, 10, true) << AddrBits
-                              << (unsigned)ASTC.toBits(*ElemCharUnits)
-                              << toString(ElemBytes, 10, false)
-                              << toString(MaxElems, 10, false)
-                              << (unsigned)MaxElems.getLimitedValue(~0U)
-                              << IndexExpr->getSourceRange());
+      DiagRuntimeBehavior(
+          BaseExpr->getBeginLoc(), BaseExpr,
+          PDiag(DiagID) << index << AddrBits
+                        << (unsigned)ASTC.toBits(*ElemCharUnits) << ElemBytes
+                        << MaxElems << (unsigned)MaxElems.getLimitedValue(~0U)
----------------
snarang181 wrote:

The %5 is being used as a pluralization helper `"element%s5"` so it is not really deadweight.  I used `getZExtValue()` to not have to truncate the value. 

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


More information about the cfe-commits mailing list