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

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 10:57:51 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++]));
----------------
s-barannikov wrote:

> @s-barannikov do you think we could have `getDataArray()` instead of changing `getData()`? This is something I would like to implement in another change if I may.

There aren't many users of `getData()` (8?), AFAICS, so I'd prefer the return type changed. There is `llvm::toStringRef()` in `StringExtras.h` that can help if the caller really needs `StringRef` (e.g., to pass it to some other interface that expects `StringRef`).

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


More information about the llvm-commits mailing list