[llvm] [DebugNames] Implement Entry::GetParentEntry query (PR #78760)
Greg Clayton via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 19 14:35:48 PST 2024
================
@@ -460,6 +460,16 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
/// Returns the Offset of the DIE within the containing CU or TU.
std::optional<uint64_t> getDIEUnitOffset() const;
+ /// Returns true if this Entry has information about its parent DIE (i.e. if
+ /// it has an IDX_parent attribute)
+ bool hasParentInformation() const;
+
+ /// Returns the Entry corresponding to the parent of the DIE represented by
+ /// `this` Entry. If the parent is not in the table, nullopt is returned.
+ /// Precondition: hasParentInformation() == true.
+ /// An error is returned for ill-formed tables.
+ Expected<std::optional<DWARFDebugNames::Entry>> getParentDIEEntry() const;
----------------
clayborg wrote:
Since we have the boolean that tell us if the entry has a parent index case, can we remove the need for an error if we get a `std::nullopt` back but `Entry::hasParentInformation() == true`? I do agree this is nice for `llvm-dwarfdump` to get an error back and display it. If we just use the error somewhere, then it is worth adding.
https://github.com/llvm/llvm-project/pull/78760
More information about the llvm-commits
mailing list