[clang] [Clang] Add thousands-separator to "cannot allocate array; evaluated array bound [...] exceeds the limit" diagnostic (PR #211785)

Ambrose Leeb via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 2 09:57:04 PDT 2026


================
@@ -356,12 +356,10 @@ bool AddSubMulHelper(InterpState &S, CodePtr OpPC, unsigned Bits, const T &LHS,
   if (S.checkingForUndefinedBehavior()) {
     const Expr *E = S.Current->getExpr(OpPC);
     QualType Type = E->getType();
-    SmallString<32> Trunc;
-    Value.trunc(Result.bitWidth())
-        .toString(Trunc, 10, Result.isSigned(), /*formatAsCLiteral=*/false,
-                  /*UpperCase=*/true, /*InsertSeparators=*/true);
     S.report(E->getExprLoc(), diag::warn_integer_constant_overflow)
-        << Trunc << Type << E->getSourceRange();
+        << formatDiagnosticInteger(Value.trunc(Result.bitWidth()),
+                                   Result.isSigned())
----------------
Sirraide wrote:

Why are we calling the function manually here when that’s already done in the `operator<<` implementations? This should just pass the APInt/APSInt or whatever this is directly to the diagnostic builder

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


More information about the cfe-commits mailing list