Skip to content

[llvm][DebugInfo] Use formatv in DWARFAcceleratorTable#191981

Merged
kwk merged 1 commit intollvm:mainfrom
kwk:formatv-2
Apr 15, 2026
Merged

[llvm][DebugInfo] Use formatv in DWARFAcceleratorTable#191981
kwk merged 1 commit intollvm:mainfrom
kwk:formatv-2

Conversation

@kwk
Copy link
Copy Markdown
Contributor

@kwk kwk commented Apr 14, 2026

This relates to #35980.

Here are all independent PRs that deal with replacing format with formatv in llvm/lib/DebugInfo:

@llvmbot
Copy link
Copy Markdown
Member

llvmbot commented Apr 14, 2026

@llvm/pr-subscribers-debuginfo

Author: Konrad Kleine (kwk)

Changes

This relates to #35980.


Full diff: https://github.com/llvm/llvm-project/pull/191981.diff

1 Files Affected:

  • (modified) llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp (+9-9)
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
index e442b5182f6a4..d37e75d46551c 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
@@ -32,7 +32,7 @@ static raw_ostream &operator<<(raw_ostream &OS, const Atom &A) {
   StringRef Str = dwarf::AtomTypeString(A.Value);
   if (!Str.empty())
     return OS << Str;
-  return OS << "DW_ATOM_unknown_" << format("%x", A.Value);
+  return OS << "DW_ATOM_unknown_" << formatv("{0:x-}", A.Value);
 }
 } // namespace
 
@@ -185,7 +185,7 @@ bool AppleAcceleratorTable::dumpName(ScopedPrinter &W,
     return false; // End of list
 
   DictScope NameScope(W, ("Name@0x" + Twine::utohexstr(NameOffset)).str());
-  W.startLine() << format("String: 0x%08" PRIx64, StringOffset);
+  W.startLine() << formatv("String: {0:x8}", StringOffset);
   W.getOStream() << " \"" << StringSection.getCStr(&StringOffset) << "\"\n";
 
   unsigned NumData = AccelSection.getU32(DataOffset);
@@ -193,7 +193,7 @@ bool AppleAcceleratorTable::dumpName(ScopedPrinter &W,
     ListScope DataScope(W, ("Data " + Twine(Data)).str());
     unsigned i = 0;
     for (auto &Atom : AtomForms) {
-      W.startLine() << format("Atom[%d]: ", i);
+      W.startLine() << formatv("Atom[{0}]: ", i);
       if (Atom.extractValue(AccelSection, DataOffset, FormParams)) {
         Atom.dump(W.getOStream());
         if (std::optional<uint64_t> Val = Atom.getAsUnsignedConstant()) {
@@ -859,7 +859,7 @@ void DWARFDebugNames::NameIndex::dumpName(ScopedPrinter &W,
   if (Hash)
     W.printHex("Hash", *Hash);
 
-  W.startLine() << format("String: 0x%08" PRIx64, NTE.getStringOffset());
+  W.startLine() << formatv("String: {0:x8}", NTE.getStringOffset());
   W.getOStream() << " \"" << NTE.getString() << "\"\n";
 
   uint64_t EntryOffset = NTE.getEntryOffset();
@@ -870,7 +870,7 @@ void DWARFDebugNames::NameIndex::dumpName(ScopedPrinter &W,
 void DWARFDebugNames::NameIndex::dumpCUs(ScopedPrinter &W) const {
   ListScope CUScope(W, "Compilation Unit offsets");
   for (uint32_t CU = 0; CU < Hdr.CompUnitCount; ++CU)
-    W.startLine() << format("CU[%u]: 0x%08" PRIx64 "\n", CU, getCUOffset(CU));
+    W.startLine() << formatv("CU[{0}]: {1:x8}\n", CU, getCUOffset(CU));
 }
 
 void DWARFDebugNames::NameIndex::dumpLocalTUs(ScopedPrinter &W) const {
@@ -879,8 +879,8 @@ void DWARFDebugNames::NameIndex::dumpLocalTUs(ScopedPrinter &W) const {
 
   ListScope TUScope(W, "Local Type Unit offsets");
   for (uint32_t TU = 0; TU < Hdr.LocalTypeUnitCount; ++TU)
-    W.startLine() << format("LocalTU[%u]: 0x%08" PRIx64 "\n", TU,
-                            getLocalTUOffset(TU));
+    W.startLine() << formatv("LocalTU[{0}]: {1:x8}\n", TU,
+                             getLocalTUOffset(TU));
 }
 
 void DWARFDebugNames::NameIndex::dumpForeignTUs(ScopedPrinter &W) const {
@@ -889,8 +889,8 @@ void DWARFDebugNames::NameIndex::dumpForeignTUs(ScopedPrinter &W) const {
 
   ListScope TUScope(W, "Foreign Type Unit signatures");
   for (uint32_t TU = 0; TU < Hdr.ForeignTypeUnitCount; ++TU) {
-    W.startLine() << format("ForeignTU[%u]: 0x%016" PRIx64 "\n", TU,
-                            getForeignTUSignature(TU));
+    W.startLine() << formatv("ForeignTU[{0}]: {1:x16}\n", TU,
+                             getForeignTUSignature(TU));
   }
 }
 

This was referenced Apr 14, 2026
Copy link
Copy Markdown
Contributor

@s-barannikov s-barannikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DavidSpickett
Copy link
Copy Markdown
Collaborator

General comment: Add "use" to all the titles "Use formatv in ...."

Copy link
Copy Markdown
Collaborator

@DavidSpickett DavidSpickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Please land without the list of PRs in the description (GitHub will give you a chance to edit it before landing).

@DavidSpickett
Copy link
Copy Markdown
Collaborator

Also [spread out landing these by a bit. A few at a time is ok and then give it maybe an hour for the bots to pick it up.

64-bit builds will likely be fine but I have a feeling some of these specifiers and casts might have been masking poor choices. So you might get reports from the Arm 32-bit bots.

@kwk
Copy link
Copy Markdown
Contributor Author

kwk commented Apr 15, 2026

General comment: Add "use" to all the titles "Use formatv in ...."

@DavidSpickett I'm sorry I've only seen this comment now. I'm going to change the remaining PRs accordingly.

@kwk kwk changed the title [llvm][DebugInfo] formatv in DWARFAcceleratorTable [llvm][DebugInfo] Use formatv in DWARFAcceleratorTable Apr 15, 2026
@kwk kwk merged commit c859d7e into llvm:main Apr 15, 2026
12 checks passed
@kwk kwk deleted the formatv-2 branch April 15, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants