1 //===-- SBType.cpp ----------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBType.h"
10 #include "SBReproducerPrivate.h"
11 #include "lldb/API/SBDefines.h"
12 #include "lldb/API/SBStream.h"
13 #include "lldb/API/SBTypeEnumMember.h"
14 #include "lldb/Core/Mangled.h"
15 #include "lldb/Symbol/CompilerType.h"
16 #include "lldb/Symbol/Type.h"
17 #include "lldb/Symbol/TypeSystem.h"
18 #include "lldb/Utility/ConstString.h"
19 #include "lldb/Utility/Stream.h"
21 #include "llvm/ADT/APSInt.h"
26 using namespace lldb_private
;
28 SBType::SBType() : m_opaque_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBType
); }
30 SBType::SBType(const CompilerType
&type
)
31 : m_opaque_sp(new TypeImpl(
32 CompilerType(type
.GetTypeSystem(), type
.GetOpaqueQualType()))) {}
34 SBType::SBType(const lldb::TypeSP
&type_sp
)
35 : m_opaque_sp(new TypeImpl(type_sp
)) {}
37 SBType::SBType(const lldb::TypeImplSP
&type_impl_sp
)
38 : m_opaque_sp(type_impl_sp
) {}
40 SBType::SBType(const SBType
&rhs
) : m_opaque_sp() {
41 LLDB_RECORD_CONSTRUCTOR(SBType
, (const lldb::SBType
&), rhs
);
44 m_opaque_sp
= rhs
.m_opaque_sp
;
48 // SBType::SBType (TypeImpl* impl) :
52 bool SBType::operator==(SBType
&rhs
) {
53 LLDB_RECORD_METHOD(bool, SBType
, operator==,(lldb::SBType
&), rhs
);
56 return !rhs
.IsValid();
61 return *m_opaque_sp
.get() == *rhs
.m_opaque_sp
.get();
64 bool SBType::operator!=(SBType
&rhs
) {
65 LLDB_RECORD_METHOD(bool, SBType
, operator!=,(lldb::SBType
&), rhs
);
73 return *m_opaque_sp
.get() != *rhs
.m_opaque_sp
.get();
76 lldb::TypeImplSP
SBType::GetSP() { return m_opaque_sp
; }
78 void SBType::SetSP(const lldb::TypeImplSP
&type_impl_sp
) {
79 m_opaque_sp
= type_impl_sp
;
82 SBType
&SBType::operator=(const SBType
&rhs
) {
83 LLDB_RECORD_METHOD(lldb::SBType
&, SBType
, operator=,(const lldb::SBType
&),
87 m_opaque_sp
= rhs
.m_opaque_sp
;
89 return LLDB_RECORD_RESULT(*this);
94 TypeImpl
&SBType::ref() {
95 if (m_opaque_sp
.get() == nullptr)
96 m_opaque_sp
= std::make_shared
<TypeImpl
>();
100 const TypeImpl
&SBType::ref() const {
101 // "const SBAddress &addr" should already have checked "addr.IsValid()" prior
102 // to calling this function. In case you didn't we will assert and die to let
104 assert(m_opaque_sp
.get());
108 bool SBType::IsValid() const {
109 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBType
, IsValid
);
110 return this->operator bool();
112 SBType::operator bool() const {
113 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBType
, operator bool);
115 if (m_opaque_sp
.get() == nullptr)
118 return m_opaque_sp
->IsValid();
121 uint64_t SBType::GetByteSize() {
122 LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBType
, GetByteSize
);
125 if (llvm::Optional
<uint64_t> size
=
126 m_opaque_sp
->GetCompilerType(false).GetByteSize(nullptr))
131 bool SBType::IsPointerType() {
132 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType
, IsPointerType
);
136 return m_opaque_sp
->GetCompilerType(true).IsPointerType();
139 bool SBType::IsArrayType() {
140 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType
, IsArrayType
);
144 return m_opaque_sp
->GetCompilerType(true).IsArrayType(nullptr, nullptr,
148 bool SBType::IsVectorType() {
149 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType
, IsVectorType
);
153 return m_opaque_sp
->GetCompilerType(true).IsVectorType(nullptr, nullptr);
156 bool SBType::IsReferenceType() {
157 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType
, IsReferenceType
);
161 return m_opaque_sp
->GetCompilerType(true).IsReferenceType();
164 SBType
SBType::GetPointerType() {
165 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType
, SBType
, GetPointerType
);
168 return LLDB_RECORD_RESULT(SBType());
170 return LLDB_RECORD_RESULT(
171 SBType(TypeImplSP(new TypeImpl(m_opaque_sp
->GetPointerType()))));
174 SBType
SBType::GetPointeeType() {
175 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType
, SBType
, GetPointeeType
);
178 return LLDB_RECORD_RESULT(SBType());
179 return LLDB_RECORD_RESULT(
180 SBType(TypeImplSP(new TypeImpl(m_opaque_sp
->GetPointeeType()))));
183 SBType
SBType::GetReferenceType() {
184 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType
, SBType
, GetReferenceType
);
187 return LLDB_RECORD_RESULT(SBType());
188 return LLDB_RECORD_RESULT(
189 SBType(TypeImplSP(new TypeImpl(m_opaque_sp
->GetReferenceType()))));
192 SBType
SBType::GetTypedefedType() {
193 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType
, SBType
, GetTypedefedType
);
196 return LLDB_RECORD_RESULT(SBType());
197 return LLDB_RECORD_RESULT(
198 SBType(TypeImplSP(new TypeImpl(m_opaque_sp
->GetTypedefedType()))));
201 SBType
SBType::GetDereferencedType() {
202 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType
, SBType
, GetDereferencedType
);
205 return LLDB_RECORD_RESULT(SBType());
206 return LLDB_RECORD_RESULT(
207 SBType(TypeImplSP(new TypeImpl(m_opaque_sp
->GetDereferencedType()))));
210 SBType
SBType::GetArrayElementType() {
211 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType
, SBType
, GetArrayElementType
);
214 return LLDB_RECORD_RESULT(SBType());
215 CompilerType canonical_type
=
216 m_opaque_sp
->GetCompilerType(true).GetCanonicalType();
217 return LLDB_RECORD_RESULT(
218 SBType(TypeImplSP(new TypeImpl(canonical_type
.GetArrayElementType()))));
221 SBType
SBType::GetArrayType(uint64_t size
) {
222 LLDB_RECORD_METHOD(lldb::SBType
, SBType
, GetArrayType
, (uint64_t), size
);
225 return LLDB_RECORD_RESULT(SBType());
226 return LLDB_RECORD_RESULT(SBType(TypeImplSP(
227 new TypeImpl(m_opaque_sp
->GetCompilerType(true).GetArrayType(size
)))));
230 SBType
SBType::GetVectorElementType() {
231 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType
, SBType
, GetVectorElementType
);
235 CompilerType vector_element_type
;
236 if (m_opaque_sp
->GetCompilerType(true).IsVectorType(&vector_element_type
,
238 type_sb
.SetSP(TypeImplSP(new TypeImpl(vector_element_type
)));
240 return LLDB_RECORD_RESULT(type_sb
);
243 bool SBType::IsFunctionType() {
244 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType
, IsFunctionType
);
248 return m_opaque_sp
->GetCompilerType(true).IsFunctionType();
251 bool SBType::IsPolymorphicClass() {
252 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType
, IsPolymorphicClass
);
256 return m_opaque_sp
->GetCompilerType(true).IsPolymorphicClass();
259 bool SBType::IsTypedefType() {
260 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType
, IsTypedefType
);
264 return m_opaque_sp
->GetCompilerType(true).IsTypedefType();
267 bool SBType::IsAnonymousType() {
268 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType
, IsAnonymousType
);
272 return m_opaque_sp
->GetCompilerType(true).IsAnonymousType();
275 lldb::SBType
SBType::GetFunctionReturnType() {
276 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType
, SBType
, GetFunctionReturnType
);
279 CompilerType
return_type(
280 m_opaque_sp
->GetCompilerType(true).GetFunctionReturnType());
281 if (return_type
.IsValid())
282 return LLDB_RECORD_RESULT(SBType(return_type
));
284 return LLDB_RECORD_RESULT(lldb::SBType());
287 lldb::SBTypeList
SBType::GetFunctionArgumentTypes() {
288 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeList
, SBType
,
289 GetFunctionArgumentTypes
);
291 SBTypeList sb_type_list
;
293 CompilerType
func_type(m_opaque_sp
->GetCompilerType(true));
294 size_t count
= func_type
.GetNumberOfFunctionArguments();
295 for (size_t i
= 0; i
< count
; i
++) {
296 sb_type_list
.Append(SBType(func_type
.GetFunctionArgumentAtIndex(i
)));
299 return LLDB_RECORD_RESULT(sb_type_list
);
302 uint32_t SBType::GetNumberOfMemberFunctions() {
303 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType
, GetNumberOfMemberFunctions
);
306 return m_opaque_sp
->GetCompilerType(true).GetNumMemberFunctions();
311 lldb::SBTypeMemberFunction
SBType::GetMemberFunctionAtIndex(uint32_t idx
) {
312 LLDB_RECORD_METHOD(lldb::SBTypeMemberFunction
, SBType
,
313 GetMemberFunctionAtIndex
, (uint32_t), idx
);
315 SBTypeMemberFunction sb_func_type
;
317 sb_func_type
.reset(new TypeMemberFunctionImpl(
318 m_opaque_sp
->GetCompilerType(true).GetMemberFunctionAtIndex(idx
)));
319 return LLDB_RECORD_RESULT(sb_func_type
);
322 lldb::SBType
SBType::GetUnqualifiedType() {
323 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType
, SBType
, GetUnqualifiedType
);
326 return LLDB_RECORD_RESULT(SBType());
327 return LLDB_RECORD_RESULT(
328 SBType(TypeImplSP(new TypeImpl(m_opaque_sp
->GetUnqualifiedType()))));
331 lldb::SBType
SBType::GetCanonicalType() {
332 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType
, SBType
, GetCanonicalType
);
335 return LLDB_RECORD_RESULT(
336 SBType(TypeImplSP(new TypeImpl(m_opaque_sp
->GetCanonicalType()))));
337 return LLDB_RECORD_RESULT(SBType());
340 lldb::BasicType
SBType::GetBasicType() {
341 LLDB_RECORD_METHOD_NO_ARGS(lldb::BasicType
, SBType
, GetBasicType
);
344 return m_opaque_sp
->GetCompilerType(false).GetBasicTypeEnumeration();
345 return eBasicTypeInvalid
;
348 SBType
SBType::GetBasicType(lldb::BasicType basic_type
) {
349 LLDB_RECORD_METHOD(lldb::SBType
, SBType
, GetBasicType
, (lldb::BasicType
),
352 if (IsValid() && m_opaque_sp
->IsValid())
353 return LLDB_RECORD_RESULT(SBType(
354 m_opaque_sp
->GetTypeSystem(false)->GetBasicTypeFromAST(basic_type
)));
355 return LLDB_RECORD_RESULT(SBType());
358 uint32_t SBType::GetNumberOfDirectBaseClasses() {
359 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType
, GetNumberOfDirectBaseClasses
);
362 return m_opaque_sp
->GetCompilerType(true).GetNumDirectBaseClasses();
366 uint32_t SBType::GetNumberOfVirtualBaseClasses() {
367 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType
, GetNumberOfVirtualBaseClasses
);
370 return m_opaque_sp
->GetCompilerType(true).GetNumVirtualBaseClasses();
374 uint32_t SBType::GetNumberOfFields() {
375 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType
, GetNumberOfFields
);
378 return m_opaque_sp
->GetCompilerType(true).GetNumFields();
382 bool SBType::GetDescription(SBStream
&description
,
383 lldb::DescriptionLevel description_level
) {
384 LLDB_RECORD_METHOD(bool, SBType
, GetDescription
,
385 (lldb::SBStream
&, lldb::DescriptionLevel
), description
,
388 Stream
&strm
= description
.ref();
391 m_opaque_sp
->GetDescription(strm
, description_level
);
393 strm
.PutCString("No value");
398 SBTypeMember
SBType::GetDirectBaseClassAtIndex(uint32_t idx
) {
399 LLDB_RECORD_METHOD(lldb::SBTypeMember
, SBType
, GetDirectBaseClassAtIndex
,
402 SBTypeMember sb_type_member
;
404 uint32_t bit_offset
= 0;
405 CompilerType base_class_type
=
406 m_opaque_sp
->GetCompilerType(true).GetDirectBaseClassAtIndex(
408 if (base_class_type
.IsValid())
409 sb_type_member
.reset(new TypeMemberImpl(
410 TypeImplSP(new TypeImpl(base_class_type
)), bit_offset
));
412 return LLDB_RECORD_RESULT(sb_type_member
);
415 SBTypeMember
SBType::GetVirtualBaseClassAtIndex(uint32_t idx
) {
416 LLDB_RECORD_METHOD(lldb::SBTypeMember
, SBType
, GetVirtualBaseClassAtIndex
,
419 SBTypeMember sb_type_member
;
421 uint32_t bit_offset
= 0;
422 CompilerType base_class_type
=
423 m_opaque_sp
->GetCompilerType(true).GetVirtualBaseClassAtIndex(
425 if (base_class_type
.IsValid())
426 sb_type_member
.reset(new TypeMemberImpl(
427 TypeImplSP(new TypeImpl(base_class_type
)), bit_offset
));
429 return LLDB_RECORD_RESULT(sb_type_member
);
432 SBTypeEnumMemberList
SBType::GetEnumMembers() {
433 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeEnumMemberList
, SBType
,
436 SBTypeEnumMemberList sb_enum_member_list
;
438 CompilerType
this_type(m_opaque_sp
->GetCompilerType(true));
439 if (this_type
.IsValid()) {
440 this_type
.ForEachEnumerator([&sb_enum_member_list
](
441 const CompilerType
&integer_type
,
443 const llvm::APSInt
&value
) -> bool {
444 SBTypeEnumMember
enum_member(
445 lldb::TypeEnumMemberImplSP(new TypeEnumMemberImpl(
446 lldb::TypeImplSP(new TypeImpl(integer_type
)), name
, value
)));
447 sb_enum_member_list
.Append(enum_member
);
448 return true; // Keep iterating
452 return LLDB_RECORD_RESULT(sb_enum_member_list
);
455 SBTypeMember
SBType::GetFieldAtIndex(uint32_t idx
) {
456 LLDB_RECORD_METHOD(lldb::SBTypeMember
, SBType
, GetFieldAtIndex
, (uint32_t),
459 SBTypeMember sb_type_member
;
461 CompilerType
this_type(m_opaque_sp
->GetCompilerType(false));
462 if (this_type
.IsValid()) {
463 uint64_t bit_offset
= 0;
464 uint32_t bitfield_bit_size
= 0;
465 bool is_bitfield
= false;
466 std::string name_sstr
;
467 CompilerType
field_type(this_type
.GetFieldAtIndex(
468 idx
, name_sstr
, &bit_offset
, &bitfield_bit_size
, &is_bitfield
));
469 if (field_type
.IsValid()) {
471 if (!name_sstr
.empty())
472 name
.SetCString(name_sstr
.c_str());
473 sb_type_member
.reset(
474 new TypeMemberImpl(TypeImplSP(new TypeImpl(field_type
)), bit_offset
,
475 name
, bitfield_bit_size
, is_bitfield
));
479 return LLDB_RECORD_RESULT(sb_type_member
);
482 bool SBType::IsTypeComplete() {
483 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType
, IsTypeComplete
);
487 return m_opaque_sp
->GetCompilerType(false).IsCompleteType();
490 uint32_t SBType::GetTypeFlags() {
491 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType
, GetTypeFlags
);
495 return m_opaque_sp
->GetCompilerType(true).GetTypeInfo();
498 const char *SBType::GetName() {
499 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBType
, GetName
);
503 return m_opaque_sp
->GetName().GetCString();
506 const char *SBType::GetDisplayTypeName() {
507 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBType
, GetDisplayTypeName
);
511 return m_opaque_sp
->GetDisplayTypeName().GetCString();
514 lldb::TypeClass
SBType::GetTypeClass() {
515 LLDB_RECORD_METHOD_NO_ARGS(lldb::TypeClass
, SBType
, GetTypeClass
);
518 return m_opaque_sp
->GetCompilerType(true).GetTypeClass();
519 return lldb::eTypeClassInvalid
;
522 uint32_t SBType::GetNumberOfTemplateArguments() {
523 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType
, GetNumberOfTemplateArguments
);
526 return m_opaque_sp
->GetCompilerType(false).GetNumTemplateArguments();
530 lldb::SBType
SBType::GetTemplateArgumentType(uint32_t idx
) {
531 LLDB_RECORD_METHOD(lldb::SBType
, SBType
, GetTemplateArgumentType
, (uint32_t),
535 return LLDB_RECORD_RESULT(SBType());
538 switch(GetTemplateArgumentKind(idx
)) {
539 case eTemplateArgumentKindType
:
540 type
= m_opaque_sp
->GetCompilerType(false).GetTypeTemplateArgument(idx
);
542 case eTemplateArgumentKindIntegral
:
543 type
= m_opaque_sp
->GetCompilerType(false)
544 .GetIntegralTemplateArgument(idx
)
551 return LLDB_RECORD_RESULT(SBType(type
));
552 return LLDB_RECORD_RESULT(SBType());
555 lldb::TemplateArgumentKind
SBType::GetTemplateArgumentKind(uint32_t idx
) {
556 LLDB_RECORD_METHOD(lldb::TemplateArgumentKind
, SBType
,
557 GetTemplateArgumentKind
, (uint32_t), idx
);
560 return m_opaque_sp
->GetCompilerType(false).GetTemplateArgumentKind(idx
);
561 return eTemplateArgumentKindNull
;
564 SBTypeList::SBTypeList() : m_opaque_up(new TypeListImpl()) {
565 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeList
);
568 SBTypeList::SBTypeList(const SBTypeList
&rhs
)
569 : m_opaque_up(new TypeListImpl()) {
570 LLDB_RECORD_CONSTRUCTOR(SBTypeList
, (const lldb::SBTypeList
&), rhs
);
572 for (uint32_t i
= 0, rhs_size
= const_cast<SBTypeList
&>(rhs
).GetSize();
574 Append(const_cast<SBTypeList
&>(rhs
).GetTypeAtIndex(i
));
577 bool SBTypeList::IsValid() {
578 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeList
, IsValid
);
579 return this->operator bool();
581 SBTypeList::operator bool() const {
582 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeList
, operator bool);
584 return (m_opaque_up
!= nullptr);
587 SBTypeList
&SBTypeList::operator=(const SBTypeList
&rhs
) {
588 LLDB_RECORD_METHOD(lldb::SBTypeList
&,
589 SBTypeList
, operator=,(const lldb::SBTypeList
&), rhs
);
592 m_opaque_up
.reset(new TypeListImpl());
593 for (uint32_t i
= 0, rhs_size
= const_cast<SBTypeList
&>(rhs
).GetSize();
595 Append(const_cast<SBTypeList
&>(rhs
).GetTypeAtIndex(i
));
597 return LLDB_RECORD_RESULT(*this);
600 void SBTypeList::Append(SBType type
) {
601 LLDB_RECORD_METHOD(void, SBTypeList
, Append
, (lldb::SBType
), type
);
604 m_opaque_up
->Append(type
.m_opaque_sp
);
607 SBType
SBTypeList::GetTypeAtIndex(uint32_t index
) {
608 LLDB_RECORD_METHOD(lldb::SBType
, SBTypeList
, GetTypeAtIndex
, (uint32_t),
612 return LLDB_RECORD_RESULT(SBType(m_opaque_up
->GetTypeAtIndex(index
)));
613 return LLDB_RECORD_RESULT(SBType());
616 uint32_t SBTypeList::GetSize() {
617 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeList
, GetSize
);
619 return m_opaque_up
->GetSize();
622 SBTypeList::~SBTypeList() {}
624 SBTypeMember::SBTypeMember() : m_opaque_up() {
625 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeMember
);
628 SBTypeMember::~SBTypeMember() {}
630 SBTypeMember::SBTypeMember(const SBTypeMember
&rhs
) : m_opaque_up() {
631 LLDB_RECORD_CONSTRUCTOR(SBTypeMember
, (const lldb::SBTypeMember
&), rhs
);
635 m_opaque_up
.reset(new TypeMemberImpl(rhs
.ref()));
639 lldb::SBTypeMember
&SBTypeMember::operator=(const lldb::SBTypeMember
&rhs
) {
640 LLDB_RECORD_METHOD(lldb::SBTypeMember
&,
641 SBTypeMember
, operator=,(const lldb::SBTypeMember
&), rhs
);
645 m_opaque_up
.reset(new TypeMemberImpl(rhs
.ref()));
647 return LLDB_RECORD_RESULT(*this);
650 bool SBTypeMember::IsValid() const {
651 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMember
, IsValid
);
652 return this->operator bool();
654 SBTypeMember::operator bool() const {
655 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMember
, operator bool);
657 return m_opaque_up
.get();
660 const char *SBTypeMember::GetName() {
661 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMember
, GetName
);
664 return m_opaque_up
->GetName().GetCString();
668 SBType
SBTypeMember::GetType() {
669 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType
, SBTypeMember
, GetType
);
673 sb_type
.SetSP(m_opaque_up
->GetTypeImpl());
675 return LLDB_RECORD_RESULT(sb_type
);
678 uint64_t SBTypeMember::GetOffsetInBytes() {
679 LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBTypeMember
, GetOffsetInBytes
);
682 return m_opaque_up
->GetBitOffset() / 8u;
686 uint64_t SBTypeMember::GetOffsetInBits() {
687 LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBTypeMember
, GetOffsetInBits
);
690 return m_opaque_up
->GetBitOffset();
694 bool SBTypeMember::IsBitfield() {
695 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeMember
, IsBitfield
);
698 return m_opaque_up
->GetIsBitfield();
702 uint32_t SBTypeMember::GetBitfieldSizeInBits() {
703 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeMember
, GetBitfieldSizeInBits
);
706 return m_opaque_up
->GetBitfieldBitSize();
710 bool SBTypeMember::GetDescription(lldb::SBStream
&description
,
711 lldb::DescriptionLevel description_level
) {
712 LLDB_RECORD_METHOD(bool, SBTypeMember
, GetDescription
,
713 (lldb::SBStream
&, lldb::DescriptionLevel
), description
,
716 Stream
&strm
= description
.ref();
719 const uint32_t bit_offset
= m_opaque_up
->GetBitOffset();
720 const uint32_t byte_offset
= bit_offset
/ 8u;
721 const uint32_t byte_bit_offset
= bit_offset
% 8u;
722 const char *name
= m_opaque_up
->GetName().GetCString();
724 strm
.Printf("+%u + %u bits: (", byte_offset
, byte_bit_offset
);
726 strm
.Printf("+%u: (", byte_offset
);
728 TypeImplSP
type_impl_sp(m_opaque_up
->GetTypeImpl());
730 type_impl_sp
->GetDescription(strm
, description_level
);
732 strm
.Printf(") %s", name
);
733 if (m_opaque_up
->GetIsBitfield()) {
734 const uint32_t bitfield_bit_size
= m_opaque_up
->GetBitfieldBitSize();
735 strm
.Printf(" : %u", bitfield_bit_size
);
738 strm
.PutCString("No value");
743 void SBTypeMember::reset(TypeMemberImpl
*type_member_impl
) {
744 m_opaque_up
.reset(type_member_impl
);
747 TypeMemberImpl
&SBTypeMember::ref() {
748 if (m_opaque_up
== nullptr)
749 m_opaque_up
.reset(new TypeMemberImpl());
753 const TypeMemberImpl
&SBTypeMember::ref() const { return *m_opaque_up
; }
755 SBTypeMemberFunction::SBTypeMemberFunction() : m_opaque_sp() {
756 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeMemberFunction
);
759 SBTypeMemberFunction::~SBTypeMemberFunction() {}
761 SBTypeMemberFunction::SBTypeMemberFunction(const SBTypeMemberFunction
&rhs
)
762 : m_opaque_sp(rhs
.m_opaque_sp
) {
763 LLDB_RECORD_CONSTRUCTOR(SBTypeMemberFunction
,
764 (const lldb::SBTypeMemberFunction
&), rhs
);
767 lldb::SBTypeMemberFunction
&SBTypeMemberFunction::
768 operator=(const lldb::SBTypeMemberFunction
&rhs
) {
770 lldb::SBTypeMemberFunction
&,
771 SBTypeMemberFunction
, operator=,(const lldb::SBTypeMemberFunction
&),
775 m_opaque_sp
= rhs
.m_opaque_sp
;
776 return LLDB_RECORD_RESULT(*this);
779 bool SBTypeMemberFunction::IsValid() const {
780 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMemberFunction
, IsValid
);
781 return this->operator bool();
783 SBTypeMemberFunction::operator bool() const {
784 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMemberFunction
, operator bool);
786 return m_opaque_sp
.get();
789 const char *SBTypeMemberFunction::GetName() {
790 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMemberFunction
, GetName
);
793 return m_opaque_sp
->GetName().GetCString();
797 const char *SBTypeMemberFunction::GetDemangledName() {
798 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMemberFunction
,
802 ConstString mangled_str
= m_opaque_sp
->GetMangledName();
804 Mangled
mangled(mangled_str
);
805 return mangled
.GetDemangledName(mangled
.GuessLanguage()).GetCString();
811 const char *SBTypeMemberFunction::GetMangledName() {
812 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMemberFunction
,
816 return m_opaque_sp
->GetMangledName().GetCString();
820 SBType
SBTypeMemberFunction::GetType() {
821 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType
, SBTypeMemberFunction
, GetType
);
825 sb_type
.SetSP(lldb::TypeImplSP(new TypeImpl(m_opaque_sp
->GetType())));
827 return LLDB_RECORD_RESULT(sb_type
);
830 lldb::SBType
SBTypeMemberFunction::GetReturnType() {
831 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType
, SBTypeMemberFunction
, GetReturnType
);
835 sb_type
.SetSP(lldb::TypeImplSP(new TypeImpl(m_opaque_sp
->GetReturnType())));
837 return LLDB_RECORD_RESULT(sb_type
);
840 uint32_t SBTypeMemberFunction::GetNumberOfArguments() {
841 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeMemberFunction
,
842 GetNumberOfArguments
);
845 return m_opaque_sp
->GetNumArguments();
849 lldb::SBType
SBTypeMemberFunction::GetArgumentTypeAtIndex(uint32_t i
) {
850 LLDB_RECORD_METHOD(lldb::SBType
, SBTypeMemberFunction
, GetArgumentTypeAtIndex
,
856 lldb::TypeImplSP(new TypeImpl(m_opaque_sp
->GetArgumentAtIndex(i
))));
858 return LLDB_RECORD_RESULT(sb_type
);
861 lldb::MemberFunctionKind
SBTypeMemberFunction::GetKind() {
862 LLDB_RECORD_METHOD_NO_ARGS(lldb::MemberFunctionKind
, SBTypeMemberFunction
,
866 return m_opaque_sp
->GetKind();
867 return lldb::eMemberFunctionKindUnknown
;
870 bool SBTypeMemberFunction::GetDescription(
871 lldb::SBStream
&description
, lldb::DescriptionLevel description_level
) {
872 LLDB_RECORD_METHOD(bool, SBTypeMemberFunction
, GetDescription
,
873 (lldb::SBStream
&, lldb::DescriptionLevel
), description
,
876 Stream
&strm
= description
.ref();
879 return m_opaque_sp
->GetDescription(strm
);
884 void SBTypeMemberFunction::reset(TypeMemberFunctionImpl
*type_member_impl
) {
885 m_opaque_sp
.reset(type_member_impl
);
888 TypeMemberFunctionImpl
&SBTypeMemberFunction::ref() {
890 m_opaque_sp
= std::make_shared
<TypeMemberFunctionImpl
>();
891 return *m_opaque_sp
.get();
894 const TypeMemberFunctionImpl
&SBTypeMemberFunction::ref() const {
895 return *m_opaque_sp
.get();
898 namespace lldb_private
{
902 void RegisterMethods
<SBType
>(Registry
&R
) {
903 LLDB_REGISTER_CONSTRUCTOR(SBType
, ());
904 LLDB_REGISTER_CONSTRUCTOR(SBType
, (const lldb::SBType
&));
905 LLDB_REGISTER_METHOD(bool, SBType
, operator==,(lldb::SBType
&));
906 LLDB_REGISTER_METHOD(bool, SBType
, operator!=,(lldb::SBType
&));
907 LLDB_REGISTER_METHOD(lldb::SBType
&,
908 SBType
, operator=,(const lldb::SBType
&));
909 LLDB_REGISTER_METHOD_CONST(bool, SBType
, IsValid
, ());
910 LLDB_REGISTER_METHOD_CONST(bool, SBType
, operator bool, ());
911 LLDB_REGISTER_METHOD(uint64_t, SBType
, GetByteSize
, ());
912 LLDB_REGISTER_METHOD(bool, SBType
, IsPointerType
, ());
913 LLDB_REGISTER_METHOD(bool, SBType
, IsArrayType
, ());
914 LLDB_REGISTER_METHOD(bool, SBType
, IsVectorType
, ());
915 LLDB_REGISTER_METHOD(bool, SBType
, IsReferenceType
, ());
916 LLDB_REGISTER_METHOD(lldb::SBType
, SBType
, GetPointerType
, ());
917 LLDB_REGISTER_METHOD(lldb::SBType
, SBType
, GetPointeeType
, ());
918 LLDB_REGISTER_METHOD(lldb::SBType
, SBType
, GetReferenceType
, ());
919 LLDB_REGISTER_METHOD(lldb::SBType
, SBType
, GetTypedefedType
, ());
920 LLDB_REGISTER_METHOD(lldb::SBType
, SBType
, GetDereferencedType
, ());
921 LLDB_REGISTER_METHOD(lldb::SBType
, SBType
, GetArrayElementType
, ());
922 LLDB_REGISTER_METHOD(lldb::SBType
, SBType
, GetArrayType
, (uint64_t));
923 LLDB_REGISTER_METHOD(lldb::SBType
, SBType
, GetVectorElementType
, ());
924 LLDB_REGISTER_METHOD(bool, SBType
, IsFunctionType
, ());
925 LLDB_REGISTER_METHOD(bool, SBType
, IsPolymorphicClass
, ());
926 LLDB_REGISTER_METHOD(bool, SBType
, IsTypedefType
, ());
927 LLDB_REGISTER_METHOD(bool, SBType
, IsAnonymousType
, ());
928 LLDB_REGISTER_METHOD(lldb::SBType
, SBType
, GetFunctionReturnType
, ());
929 LLDB_REGISTER_METHOD(lldb::SBTypeList
, SBType
, GetFunctionArgumentTypes
,
931 LLDB_REGISTER_METHOD(uint32_t, SBType
, GetNumberOfMemberFunctions
, ());
932 LLDB_REGISTER_METHOD(lldb::SBTypeMemberFunction
, SBType
,
933 GetMemberFunctionAtIndex
, (uint32_t));
934 LLDB_REGISTER_METHOD(lldb::SBType
, SBType
, GetUnqualifiedType
, ());
935 LLDB_REGISTER_METHOD(lldb::SBType
, SBType
, GetCanonicalType
, ());
936 LLDB_REGISTER_METHOD(lldb::BasicType
, SBType
, GetBasicType
, ());
937 LLDB_REGISTER_METHOD(lldb::SBType
, SBType
, GetBasicType
, (lldb::BasicType
));
938 LLDB_REGISTER_METHOD(uint32_t, SBType
, GetNumberOfDirectBaseClasses
, ());
939 LLDB_REGISTER_METHOD(uint32_t, SBType
, GetNumberOfVirtualBaseClasses
, ());
940 LLDB_REGISTER_METHOD(uint32_t, SBType
, GetNumberOfFields
, ());
941 LLDB_REGISTER_METHOD(bool, SBType
, GetDescription
,
942 (lldb::SBStream
&, lldb::DescriptionLevel
));
943 LLDB_REGISTER_METHOD(lldb::SBTypeMember
, SBType
, GetDirectBaseClassAtIndex
,
945 LLDB_REGISTER_METHOD(lldb::SBTypeMember
, SBType
, GetVirtualBaseClassAtIndex
,
947 LLDB_REGISTER_METHOD(lldb::SBTypeEnumMemberList
, SBType
, GetEnumMembers
,
949 LLDB_REGISTER_METHOD(lldb::SBTypeMember
, SBType
, GetFieldAtIndex
,
951 LLDB_REGISTER_METHOD(bool, SBType
, IsTypeComplete
, ());
952 LLDB_REGISTER_METHOD(uint32_t, SBType
, GetTypeFlags
, ());
953 LLDB_REGISTER_METHOD(const char *, SBType
, GetName
, ());
954 LLDB_REGISTER_METHOD(const char *, SBType
, GetDisplayTypeName
, ());
955 LLDB_REGISTER_METHOD(lldb::TypeClass
, SBType
, GetTypeClass
, ());
956 LLDB_REGISTER_METHOD(uint32_t, SBType
, GetNumberOfTemplateArguments
, ());
957 LLDB_REGISTER_METHOD(lldb::SBType
, SBType
, GetTemplateArgumentType
,
959 LLDB_REGISTER_METHOD(lldb::TemplateArgumentKind
, SBType
,
960 GetTemplateArgumentKind
, (uint32_t));
961 LLDB_REGISTER_CONSTRUCTOR(SBTypeList
, ());
962 LLDB_REGISTER_CONSTRUCTOR(SBTypeList
, (const lldb::SBTypeList
&));
963 LLDB_REGISTER_METHOD(bool, SBTypeList
, IsValid
, ());
964 LLDB_REGISTER_METHOD_CONST(bool, SBTypeList
, operator bool, ());
965 LLDB_REGISTER_METHOD(lldb::SBTypeList
&,
966 SBTypeList
, operator=,(const lldb::SBTypeList
&));
967 LLDB_REGISTER_METHOD(void, SBTypeList
, Append
, (lldb::SBType
));
968 LLDB_REGISTER_METHOD(lldb::SBType
, SBTypeList
, GetTypeAtIndex
, (uint32_t));
969 LLDB_REGISTER_METHOD(uint32_t, SBTypeList
, GetSize
, ());
970 LLDB_REGISTER_CONSTRUCTOR(SBTypeMember
, ());
971 LLDB_REGISTER_CONSTRUCTOR(SBTypeMember
, (const lldb::SBTypeMember
&));
972 LLDB_REGISTER_METHOD(lldb::SBTypeMember
&,
973 SBTypeMember
, operator=,(const lldb::SBTypeMember
&));
974 LLDB_REGISTER_METHOD_CONST(bool, SBTypeMember
, IsValid
, ());
975 LLDB_REGISTER_METHOD_CONST(bool, SBTypeMember
, operator bool, ());
976 LLDB_REGISTER_METHOD(const char *, SBTypeMember
, GetName
, ());
977 LLDB_REGISTER_METHOD(lldb::SBType
, SBTypeMember
, GetType
, ());
978 LLDB_REGISTER_METHOD(uint64_t, SBTypeMember
, GetOffsetInBytes
, ());
979 LLDB_REGISTER_METHOD(uint64_t, SBTypeMember
, GetOffsetInBits
, ());
980 LLDB_REGISTER_METHOD(bool, SBTypeMember
, IsBitfield
, ());
981 LLDB_REGISTER_METHOD(uint32_t, SBTypeMember
, GetBitfieldSizeInBits
, ());
982 LLDB_REGISTER_METHOD(bool, SBTypeMember
, GetDescription
,
983 (lldb::SBStream
&, lldb::DescriptionLevel
));
984 LLDB_REGISTER_CONSTRUCTOR(SBTypeMemberFunction
, ());
985 LLDB_REGISTER_CONSTRUCTOR(SBTypeMemberFunction
,
986 (const lldb::SBTypeMemberFunction
&));
987 LLDB_REGISTER_METHOD(
988 lldb::SBTypeMemberFunction
&,
989 SBTypeMemberFunction
, operator=,(const lldb::SBTypeMemberFunction
&));
990 LLDB_REGISTER_METHOD_CONST(bool, SBTypeMemberFunction
, IsValid
, ());
991 LLDB_REGISTER_METHOD_CONST(bool, SBTypeMemberFunction
, operator bool, ());
992 LLDB_REGISTER_METHOD(const char *, SBTypeMemberFunction
, GetName
, ());
993 LLDB_REGISTER_METHOD(const char *, SBTypeMemberFunction
, GetDemangledName
,
995 LLDB_REGISTER_METHOD(const char *, SBTypeMemberFunction
, GetMangledName
,
997 LLDB_REGISTER_METHOD(lldb::SBType
, SBTypeMemberFunction
, GetType
, ());
998 LLDB_REGISTER_METHOD(lldb::SBType
, SBTypeMemberFunction
, GetReturnType
, ());
999 LLDB_REGISTER_METHOD(uint32_t, SBTypeMemberFunction
, GetNumberOfArguments
,
1001 LLDB_REGISTER_METHOD(lldb::SBType
, SBTypeMemberFunction
,
1002 GetArgumentTypeAtIndex
, (uint32_t));
1003 LLDB_REGISTER_METHOD(lldb::MemberFunctionKind
, SBTypeMemberFunction
,
1005 LLDB_REGISTER_METHOD(bool, SBTypeMemberFunction
, GetDescription
,
1006 (lldb::SBStream
&, lldb::DescriptionLevel
));