[llvm] f152625 - [Support] Fixup for formatting hex on 32 bit (#181338)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 16 01:03:49 PST 2026
Author: Konrad Kleine
Date: 2026-02-16T10:03:45+01:00
New Revision: f152625bb850fe88224887eb2da2ce8c78f12abc
URL: https://github.com/llvm/llvm-project/commit/f152625bb850fe88224887eb2da2ce8c78f12abc
DIFF: https://github.com/llvm/llvm-project/commit/f152625bb850fe88224887eb2da2ce8c78f12abc.diff
LOG: [Support] Fixup for formatting hex on 32 bit (#181338)
Without the `PRIx64`, the test won't work on 32 bit architectures.
See this comment:
https://github.com/llvm/llvm-project/pull/180498#issuecomment-3891979182
The issue is that `PRIx64` expands differently depending on the
architecture. In the original code modified in #180498 the [macro was
used](https://github.com/llvm/llvm-project/pull/180498/changes#diff-5dcf6451d2bf9e9e3a8d28b0212263a8db576045b1d4eab80cca1bfd13a3bb76L356):
```diff
- OS << format("0x%*.*" PRIx64, HexDigits, HexDigits, Address);
+ OS << formatv("0x{0:x-}",
+ fmt_align(Address, AlignStyle::Right, HexDigits, '0'));
```
I simply didn't use it in my test because on my architecture the
`PRIx64` wasn't necessary.
This is a fixup for #180498 and it should unblock the
[clang-armv7-vfpv3-2stage](https://lab.llvm.org/buildbot/#/builders/135)
builder.
Added:
Modified:
llvm/unittests/Support/FormatVariadicTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/Support/FormatVariadicTest.cpp b/llvm/unittests/Support/FormatVariadicTest.cpp
index 8265c2783566d..a3e9841536fdc 100644
--- a/llvm/unittests/Support/FormatVariadicTest.cpp
+++ b/llvm/unittests/Support/FormatVariadicTest.cpp
@@ -404,8 +404,9 @@ TEST(FormatAndFormatvTest, EquivalentHexFormatting) {
// Here's the old format() way of printing a hex number with
// dynamic width and precision, both being the same.
- EXPECT_EQ("0x00000000ff",
- printToString(100, format("0x%*.*x", HexDigits, HexDigits, N)));
+ EXPECT_EQ(
+ "0x00000000ff",
+ printToString(100, format("0x%*.*" PRIx64, HexDigits, HexDigits, N)));
// Now, do the same with formatv()
EXPECT_EQ("0x00000000ff",
More information about the llvm-commits
mailing list