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