[LoongArch][Clang] Make the parameters and return value of {x,}vorn.v builti ns ...
[llvm-project.git] / lldb / source / Plugins / SymbolFile / DWARF / DWARFFormValue.h
blob8ab9163e645feaae4d483442567856e2de160860
1 //===-- DWARFFormValue.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_DWARFFORMVALUE_H
10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFFORMVALUE_H
12 #include "DWARFDataExtractor.h"
13 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
14 #include <optional>
16 namespace lldb_private::plugin {
17 namespace dwarf {
18 class DWARFUnit;
19 class SymbolFileDWARF;
20 class DWARFDIE;
22 class DWARFFormValue {
23 public:
24 typedef llvm::DWARFFormValue::ValueType ValueType;
25 enum {
26 eValueTypeInvalid = 0,
27 eValueTypeUnsigned,
28 eValueTypeSigned,
29 eValueTypeCStr,
30 eValueTypeBlock
33 DWARFFormValue() = default;
34 DWARFFormValue(const DWARFUnit *unit) : m_unit(unit) {}
35 DWARFFormValue(const DWARFUnit *unit, dw_form_t form)
36 : m_unit(unit), m_form(form) {}
37 const DWARFUnit *GetUnit() const { return m_unit; }
38 void SetUnit(const DWARFUnit *unit) { m_unit = unit; }
39 dw_form_t Form() const { return m_form; }
40 dw_form_t &FormRef() { return m_form; }
41 void SetForm(dw_form_t form) { m_form = form; }
42 const ValueType &Value() const { return m_value; }
43 ValueType &ValueRef() { return m_value; }
44 void SetValue(const ValueType &val) { m_value = val; }
46 void Dump(Stream &s) const;
47 bool ExtractValue(const DWARFDataExtractor &data, lldb::offset_t *offset_ptr);
48 const uint8_t *BlockData() const;
49 static std::optional<uint8_t> GetFixedSize(dw_form_t form,
50 const DWARFUnit *u);
51 std::optional<uint8_t> GetFixedSize() const;
52 DWARFDIE Reference() const;
54 /// If this is a reference to another DIE, return the corresponding DWARFUnit
55 /// and DIE offset such that Unit->GetDIE(offset) produces the desired DIE.
56 /// Otherwise, a nullptr and unspecified offset are returned.
57 std::pair<DWARFUnit *, uint64_t> ReferencedUnitAndOffset() const;
59 uint64_t Reference(dw_offset_t offset) const;
60 bool Boolean() const { return m_value.uval != 0; }
61 uint64_t Unsigned() const { return m_value.uval; }
62 void SetUnsigned(uint64_t uval) { m_value.uval = uval; }
63 int64_t Signed() const { return m_value.sval; }
64 void SetSigned(int64_t sval) { m_value.sval = sval; }
65 const char *AsCString() const;
66 dw_addr_t Address() const;
67 bool IsValid() const { return m_form != 0; }
68 bool SkipValue(const DWARFDataExtractor &debug_info_data,
69 lldb::offset_t *offset_ptr) const;
70 static bool SkipValue(const dw_form_t form,
71 const DWARFDataExtractor &debug_info_data,
72 lldb::offset_t *offset_ptr, const DWARFUnit *unit);
73 static bool IsBlockForm(const dw_form_t form);
74 static bool IsDataForm(const dw_form_t form);
75 static int Compare(const DWARFFormValue &a, const DWARFFormValue &b);
76 void Clear();
77 static bool FormIsSupported(dw_form_t form);
79 protected:
80 // Compile unit where m_value was located.
81 // It may be different from compile unit where m_value refers to.
82 const DWARFUnit *m_unit = nullptr; // Unit for this form
83 dw_form_t m_form = dw_form_t(0); // Form for this value
84 ValueType m_value; // Contains all data for the form
86 } // namespace dwarf
87 } // namespace lldb_private::plugin
89 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFFORMVALUE_H