1 //===-- SBType.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 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_API_SBTYPE_H
10 #define LLDB_API_SBTYPE_H
11 
12 #include "lldb/API/SBDefines.h"
13 
14 namespace lldb {
15 
16 class SBTypeList;
17 
18 class LLDB_API SBTypeMember {
19 public:
20   SBTypeMember();
21 
22   SBTypeMember(const lldb::SBTypeMember &rhs);
23 
24   ~SBTypeMember();
25 
26   lldb::SBTypeMember &operator=(const lldb::SBTypeMember &rhs);
27 
28   explicit operator bool() const;
29 
30   bool IsValid() const;
31 
32   const char *GetName();
33 
34   lldb::SBType GetType();
35 
36   uint64_t GetOffsetInBytes();
37 
38   uint64_t GetOffsetInBits();
39 
40   bool IsBitfield();
41 
42   uint32_t GetBitfieldSizeInBits();
43 
44   bool GetDescription(lldb::SBStream &description,
45                       lldb::DescriptionLevel description_level);
46 
47 protected:
48   friend class SBType;
49 
50   void reset(lldb_private::TypeMemberImpl *);
51 
52   lldb_private::TypeMemberImpl &ref();
53 
54   const lldb_private::TypeMemberImpl &ref() const;
55 
56   std::unique_ptr<lldb_private::TypeMemberImpl> m_opaque_up;
57 };
58 
59 class SBTypeMemberFunction {
60 public:
61   SBTypeMemberFunction();
62 
63   SBTypeMemberFunction(const lldb::SBTypeMemberFunction &rhs);
64 
65   ~SBTypeMemberFunction();
66 
67   lldb::SBTypeMemberFunction &operator=(const lldb::SBTypeMemberFunction &rhs);
68 
69   explicit operator bool() const;
70 
71   bool IsValid() const;
72 
73   const char *GetName();
74 
75   const char *GetDemangledName();
76 
77   const char *GetMangledName();
78 
79   lldb::SBType GetType();
80 
81   lldb::SBType GetReturnType();
82 
83   uint32_t GetNumberOfArguments();
84 
85   lldb::SBType GetArgumentTypeAtIndex(uint32_t);
86 
87   lldb::MemberFunctionKind GetKind();
88 
89   bool GetDescription(lldb::SBStream &description,
90                       lldb::DescriptionLevel description_level);
91 
92 protected:
93   friend class SBType;
94 
95   void reset(lldb_private::TypeMemberFunctionImpl *);
96 
97   lldb_private::TypeMemberFunctionImpl &ref();
98 
99   const lldb_private::TypeMemberFunctionImpl &ref() const;
100 
101   lldb::TypeMemberFunctionImplSP m_opaque_sp;
102 };
103 
104 class SBType {
105 public:
106   SBType();
107 
108   SBType(const lldb::SBType &rhs);
109 
110   ~SBType();
111 
112   explicit operator bool() const;
113 
114   bool IsValid() const;
115 
116   uint64_t GetByteSize();
117 
118   bool IsPointerType();
119 
120   bool IsReferenceType();
121 
122   bool IsFunctionType();
123 
124   bool IsPolymorphicClass();
125 
126   bool IsArrayType();
127 
128   bool IsVectorType();
129 
130   bool IsTypedefType();
131 
132   bool IsAnonymousType();
133 
134   bool IsScopedEnumerationType();
135 
136   bool IsAggregateType();
137 
138   lldb::SBType GetPointerType();
139 
140   lldb::SBType GetPointeeType();
141 
142   lldb::SBType GetReferenceType();
143 
144   lldb::SBType GetTypedefedType();
145 
146   lldb::SBType GetDereferencedType();
147 
148   lldb::SBType GetUnqualifiedType();
149 
150   lldb::SBType GetArrayElementType();
151 
152   lldb::SBType GetArrayType(uint64_t size);
153 
154   lldb::SBType GetVectorElementType();
155 
156   lldb::SBType GetCanonicalType();
157 
158   lldb::SBType GetEnumerationIntegerType();
159 
160   // Get the "lldb::BasicType" enumeration for a type. If a type is not a basic
161   // type eBasicTypeInvalid will be returned
162   lldb::BasicType GetBasicType();
163 
164   // The call below confusing and should really be renamed to "CreateBasicType"
165   lldb::SBType GetBasicType(lldb::BasicType type);
166 
167   uint32_t GetNumberOfFields();
168 
169   uint32_t GetNumberOfDirectBaseClasses();
170 
171   uint32_t GetNumberOfVirtualBaseClasses();
172 
173   lldb::SBTypeMember GetFieldAtIndex(uint32_t idx);
174 
175   lldb::SBTypeMember GetDirectBaseClassAtIndex(uint32_t idx);
176 
177   lldb::SBTypeMember GetVirtualBaseClassAtIndex(uint32_t idx);
178 
179   lldb::SBTypeEnumMemberList GetEnumMembers();
180 
181   uint32_t GetNumberOfTemplateArguments();
182 
183   lldb::SBType GetTemplateArgumentType(uint32_t idx);
184 
185   /// Return the TemplateArgumentKind of the template argument at index idx.
186   /// Variadic argument packs are automatically expanded.
187   lldb::TemplateArgumentKind GetTemplateArgumentKind(uint32_t idx);
188 
189   lldb::SBType GetFunctionReturnType();
190 
191   lldb::SBTypeList GetFunctionArgumentTypes();
192 
193   uint32_t GetNumberOfMemberFunctions();
194 
195   lldb::SBTypeMemberFunction GetMemberFunctionAtIndex(uint32_t idx);
196 
197   lldb::SBModule GetModule();
198 
199   const char *GetName();
200 
201   const char *GetDisplayTypeName();
202 
203   lldb::TypeClass GetTypeClass();
204 
205   bool IsTypeComplete();
206 
207   uint32_t GetTypeFlags();
208 
209   bool GetDescription(lldb::SBStream &description,
210                       lldb::DescriptionLevel description_level);
211 
212   lldb::SBType &operator=(const lldb::SBType &rhs);
213 
214   bool operator==(lldb::SBType &rhs);
215 
216   bool operator!=(lldb::SBType &rhs);
217 
218 protected:
219   lldb_private::TypeImpl &ref();
220 
221   const lldb_private::TypeImpl &ref() const;
222 
223   lldb::TypeImplSP GetSP();
224 
225   void SetSP(const lldb::TypeImplSP &type_impl_sp);
226 
227   lldb::TypeImplSP m_opaque_sp;
228 
229   friend class SBFunction;
230   friend class SBModule;
231   friend class SBTarget;
232   friend class SBTypeEnumMember;
233   friend class SBTypeEnumMemberList;
234   friend class SBTypeNameSpecifier;
235   friend class SBTypeMember;
236   friend class SBTypeMemberFunction;
237   friend class SBTypeList;
238   friend class SBValue;
239 
240   SBType(const lldb_private::CompilerType &);
241   SBType(const lldb::TypeSP &);
242   SBType(const lldb::TypeImplSP &);
243 };
244 
245 class SBTypeList {
246 public:
247   SBTypeList();
248 
249   SBTypeList(const lldb::SBTypeList &rhs);
250 
251   ~SBTypeList();
252 
253   lldb::SBTypeList &operator=(const lldb::SBTypeList &rhs);
254 
255   explicit operator bool() const;
256 
257   bool IsValid();
258 
259   void Append(lldb::SBType type);
260 
261   lldb::SBType GetTypeAtIndex(uint32_t index);
262 
263   uint32_t GetSize();
264 
265 private:
266   std::unique_ptr<lldb_private::TypeListImpl> m_opaque_up;
267   friend class SBModule;
268   friend class SBCompileUnit;
269 };
270 
271 } // namespace lldb
272 
273 #endif // LLDB_API_SBTYPE_H
274