[llvm] [llvm][DebugInfo] Use formatv() instead of format() (PR #191308)

Konrad Kleine via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 13 04:52:38 PDT 2026


================
@@ -101,30 +103,34 @@ constexpr uint64_t getCIEId(bool IsDWARF64, bool IsEH) {
 void CIE::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
   // A CIE with a zero length is a terminator entry in the .eh_frame section.
   if (DumpOpts.IsEH && Length == 0) {
-    OS << format("%08" PRIx64, Offset) << " ZERO terminator\n";
+    OS << formatv("{0:x-8}", Offset) << " ZERO terminator\n";
     return;
   }
 
-  OS << format("%08" PRIx64, Offset)
-     << format(" %0*" PRIx64, IsDWARF64 ? 16 : 8, Length)
-     << format(" %0*" PRIx64, IsDWARF64 && !DumpOpts.IsEH ? 16 : 8,
-               getCIEId(IsDWARF64, DumpOpts.IsEH))
+  OS << formatv("{0:x-8}", Offset)
+     << formatv(" {0:x-}",
+                fmt_align(Length, AlignStyle::Right, IsDWARF64 ? 16 : 8, '0'))
+     << formatv(" {0:x-}",
+                fmt_align(getCIEId(IsDWARF64, DumpOpts.IsEH), AlignStyle::Right,
+                          IsDWARF64 && !DumpOpts.IsEH ? 16 : 8, '0'))
      << " CIE\n"
      << "  Format:                " << FormatString(IsDWARF64) << "\n";
   if (DumpOpts.IsEH && Version != 1)
     OS << "WARNING: unsupported CIE version\n";
-  OS << format("  Version:               %d\n", Version)
+  OS << formatv("  Version:               {0}\n", Version)
      << "  Augmentation:          \"" << Augmentation << "\"\n";
   if (Version >= 4) {
-    OS << format("  Address size:          %u\n", (uint32_t)AddressSize);
-    OS << format("  Segment desc size:     %u\n",
-                 (uint32_t)SegmentDescriptorSize);
+    OS << formatv("  Address size:          {0}\n", (uint32_t)AddressSize);
+    OS << formatv("  Segment desc size:     {0}\n",
+                  (uint32_t)SegmentDescriptorSize);
   }
-  OS << format("  Code alignment factor: %u\n", (uint32_t)CodeAlignmentFactor);
-  OS << format("  Data alignment factor: %d\n", (int32_t)DataAlignmentFactor);
-  OS << format("  Return address column: %d\n", (int32_t)ReturnAddressRegister);
+  OS << formatv("  Code alignment factor: {0}\n",
+                (uint32_t)CodeAlignmentFactor);
+  OS << formatv("  Data alignment factor: {0}\n", (int32_t)DataAlignmentFactor);
+  OS << formatv("  Return address column: {0}\n",
+                (int32_t)ReturnAddressRegister);
----------------
kwk wrote:

Addressed in https://github.com/llvm/llvm-project/commit/bd36b59f2dc168befbfed9487e3095f74ce99bce.

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


More information about the llvm-commits mailing list