[llvm] [llvm-objdump] Add inlined function display support (PR #142246)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 5 01:31:06 PDT 2025


================
@@ -22,60 +23,108 @@
 namespace llvm {
 namespace objdump {
 
+/// Base class for representing the location of a source-level variable or
+/// an inlined function.
+class LiveElement {
+protected:
+  const char *Name;
+  DWARFUnit *Unit;
+  const DWARFDie FuncDie;
+
+public:
+  LiveElement(const char *Name, DWARFUnit *Unit, const DWARFDie FuncDie)
+      : Name(Name), Unit(Unit), FuncDie(FuncDie) {}
+
+  virtual ~LiveElement() {};
+  const char *getName() const { return Name; }
+  DWARFUnit *getDwarfUnit() const { return Unit; }
+  const DWARFDie getFuncDie() const { return FuncDie; }
+
+  virtual bool liveAtAddress(object::SectionedAddress Addr) = 0;
+  virtual void print(raw_ostream &OS, const MCRegisterInfo &MRI) const = 0;
+  virtual void dump(raw_ostream &OS) const = 0;
+  virtual void printElementLine(raw_ostream &OS,
+                                object::SectionedAddress Address,
+                                bool IsEnd) const {}
+};
+
+class InlinedFunction : public LiveElement {
+  DWARFDie InlinedFuncDie;
+  DWARFAddressRange Range;
+
+public:
+  InlinedFunction(const char *FunctionName, DWARFUnit *Unit,
+                  const DWARFDie FuncDie, const DWARFDie InlinedFuncDie,
+                  DWARFAddressRange &Range)
+      : LiveElement(FunctionName, Unit, FuncDie),
+        InlinedFuncDie(InlinedFuncDie), Range(Range) {}
+
+  virtual ~InlinedFunction() {}
----------------
jh7370 wrote:

This is not needed because the base class has a virtual destructor (https://stackoverflow.com/a/5610164).

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


More information about the llvm-commits mailing list