[llvm] [DebugInfo] DWARFFormValue use formatv instead of format (PR #180498)
Konrad Kleine via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 9 06:51:11 PST 2026
================
@@ -552,19 +557,20 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
break;
case DW_FORM_rnglistx:
- OS << format("indexed (0x%x) rangelist = ", (uint32_t)UValue);
+ OS << formatv("indexed ({0:x+}) rangelist = ", (uint32_t)UValue);
break;
case DW_FORM_loclistx:
- OS << format("indexed (0x%x) loclist = ", (uint32_t)UValue);
+ OS << formatv("indexed ({0:x+}) loclist = ", (uint32_t)UValue);
break;
case DW_FORM_sec_offset:
- AddrOS << format("0x%0*" PRIx64, OffsetDumpWidth, UValue);
+ AddrOS << formatv(
+ "0x{0:x-}", fmt_align(UValue, AlignStyle::Right, OffsetDumpWidth, '0'));
----------------
kwk wrote:
`0x{0:x-}` here ensures that the alignment happens and the `0x` is prefix. When I use `{0:x+}` for example to add the `0x` prefix automatically, the alignment considers it to be part of the string to prefix with `'0'`s. In other words you get examples like these `0000000xff` which is most certainly not what one wants.
The other places where I've just used `{0:x-}` the original format didn't include a `0x` prefix either. For example:
```diff
- AddrOS << format("indexed (%8.8x) address = ", (uint32_t)UValue);
+ AddrOS << formatv("indexed ({0:x-8}) address = ", (uint32_t)UValue);
```
For example
```c++
format("%2.2", 255) # yields: ff
formatv("{0:x-2}", 255) # yields: ff
```
https://github.com/llvm/llvm-project/pull/180498
More information about the llvm-commits
mailing list