[llvm] [NFC] Extract Printing portions of DWARFCFIProgram to new files (PR #143762)
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 12 15:32:03 PDT 2025
================
@@ -0,0 +1,41 @@
+//===- DWARFCFIPrinter.h ----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_DWARF_DWARFCFIPRINTER_H
+#define LLVM_DEBUGINFO_DWARF_DWARFCFIPRINTER_H
+
+#include "llvm/DebugInfo/DWARF/DWARFCFIProgram.h"
+
+namespace llvm {
+
+struct DIDumpOptions;
+
+namespace dwarf {
+
+// This class is separate from CFIProgram to decouple CFIPrograms from the
+// enclosing DWARF dies and type units, which allows using them in lower-level
+// places without build dependencies.
+
+class CFIPrinter {
+public:
+ static void print(const CFIProgram &P, raw_ostream &OS,
+ DIDumpOptions &DumpOpts, unsigned IndentLevel,
+ std::optional<uint64_t> Address);
+
+ static void printOperand(raw_ostream &OS, DIDumpOptions &DumpOpts,
+ const CFIProgram &P,
+ const CFIProgram::Instruction &Instr,
+ unsigned OperandIdx, uint64_t Operand,
+ std::optional<uint64_t> &Address);
+};
----------------
igorkudrin wrote:
Now, as only the public interface of `CFIProgram` is used, you can remove the `CFIPrinter` class, making `print()` a free function. `printOperand()` can be a static function in the implementation file, as its only caller is `print()`.
https://github.com/llvm/llvm-project/pull/143762
More information about the llvm-commits
mailing list