[llvm] 453d0e2 - [llvm][DebugInfo] formatv in LVScope (#192008)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 03:17:36 PDT 2026


Author: Konrad Kleine
Date: 2026-04-14T12:17:31+02:00
New Revision: 453d0e229d7a0288a65d16a15ba79948c4fff303

URL: https://github.com/llvm/llvm-project/commit/453d0e229d7a0288a65d16a15ba79948c4fff303
DIFF: https://github.com/llvm/llvm-project/commit/453d0e229d7a0288a65d16a15ba79948c4fff303.diff

LOG: [llvm][DebugInfo] formatv in LVScope (#192008)

This relates to #35980.

Added: 
    

Modified: 
    llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp
index e03932622b259..0d5fb3348bd5a 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp
@@ -1184,10 +1184,10 @@ void LVScopeArray::printExtra(raw_ostream &OS, bool Full) const {
 void LVScopeCompileUnit::addSize(LVScope *Scope, LVOffset Lower,
                                  LVOffset Upper) {
   LLVM_DEBUG({
-    dbgs() << format(
-        "CU [0x%08" PRIx64 "], Scope [0x%08" PRIx64 "], Range [0x%08" PRIx64
-        ":0x%08" PRIx64 "], Size = %" PRId64 "\n",
-        getOffset(), Scope->getOffset(), Lower, Upper, Upper - Lower);
+    dbgs() << formatv("CU [{0:x8}], Scope [{1:x8}], Range [{2:x8}"
+                      ":{3:x8}], Size = {4}\n",
+                      getOffset(), Scope->getOffset(), Lower, Upper,
+                      Upper - Lower);
   });
 
   // There is no need to check for a previous entry, as we are traversing the
@@ -1482,7 +1482,7 @@ void LVScopeCompileUnit::printWarnings(raw_ostream &OS, bool Full) const {
   if (options().getInternalTag() && getReader().isBinaryTypeELF()) {
     PrintHeader("Unsupported DWARF Tags");
     for (LVTagOffsetsMap::const_reference Entry : DebugTags) {
-      OS << format("\n0x%02x", (unsigned)Entry.first) << ", "
+      OS << formatv("\n{0:x2}", (unsigned)Entry.first) << ", "
          << dwarf::TagString(Entry.first) << "\n";
       unsigned Count = 0;
       for (const LVOffset &Offset : Entry.second)
@@ -1498,7 +1498,7 @@ void LVScopeCompileUnit::printWarnings(raw_ostream &OS, bool Full) const {
       // Symbol basic information.
       LVSymbol *Symbol = Entry.second;
       OS << hexSquareString(Entry.first) << " {Coverage} "
-         << format("%.2f%%", Symbol->getCoveragePercentage()) << " "
+         << formatv("{0:f2}%", Symbol->getCoveragePercentage()) << " "
          << formattedKind(Symbol->kind()) << " "
          << formattedName(Symbol->getName()) << "\n";
     }
@@ -1527,8 +1527,8 @@ void LVScopeCompileUnit::printWarnings(raw_ostream &OS, bool Full) const {
 void LVScopeCompileUnit::printTotals(raw_ostream &OS) const {
   OS << "\nTotals by lexical level:\n";
   for (size_t Index = 1; Index <= MaxSeenLevel; ++Index)
-    OS << format("[%03d]: %10d (%6.2f%%)\n", Index, Totals[Index].first,
-                 Totals[Index].second);
+    OS << formatv("[{0,0+3}]: {1,10} ({2,6:f2}%)\n", Index, Totals[Index].first,
+                  Totals[Index].second);
 }
 
 void LVScopeCompileUnit::printScopeSize(const LVScope *Scope, raw_ostream &OS) {
@@ -1540,7 +1540,7 @@ void LVScopeCompileUnit::printScopeSize(const LVScope *Scope, raw_ostream &OS) {
     // implementation-defined rounding inside printing functions.
     float Percentage =
         rint((float(Size) / CUContributionSize) * 100.0 * 100.0) / 100.0;
-    OS << format("%10" PRId64 " (%6.2f%%) : ", Size, Percentage);
+    OS << formatv("{0,10} ({1,6:f2}%) : ", Size, Percentage);
     Scope->print(OS);
 
     // Keep record of the total sizes at each lexical level.
@@ -1607,11 +1607,12 @@ void LVScopeCompileUnit::printSummary(raw_ostream &OS, const LVCounter &Counter,
                                       const char *Header) const {
   std::string Separator = std::string(29, '-');
   auto PrintSeparator = [&]() { OS << Separator << "\n"; };
+  const char *Fmt = "{0,-9}{1,9}  {2,9}\n";
   auto PrintHeadingRow = [&](const char *T, const char *U, const char *V) {
-    OS << format("%-9s%9s  %9s\n", T, U, V);
+    OS << formatv(Fmt, T, U, V);
   };
   auto PrintDataRow = [&](const char *T, unsigned U, unsigned V) {
-    OS << format("%-9s%9d  %9d\n", T, U, V);
+    OS << formatv(Fmt, T, U, V);
   };
 
   OS << "\n";


        


More information about the llvm-commits mailing list