[LoongArch][Clang] Make the parameters and return value of {x,}vorn.v builti ns ...
[llvm-project.git] / lldb / source / Plugins / SymbolFile / DWARF / DWARFBaseDIE.cpp
blobc2ebeed4c860d43980ad6fb6f1caa120e8bf117a
1 //===-- DWARFBaseDIE.cpp --------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "DWARFBaseDIE.h"
11 #include "DWARFUnit.h"
12 #include "DWARFDebugInfoEntry.h"
13 #include "SymbolFileDWARF.h"
15 #include "lldb/Core/Module.h"
16 #include "lldb/Symbol/ObjectFile.h"
17 #include "lldb/Utility/Log.h"
18 #include <optional>
20 using namespace lldb_private;
21 using namespace lldb_private::plugin::dwarf;
23 std::optional<DIERef> DWARFBaseDIE::GetDIERef() const {
24 if (!IsValid())
25 return std::nullopt;
27 return DIERef(m_cu->GetSymbolFileDWARF().GetFileIndex(),
28 m_cu->GetDebugSection(), m_die->GetOffset());
31 dw_tag_t DWARFBaseDIE::Tag() const {
32 if (m_die)
33 return m_die->Tag();
34 else
35 return llvm::dwarf::DW_TAG_null;
38 const char *DWARFBaseDIE::GetAttributeValueAsString(const dw_attr_t attr,
39 const char *fail_value) const {
40 if (IsValid())
41 return m_die->GetAttributeValueAsString(GetCU(), attr, fail_value);
42 else
43 return fail_value;
46 uint64_t DWARFBaseDIE::GetAttributeValueAsUnsigned(const dw_attr_t attr,
47 uint64_t fail_value) const {
48 if (IsValid())
49 return m_die->GetAttributeValueAsUnsigned(GetCU(), attr, fail_value);
50 else
51 return fail_value;
54 std::optional<uint64_t>
55 DWARFBaseDIE::GetAttributeValueAsOptionalUnsigned(const dw_attr_t attr) const {
56 if (IsValid())
57 return m_die->GetAttributeValueAsOptionalUnsigned(GetCU(), attr);
58 return std::nullopt;
61 uint64_t DWARFBaseDIE::GetAttributeValueAsAddress(const dw_attr_t attr,
62 uint64_t fail_value) const {
63 if (IsValid())
64 return m_die->GetAttributeValueAsAddress(GetCU(), attr, fail_value);
65 else
66 return fail_value;
69 lldb::user_id_t DWARFBaseDIE::GetID() const {
70 const std::optional<DIERef> &ref = this->GetDIERef();
71 if (ref)
72 return ref->get_id();
74 return LLDB_INVALID_UID;
77 const char *DWARFBaseDIE::GetName() const {
78 if (IsValid())
79 return m_die->GetName(m_cu);
80 else
81 return nullptr;
84 lldb::ModuleSP DWARFBaseDIE::GetModule() const {
85 SymbolFileDWARF *dwarf = GetDWARF();
86 if (dwarf)
87 return dwarf->GetObjectFile()->GetModule();
88 else
89 return lldb::ModuleSP();
92 dw_offset_t DWARFBaseDIE::GetOffset() const {
93 if (IsValid())
94 return m_die->GetOffset();
95 else
96 return DW_INVALID_OFFSET;
99 SymbolFileDWARF *DWARFBaseDIE::GetDWARF() const {
100 if (m_cu)
101 return &m_cu->GetSymbolFileDWARF();
102 else
103 return nullptr;
106 bool DWARFBaseDIE::HasChildren() const {
107 return m_die && m_die->HasChildren();
110 bool DWARFBaseDIE::Supports_DW_AT_APPLE_objc_complete_type() const {
111 return IsValid() && GetDWARF()->Supports_DW_AT_APPLE_objc_complete_type(m_cu);
114 DWARFAttributes DWARFBaseDIE::GetAttributes(Recurse recurse) const {
115 if (IsValid())
116 return m_die->GetAttributes(m_cu, recurse);
117 return DWARFAttributes();
120 namespace lldb_private::plugin {
121 namespace dwarf {
122 bool operator==(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs) {
123 return lhs.GetDIE() == rhs.GetDIE() && lhs.GetCU() == rhs.GetCU();
126 bool operator!=(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs) {
127 return !(lhs == rhs);
129 } // namespace dwarf
130 } // namespace lldb_private::plugin
132 const DWARFDataExtractor &DWARFBaseDIE::GetData() const {
133 // Clients must check if this DIE is valid before calling this function.
134 assert(IsValid());
135 return m_cu->GetData();