xref: /llvm-project/lldb/include/lldb/API/SBType.h (revision 30367cb5982dfdab2655401f020711311e7d78b9)
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 LLDB_API SBTypeStaticField {
111 public:
112   SBTypeStaticField();
113 
114   SBTypeStaticField(const lldb::SBTypeStaticField &rhs);
115   lldb::SBTypeStaticField &operator=(const lldb::SBTypeStaticField &rhs);
116 
117   ~SBTypeStaticField();
118 
119   explicit operator bool() const;
120 
121   bool IsValid() const;
122 
123   const char *GetName();
124 
125   const char *GetMangledName();
126 
127   lldb::SBType GetType();
128 
129   lldb::SBValue GetConstantValue(lldb::SBTarget target);
130 
131 protected:
132   friend class SBType;
133 
134   explicit SBTypeStaticField(lldb_private::CompilerDecl decl);
135 
136   std::unique_ptr<lldb_private::CompilerDecl> m_opaque_up;
137 };
138 
139 class SBType {
140 public:
141   SBType();
142 
143   SBType(const lldb::SBType &rhs);
144 
145   ~SBType();
146 
147   explicit operator bool() const;
148 
149   bool IsValid() const;
150 
151   uint64_t GetByteSize();
152 
153   uint64_t GetByteAlign();
154 
155   bool IsPointerType();
156 
157   bool IsReferenceType();
158 
159   bool IsFunctionType();
160 
161   bool IsPolymorphicClass();
162 
163   bool IsArrayType();
164 
165   bool IsVectorType();
166 
167   bool IsTypedefType();
168 
169   bool IsAnonymousType();
170 
171   bool IsScopedEnumerationType();
172 
173   bool IsAggregateType();
174 
175   lldb::SBType GetPointerType();
176 
177   lldb::SBType GetPointeeType();
178 
179   lldb::SBType GetReferenceType();
180 
181   lldb::SBType GetTypedefedType();
182 
183   lldb::SBType GetDereferencedType();
184 
185   lldb::SBType GetUnqualifiedType();
186 
187   lldb::SBType GetArrayElementType();
188 
189   lldb::SBType GetArrayType(uint64_t size);
190 
191   lldb::SBType GetVectorElementType();
192 
193   lldb::SBType GetCanonicalType();
194 
195   lldb::SBType GetEnumerationIntegerType();
196 
197   // Get the "lldb::BasicType" enumeration for a type. If a type is not a basic
198   // type eBasicTypeInvalid will be returned
199   lldb::BasicType GetBasicType();
200 
201   // The call below confusing and should really be renamed to "CreateBasicType"
202   lldb::SBType GetBasicType(lldb::BasicType type);
203 
204   uint32_t GetNumberOfFields();
205 
206   uint32_t GetNumberOfDirectBaseClasses();
207 
208   uint32_t GetNumberOfVirtualBaseClasses();
209 
210   lldb::SBTypeMember GetFieldAtIndex(uint32_t idx);
211 
212   lldb::SBTypeMember GetDirectBaseClassAtIndex(uint32_t idx);
213 
214   lldb::SBTypeMember GetVirtualBaseClassAtIndex(uint32_t idx);
215 
216   lldb::SBTypeStaticField GetStaticFieldWithName(const char *name);
217 
218   lldb::SBTypeEnumMemberList GetEnumMembers();
219 
220   uint32_t GetNumberOfTemplateArguments();
221 
222   lldb::SBType GetTemplateArgumentType(uint32_t idx);
223 
224   /// Return the TemplateArgumentKind of the template argument at index idx.
225   /// Variadic argument packs are automatically expanded.
226   lldb::TemplateArgumentKind GetTemplateArgumentKind(uint32_t idx);
227 
228   lldb::SBType GetFunctionReturnType();
229 
230   lldb::SBTypeList GetFunctionArgumentTypes();
231 
232   uint32_t GetNumberOfMemberFunctions();
233 
234   lldb::SBTypeMemberFunction GetMemberFunctionAtIndex(uint32_t idx);
235 
236   lldb::SBModule GetModule();
237 
238   const char *GetName();
239 
240   const char *GetDisplayTypeName();
241 
242   lldb::TypeClass GetTypeClass();
243 
244   bool IsTypeComplete();
245 
246   uint32_t GetTypeFlags();
247 
248   bool GetDescription(lldb::SBStream &description,
249                       lldb::DescriptionLevel description_level);
250 
251   lldb::SBType FindDirectNestedType(const char *name);
252 
253   lldb::SBType &operator=(const lldb::SBType &rhs);
254 
255   bool operator==(lldb::SBType &rhs);
256 
257   bool operator!=(lldb::SBType &rhs);
258 
259 protected:
260   lldb_private::TypeImpl &ref();
261 
262   const lldb_private::TypeImpl &ref() const;
263 
264   lldb::TypeImplSP GetSP();
265 
266   void SetSP(const lldb::TypeImplSP &type_impl_sp);
267 
268   lldb::TypeImplSP m_opaque_sp;
269 
270   friend class SBFunction;
271   friend class SBModule;
272   friend class SBTarget;
273   friend class SBTypeEnumMember;
274   friend class SBTypeEnumMemberList;
275   friend class SBTypeNameSpecifier;
276   friend class SBTypeMember;
277   friend class SBTypeMemberFunction;
278   friend class SBTypeStaticField;
279   friend class SBTypeList;
280   friend class SBValue;
281   friend class SBWatchpoint;
282 
283   friend class lldb_private::python::SWIGBridge;
284 
285   SBType(const lldb_private::CompilerType &);
286   SBType(const lldb::TypeSP &);
287   SBType(const lldb::TypeImplSP &);
288 };
289 
290 class SBTypeList {
291 public:
292   SBTypeList();
293 
294   SBTypeList(const lldb::SBTypeList &rhs);
295 
296   ~SBTypeList();
297 
298   lldb::SBTypeList &operator=(const lldb::SBTypeList &rhs);
299 
300   explicit operator bool() const;
301 
302   bool IsValid();
303 
304   void Append(lldb::SBType type);
305 
306   lldb::SBType GetTypeAtIndex(uint32_t index);
307 
308   uint32_t GetSize();
309 
310 private:
311   std::unique_ptr<lldb_private::TypeListImpl> m_opaque_up;
312   friend class SBModule;
313   friend class SBCompileUnit;
314 };
315 
316 } // namespace lldb
317 
318 #endif // LLDB_API_SBTYPE_H
319