[llvm] [llvm][DebugInfo] formatv in LVReader (PR #192007)

Konrad Kleine via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 08:54:11 PDT 2026


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

>From ba8e21d87218c9283fc29ac29ccc5911c93313e2 Mon Sep 17 00:00:00 2001
From: Konrad Kleine <kkleine at redhat.com>
Date: Mon, 13 Apr 2026 20:21:16 +0000
Subject: [PATCH 1/4] [llvm][DebugInfo] formatv in LVReader

This relates to #35980.
---
 llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
index d973a47f68732..8273149f6fe63 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
@@ -70,22 +70,19 @@ bool checkIntegrityScopesTree(LVScope *Root) {
     });
 
     auto PrintIndex = [](unsigned Index) {
-      if (Index)
-        dbgs() << format("%8d: ", Index);
-      else
-        dbgs() << format("%8c: ", ' ');
+      dbgs() << formatv("{0,8}: ", Index ? Index : ' ');
     };
     auto PrintElement = [&](LVElement *Element, unsigned Index = 0) {
       PrintIndex(Index);
       std::string ElementName(Element->getName());
-      dbgs() << format("%15s ID=0x%08x '%s'\n", Element->kind(),
-                       Element->getID(), ElementName.c_str());
+      dbgs() << formatv("{0,15} ID={1:x8} '{2}'\n", Element->kind(),
+                        Element->getID(), ElementName);
     };
 
     std::string RootName(Root->getName());
     dbgs() << formatv("{0}\n", fmt_repeat('=', 72));
-    dbgs() << format("Root: '%s'\nDuplicated elements: %d\n", RootName.c_str(),
-                     Duplicate.size());
+    dbgs() << formatv("Root: '{0}'\nDuplicated elements: {1}\n",
+                      RootName, Duplicate.size());
     dbgs() << formatv("{0}\n", fmt_repeat('=', 72));
 
     unsigned Index = 0;

>From 3da74bcf2fa374b6587712d0d7795fad22bc2f19 Mon Sep 17 00:00:00 2001
From: Konrad Kleine <kkleine at redhat.com>
Date: Tue, 14 Apr 2026 07:56:07 +0000
Subject: [PATCH 2/4] Fix format

---
 llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
index 8273149f6fe63..3e38b28149eb9 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
@@ -81,8 +81,8 @@ bool checkIntegrityScopesTree(LVScope *Root) {
 
     std::string RootName(Root->getName());
     dbgs() << formatv("{0}\n", fmt_repeat('=', 72));
-    dbgs() << formatv("Root: '{0}'\nDuplicated elements: {1}\n",
-                      RootName, Duplicate.size());
+    dbgs() << formatv("Root: '{0}'\nDuplicated elements: {1}\n", RootName,
+                      Duplicate.size());
     dbgs() << formatv("{0}\n", fmt_repeat('=', 72));
 
     unsigned Index = 0;

>From c5f764e02036dd84e01ccb5f660a3ac0d2aa36a1 Mon Sep 17 00:00:00 2001
From: Konrad Kleine <kkleine at redhat.com>
Date: Tue, 14 Apr 2026 15:52:54 +0000
Subject: [PATCH 3/4] Fix formatting of error

---
 llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
index 3e38b28149eb9..e8b5c760be039 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
@@ -70,7 +70,10 @@ bool checkIntegrityScopesTree(LVScope *Root) {
     });
 
     auto PrintIndex = [](unsigned Index) {
-      dbgs() << formatv("{0,8}: ", Index ? Index : ' ');
+      if (Index)
+        dbgs() << formatv("{0,8}: ", Index);
+      else
+        dbgs() << formatv("{0,8:s}: ", ' ');
     };
     auto PrintElement = [&](LVElement *Element, unsigned Index = 0) {
       PrintIndex(Index);

>From a835da5906262439aa6644f8ae484be2912a620c Mon Sep 17 00:00:00 2001
From: Konrad Kleine <kkleine at redhat.com>
Date: Tue, 14 Apr 2026 15:53:21 +0000
Subject: [PATCH 4/4] Fixup

---
 llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
index e8b5c760be039..6c4f803d93c8b 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
@@ -73,7 +73,7 @@ bool checkIntegrityScopesTree(LVScope *Root) {
       if (Index)
         dbgs() << formatv("{0,8}: ", Index);
       else
-        dbgs() << formatv("{0,8:s}: ", ' ');
+        dbgs() << formatv("{0,8}: ", ' ');
     };
     auto PrintElement = [&](LVElement *Element, unsigned Index = 0) {
       PrintIndex(Index);



More information about the llvm-commits mailing list