xref: /freebsd/contrib/llvm-project/lldb/include/lldb/API/SBType.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
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   /// Returns the value of the non-type template parameter at index \c idx.
225   /// If \c idx is out-of-bounds or the template parameter doesn't have
226   /// a value, returns an empty SBValue.
227   ///
228   /// This function will expand parameter packs.
229   lldb::SBValue GetTemplateArgumentValue(lldb::SBTarget target, uint32_t idx);
230 
231   /// Return the TemplateArgumentKind of the template argument at index idx.
232   /// Variadic argument packs are automatically expanded.
233   lldb::TemplateArgumentKind GetTemplateArgumentKind(uint32_t idx);
234 
235   lldb::SBType GetFunctionReturnType();
236 
237   lldb::SBTypeList GetFunctionArgumentTypes();
238 
239   uint32_t GetNumberOfMemberFunctions();
240 
241   lldb::SBTypeMemberFunction GetMemberFunctionAtIndex(uint32_t idx);
242 
243   lldb::SBModule GetModule();
244 
245   const char *GetName();
246 
247   const char *GetDisplayTypeName();
248 
249   lldb::TypeClass GetTypeClass();
250 
251   bool IsTypeComplete();
252 
253   uint32_t GetTypeFlags();
254 
255   bool GetDescription(lldb::SBStream &description,
256                       lldb::DescriptionLevel description_level);
257 
258   lldb::SBType FindDirectNestedType(const char *name);
259 
260   lldb::SBType &operator=(const lldb::SBType &rhs);
261 
262   bool operator==(lldb::SBType &rhs);
263 
264   bool operator!=(lldb::SBType &rhs);
265 
266 protected:
267   lldb_private::TypeImpl &ref();
268 
269   const lldb_private::TypeImpl &ref() const;
270 
271   lldb::TypeImplSP GetSP();
272 
273   void SetSP(const lldb::TypeImplSP &type_impl_sp);
274 
275   lldb::TypeImplSP m_opaque_sp;
276 
277   friend class SBFunction;
278   friend class SBModule;
279   friend class SBTarget;
280   friend class SBTypeEnumMember;
281   friend class SBTypeEnumMemberList;
282   friend class SBTypeNameSpecifier;
283   friend class SBTypeMember;
284   friend class SBTypeMemberFunction;
285   friend class SBTypeStaticField;
286   friend class SBTypeList;
287   friend class SBValue;
288   friend class SBWatchpoint;
289 
290   friend class lldb_private::python::SWIGBridge;
291 
292   SBType(const lldb_private::CompilerType &);
293   SBType(const lldb::TypeSP &);
294   SBType(const lldb::TypeImplSP &);
295 };
296 
297 class SBTypeList {
298 public:
299   SBTypeList();
300 
301   SBTypeList(const lldb::SBTypeList &rhs);
302 
303   ~SBTypeList();
304 
305   lldb::SBTypeList &operator=(const lldb::SBTypeList &rhs);
306 
307   explicit operator bool() const;
308 
309   bool IsValid();
310 
311   void Append(lldb::SBType type);
312 
313   lldb::SBType GetTypeAtIndex(uint32_t index);
314 
315   uint32_t GetSize();
316 
317 private:
318   std::unique_ptr<lldb_private::TypeListImpl> m_opaque_up;
319   friend class SBModule;
320   friend class SBCompileUnit;
321 };
322 
323 } // namespace lldb
324 
325 #endif // LLDB_API_SBTYPE_H
326