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

Konrad Kleine via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 10:46:12 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:

I've tried it locally and this would indeed work but it is ugly in terms of needed  non-static casts

```c++
uint64_t Offset = Op->getRawOperand(Operand);
uint64_t EndOffset = Offset + Op->getRawOperand(Operand - 1);
OS << formatv(
    " {0:$[ ]@[x2]}",
    make_range((const uint8_t *)Expr->getData().begin() + Offset,
               (const uint8_t *)Expr->getData().begin() + EndOffset));
```

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


More information about the llvm-commits mailing list