[LoongArch][Clang] Make the parameters and return value of {x,}vorn.v builti ns ...
[llvm-project.git] / lldb / source / Plugins / SymbolFile / DWARF / DWARFAttribute.h
blobe05ccc980d92ada7c68cf190d114514db958ae7a
1 //===-- DWARFAttribute.h ----------------------------------------*- C++ -*-===//
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 #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H
10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H
12 #include "DWARFDefines.h"
13 #include "DWARFFormValue.h"
14 #include "llvm/ADT/SmallVector.h"
15 #include <vector>
17 namespace lldb_private::plugin {
18 namespace dwarf {
19 class DWARFUnit;
21 class DWARFAttribute {
22 public:
23 DWARFAttribute(dw_attr_t attr, dw_form_t form,
24 DWARFFormValue::ValueType value)
25 : m_attr(attr), m_form(form), m_value(value) {}
27 dw_attr_t get_attr() const { return m_attr; }
28 dw_form_t get_form() const { return m_form; }
29 DWARFFormValue::ValueType get_value() const { return m_value; }
30 void get(dw_attr_t &attr, dw_form_t &form,
31 DWARFFormValue::ValueType &val) const {
32 attr = m_attr;
33 form = m_form;
34 val = m_value;
37 protected:
38 dw_attr_t m_attr;
39 dw_form_t m_form;
40 DWARFFormValue::ValueType m_value;
43 class DWARFAttributes {
44 public:
45 DWARFAttributes();
46 ~DWARFAttributes();
48 void Append(const DWARFFormValue &form_value, dw_offset_t attr_die_offset,
49 dw_attr_t attr);
50 DWARFUnit *CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; }
51 dw_offset_t DIEOffsetAtIndex(uint32_t i) const {
52 return m_infos[i].die_offset;
54 dw_attr_t AttributeAtIndex(uint32_t i) const {
55 return m_infos[i].attr.get_attr();
57 dw_form_t FormAtIndex(uint32_t i) const { return m_infos[i].attr.get_form(); }
58 DWARFFormValue::ValueType ValueAtIndex(uint32_t i) const {
59 return m_infos[i].attr.get_value();
61 bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const;
62 DWARFDIE FormValueAsReferenceAtIndex(uint32_t i) const;
63 DWARFDIE FormValueAsReference(dw_attr_t attr) const;
64 uint32_t FindAttributeIndex(dw_attr_t attr) const;
65 void Clear() { m_infos.clear(); }
66 size_t Size() const { return m_infos.size(); }
68 protected:
69 struct AttributeValue {
70 DWARFUnit *cu; // Keep the compile unit with each attribute in
71 // case we have DW_FORM_ref_addr values
72 dw_offset_t die_offset;
73 DWARFAttribute attr;
75 typedef llvm::SmallVector<AttributeValue, 8> collection;
76 collection m_infos;
78 } // namespace dwarf
79 } // namespace lldb_private::plugin
81 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H