[llvm] [llvm][DebugInfo] formatv in DWARFDebugPubTable (PR #191988)

Konrad Kleine via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 02:43:28 PDT 2026


https://github.com/kwk updated https://github.com/llvm/llvm-project/pull/191988

>From 30ad74dea1ff21f98c0bc7d37bc908cb1c625611 Mon Sep 17 00:00:00 2001
From: Konrad Kleine <kkleine at redhat.com>
Date: Mon, 13 Apr 2026 20:17:47 +0000
Subject: [PATCH 1/2] [llvm][DebugInfo] formatv in DWARFDebugPubTable

This relates to #35980.
---
 .../DebugInfo/DWARF/DWARFDebugPubTable.cpp    | 24 ++++++++++++-------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
index 5031acdb54efc..c8d3757933d8e 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
@@ -7,12 +7,14 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/DebugInfo/DWARF/DWARFDebugPubTable.h"
-#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/BinaryFormat/Dwarf.h"
+#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
 #include "llvm/Support/DataExtractor.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/FormatAdapters.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cstdint>
 
@@ -93,24 +95,30 @@ void DWARFDebugPubTable::extract(
 void DWARFDebugPubTable::dump(raw_ostream &OS) const {
   for (const Set &S : Sets) {
     int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(S.Format);
-    OS << "length = " << format("0x%0*" PRIx64, OffsetDumpWidth, S.Length);
+    OS << "length = "
+       << formatv("0x{0:x-}",
+                  fmt_align(S.Length, AlignStyle::Right, OffsetDumpWidth, '0'));
     OS << ", format = " << dwarf::FormatString(S.Format);
-    OS << ", version = " << format("0x%04x", S.Version);
+    OS << ", version = " << formatv("{0:x4}", S.Version);
     OS << ", unit_offset = "
-       << format("0x%0*" PRIx64, OffsetDumpWidth, S.Offset);
-    OS << ", unit_size = " << format("0x%0*" PRIx64, OffsetDumpWidth, S.Size)
+       << formatv("0x{0:x-}",
+                  fmt_align(S.Offset, AlignStyle::Right, OffsetDumpWidth, '0'));
+    OS << ", unit_size = "
+       << formatv("0x{0:x-}",
+                  fmt_align(S.Size, AlignStyle::Right, OffsetDumpWidth, '0'))
        << '\n';
     OS << (GnuStyle ? "Offset     Linkage  Kind     Name\n"
                     : "Offset     Name\n");
 
     for (const Entry &E : S.Entries) {
-      OS << format("0x%0*" PRIx64 " ", OffsetDumpWidth, E.SecOffset);
+      OS << formatv("0x{0:x-} ", fmt_align(E.SecOffset, AlignStyle::Right,
+                                           OffsetDumpWidth, '0'));
       if (GnuStyle) {
         StringRef EntryLinkage =
             GDBIndexEntryLinkageString(E.Descriptor.Linkage);
         StringRef EntryKind = dwarf::GDBIndexEntryKindString(E.Descriptor.Kind);
-        OS << format("%-8s", EntryLinkage.data()) << ' '
-           << format("%-8s", EntryKind.data()) << ' ';
+        OS << formatv("{0, -8}", EntryLinkage.data()) << ' '
+           << formatv("{0, -8}", EntryKind.data()) << ' ';
       }
       OS << '\"' << E.Name << "\"\n";
     }

>From bad4b8ec33c9a279b9a2fadb3cdbe7c527cfbba0 Mon Sep 17 00:00:00 2001
From: Konrad Kleine <konrad.kleine at posteo.de>
Date: Tue, 14 Apr 2026 11:43:18 +0200
Subject: [PATCH 2/2] Update llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp

Co-authored-by: Sergei Barannikov <barannikov88 at gmail.com>
---
 llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
index c8d3757933d8e..235b542305537 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
@@ -117,8 +117,8 @@ void DWARFDebugPubTable::dump(raw_ostream &OS) const {
         StringRef EntryLinkage =
             GDBIndexEntryLinkageString(E.Descriptor.Linkage);
         StringRef EntryKind = dwarf::GDBIndexEntryKindString(E.Descriptor.Kind);
-        OS << formatv("{0, -8}", EntryLinkage.data()) << ' '
-           << formatv("{0, -8}", EntryKind.data()) << ' ';
+        OS << formatv("{0,-8}", EntryLinkage.data()) << ' '
+           << formatv("{0,-8}", EntryKind.data()) << ' ';
       }
       OS << '\"' << E.Name << "\"\n";
     }



More information about the llvm-commits mailing list