[llvm] [llvm][DebugInfo] Use formatv in DWARFExpressionPrinter (PR #191993)

Konrad Kleine via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 10:24:08 PDT 2026


================
@@ -176,7 +176,8 @@ void printDwarfExpression(const DWARFExpression *E, raw_ostream &OS,
     if (!printOp(&Op, OS, DumpOpts, E, U) && !DumpOpts.PrintRegisterOnly) {
       uint64_t FailOffset = Op.getEndOffset();
       while (FailOffset < E->getData().size())
-        OS << format(" %02x", static_cast<uint8_t>(E->getData()[FailOffset++]));
+        OS << formatv(" {0:x-2}",
+                      static_cast<uint8_t>(E->getData()[FailOffset++]));
----------------
kwk wrote:

This works for a simple test:

```c++
  StringRef SRef("12345678"); // in ASCII this is 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38
  int Offset = 3;
  EXPECT_EQ("0x34 0x35 0x36 0x37 0x38", formatv("{0:$[ ]@[x2]}", make_range(SRef.begin()+Offset, SRef.end())).str());
```

Maybe I can translate it to be used here as well.

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


More information about the llvm-commits mailing list