[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / lldb / source / API / SBType.cpp
blob33b67ad4c004313193513721533b1593d4971eb9
1 //===-- SBType.cpp ----------------------------------------------*- 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 //===----------------------------------------------------------------------===//
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"
23 #include <memory>
25 using namespace lldb;
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);
43 if (this != &rhs) {
44 m_opaque_sp = rhs.m_opaque_sp;
48 // SBType::SBType (TypeImpl* impl) :
49 // m_opaque_up(impl)
50 //{}
52 bool SBType::operator==(SBType &rhs) {
53 LLDB_RECORD_METHOD(bool, SBType, operator==,(lldb::SBType &), rhs);
55 if (!IsValid())
56 return !rhs.IsValid();
58 if (!rhs.IsValid())
59 return false;
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);
67 if (!IsValid())
68 return rhs.IsValid();
70 if (!rhs.IsValid())
71 return true;
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 &),
84 rhs);
86 if (this != &rhs) {
87 m_opaque_sp = rhs.m_opaque_sp;
89 return LLDB_RECORD_RESULT(*this);
92 SBType::~SBType() {}
94 TypeImpl &SBType::ref() {
95 if (m_opaque_sp.get() == nullptr)
96 m_opaque_sp = std::make_shared<TypeImpl>();
97 return *m_opaque_sp;
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
103 // you know.
104 assert(m_opaque_sp.get());
105 return *m_opaque_sp;
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)
116 return false;
118 return m_opaque_sp->IsValid();
121 uint64_t SBType::GetByteSize() {
122 LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBType, GetByteSize);
124 if (IsValid())
125 if (llvm::Optional<uint64_t> size =
126 m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr))
127 return *size;
128 return 0;
131 bool SBType::IsPointerType() {
132 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsPointerType);
134 if (!IsValid())
135 return false;
136 return m_opaque_sp->GetCompilerType(true).IsPointerType();
139 bool SBType::IsArrayType() {
140 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsArrayType);
142 if (!IsValid())
143 return false;
144 return m_opaque_sp->GetCompilerType(true).IsArrayType(nullptr, nullptr,
145 nullptr);
148 bool SBType::IsVectorType() {
149 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsVectorType);
151 if (!IsValid())
152 return false;
153 return m_opaque_sp->GetCompilerType(true).IsVectorType(nullptr, nullptr);
156 bool SBType::IsReferenceType() {
157 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsReferenceType);
159 if (!IsValid())
160 return false;
161 return m_opaque_sp->GetCompilerType(true).IsReferenceType();
164 SBType SBType::GetPointerType() {
165 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetPointerType);
167 if (!IsValid())
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);
177 if (!IsValid())
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);
186 if (!IsValid())
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);
195 if (!IsValid())
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);
204 if (!IsValid())
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);
213 if (!IsValid())
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);
224 if (!IsValid())
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);
233 SBType type_sb;
234 if (IsValid()) {
235 CompilerType vector_element_type;
236 if (m_opaque_sp->GetCompilerType(true).IsVectorType(&vector_element_type,
237 nullptr))
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);
246 if (!IsValid())
247 return false;
248 return m_opaque_sp->GetCompilerType(true).IsFunctionType();
251 bool SBType::IsPolymorphicClass() {
252 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsPolymorphicClass);
254 if (!IsValid())
255 return false;
256 return m_opaque_sp->GetCompilerType(true).IsPolymorphicClass();
259 bool SBType::IsTypedefType() {
260 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsTypedefType);
262 if (!IsValid())
263 return false;
264 return m_opaque_sp->GetCompilerType(true).IsTypedefType();
267 bool SBType::IsAnonymousType() {
268 LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsAnonymousType);
270 if (!IsValid())
271 return false;
272 return m_opaque_sp->GetCompilerType(true).IsAnonymousType();
275 lldb::SBType SBType::GetFunctionReturnType() {
276 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetFunctionReturnType);
278 if (IsValid()) {
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;
292 if (IsValid()) {
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);
305 if (IsValid()) {
306 return m_opaque_sp->GetCompilerType(true).GetNumMemberFunctions();
308 return 0;
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;
316 if (IsValid())
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);
325 if (!IsValid())
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);
334 if (IsValid())
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);
343 if (IsValid())
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),
350 basic_type);
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);
361 if (IsValid())
362 return m_opaque_sp->GetCompilerType(true).GetNumDirectBaseClasses();
363 return 0;
366 uint32_t SBType::GetNumberOfVirtualBaseClasses() {
367 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfVirtualBaseClasses);
369 if (IsValid())
370 return m_opaque_sp->GetCompilerType(true).GetNumVirtualBaseClasses();
371 return 0;
374 uint32_t SBType::GetNumberOfFields() {
375 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfFields);
377 if (IsValid())
378 return m_opaque_sp->GetCompilerType(true).GetNumFields();
379 return 0;
382 bool SBType::GetDescription(SBStream &description,
383 lldb::DescriptionLevel description_level) {
384 LLDB_RECORD_METHOD(bool, SBType, GetDescription,
385 (lldb::SBStream &, lldb::DescriptionLevel), description,
386 description_level);
388 Stream &strm = description.ref();
390 if (m_opaque_sp) {
391 m_opaque_sp->GetDescription(strm, description_level);
392 } else
393 strm.PutCString("No value");
395 return true;
398 SBTypeMember SBType::GetDirectBaseClassAtIndex(uint32_t idx) {
399 LLDB_RECORD_METHOD(lldb::SBTypeMember, SBType, GetDirectBaseClassAtIndex,
400 (uint32_t), idx);
402 SBTypeMember sb_type_member;
403 if (IsValid()) {
404 uint32_t bit_offset = 0;
405 CompilerType base_class_type =
406 m_opaque_sp->GetCompilerType(true).GetDirectBaseClassAtIndex(
407 idx, &bit_offset);
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,
417 (uint32_t), idx);
419 SBTypeMember sb_type_member;
420 if (IsValid()) {
421 uint32_t bit_offset = 0;
422 CompilerType base_class_type =
423 m_opaque_sp->GetCompilerType(true).GetVirtualBaseClassAtIndex(
424 idx, &bit_offset);
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,
434 GetEnumMembers);
436 SBTypeEnumMemberList sb_enum_member_list;
437 if (IsValid()) {
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,
442 ConstString name,
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),
457 idx);
459 SBTypeMember sb_type_member;
460 if (IsValid()) {
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()) {
470 ConstString name;
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);
485 if (!IsValid())
486 return false;
487 return m_opaque_sp->GetCompilerType(false).IsCompleteType();
490 uint32_t SBType::GetTypeFlags() {
491 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetTypeFlags);
493 if (!IsValid())
494 return 0;
495 return m_opaque_sp->GetCompilerType(true).GetTypeInfo();
498 const char *SBType::GetName() {
499 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBType, GetName);
501 if (!IsValid())
502 return "";
503 return m_opaque_sp->GetName().GetCString();
506 const char *SBType::GetDisplayTypeName() {
507 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBType, GetDisplayTypeName);
509 if (!IsValid())
510 return "";
511 return m_opaque_sp->GetDisplayTypeName().GetCString();
514 lldb::TypeClass SBType::GetTypeClass() {
515 LLDB_RECORD_METHOD_NO_ARGS(lldb::TypeClass, SBType, GetTypeClass);
517 if (IsValid())
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);
525 if (IsValid())
526 return m_opaque_sp->GetCompilerType(false).GetNumTemplateArguments();
527 return 0;
530 lldb::SBType SBType::GetTemplateArgumentType(uint32_t idx) {
531 LLDB_RECORD_METHOD(lldb::SBType, SBType, GetTemplateArgumentType, (uint32_t),
532 idx);
534 if (!IsValid())
535 return LLDB_RECORD_RESULT(SBType());
537 CompilerType type;
538 switch(GetTemplateArgumentKind(idx)) {
539 case eTemplateArgumentKindType:
540 type = m_opaque_sp->GetCompilerType(false).GetTypeTemplateArgument(idx);
541 break;
542 case eTemplateArgumentKindIntegral:
543 type = m_opaque_sp->GetCompilerType(false)
544 .GetIntegralTemplateArgument(idx)
545 ->type;
546 break;
547 default:
548 break;
550 if (type.IsValid())
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);
559 if (IsValid())
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();
573 i < rhs_size; i++)
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);
591 if (this != &rhs) {
592 m_opaque_up.reset(new TypeListImpl());
593 for (uint32_t i = 0, rhs_size = const_cast<SBTypeList &>(rhs).GetSize();
594 i < rhs_size; i++)
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);
603 if (type.IsValid())
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),
609 index);
611 if (m_opaque_up)
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);
633 if (this != &rhs) {
634 if (rhs.IsValid())
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);
643 if (this != &rhs) {
644 if (rhs.IsValid())
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);
663 if (m_opaque_up)
664 return m_opaque_up->GetName().GetCString();
665 return nullptr;
668 SBType SBTypeMember::GetType() {
669 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeMember, GetType);
671 SBType sb_type;
672 if (m_opaque_up) {
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);
681 if (m_opaque_up)
682 return m_opaque_up->GetBitOffset() / 8u;
683 return 0;
686 uint64_t SBTypeMember::GetOffsetInBits() {
687 LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBTypeMember, GetOffsetInBits);
689 if (m_opaque_up)
690 return m_opaque_up->GetBitOffset();
691 return 0;
694 bool SBTypeMember::IsBitfield() {
695 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeMember, IsBitfield);
697 if (m_opaque_up)
698 return m_opaque_up->GetIsBitfield();
699 return false;
702 uint32_t SBTypeMember::GetBitfieldSizeInBits() {
703 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeMember, GetBitfieldSizeInBits);
705 if (m_opaque_up)
706 return m_opaque_up->GetBitfieldBitSize();
707 return 0;
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,
714 description_level);
716 Stream &strm = description.ref();
718 if (m_opaque_up) {
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();
723 if (byte_bit_offset)
724 strm.Printf("+%u + %u bits: (", byte_offset, byte_bit_offset);
725 else
726 strm.Printf("+%u: (", byte_offset);
728 TypeImplSP type_impl_sp(m_opaque_up->GetTypeImpl());
729 if (type_impl_sp)
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);
737 } else {
738 strm.PutCString("No value");
740 return true;
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());
750 return *m_opaque_up;
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) {
769 LLDB_RECORD_METHOD(
770 lldb::SBTypeMemberFunction &,
771 SBTypeMemberFunction, operator=,(const lldb::SBTypeMemberFunction &),
772 rhs);
774 if (this != &rhs)
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);
792 if (m_opaque_sp)
793 return m_opaque_sp->GetName().GetCString();
794 return nullptr;
797 const char *SBTypeMemberFunction::GetDemangledName() {
798 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMemberFunction,
799 GetDemangledName);
801 if (m_opaque_sp) {
802 ConstString mangled_str = m_opaque_sp->GetMangledName();
803 if (mangled_str) {
804 Mangled mangled(mangled_str);
805 return mangled.GetDemangledName(mangled.GuessLanguage()).GetCString();
808 return nullptr;
811 const char *SBTypeMemberFunction::GetMangledName() {
812 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMemberFunction,
813 GetMangledName);
815 if (m_opaque_sp)
816 return m_opaque_sp->GetMangledName().GetCString();
817 return nullptr;
820 SBType SBTypeMemberFunction::GetType() {
821 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeMemberFunction, GetType);
823 SBType sb_type;
824 if (m_opaque_sp) {
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);
833 SBType sb_type;
834 if (m_opaque_sp) {
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);
844 if (m_opaque_sp)
845 return m_opaque_sp->GetNumArguments();
846 return 0;
849 lldb::SBType SBTypeMemberFunction::GetArgumentTypeAtIndex(uint32_t i) {
850 LLDB_RECORD_METHOD(lldb::SBType, SBTypeMemberFunction, GetArgumentTypeAtIndex,
851 (uint32_t), i);
853 SBType sb_type;
854 if (m_opaque_sp) {
855 sb_type.SetSP(
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,
863 GetKind);
865 if (m_opaque_sp)
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,
874 description_level);
876 Stream &strm = description.ref();
878 if (m_opaque_sp)
879 return m_opaque_sp->GetDescription(strm);
881 return false;
884 void SBTypeMemberFunction::reset(TypeMemberFunctionImpl *type_member_impl) {
885 m_opaque_sp.reset(type_member_impl);
888 TypeMemberFunctionImpl &SBTypeMemberFunction::ref() {
889 if (!m_opaque_sp)
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 {
899 namespace repro {
901 template <>
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,
930 ());
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,
944 (uint32_t));
945 LLDB_REGISTER_METHOD(lldb::SBTypeMember, SBType, GetVirtualBaseClassAtIndex,
946 (uint32_t));
947 LLDB_REGISTER_METHOD(lldb::SBTypeEnumMemberList, SBType, GetEnumMembers,
948 ());
949 LLDB_REGISTER_METHOD(lldb::SBTypeMember, SBType, GetFieldAtIndex,
950 (uint32_t));
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,
958 (uint32_t));
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,
994 ());
995 LLDB_REGISTER_METHOD(const char *, SBTypeMemberFunction, GetMangledName,
996 ());
997 LLDB_REGISTER_METHOD(lldb::SBType, SBTypeMemberFunction, GetType, ());
998 LLDB_REGISTER_METHOD(lldb::SBType, SBTypeMemberFunction, GetReturnType, ());
999 LLDB_REGISTER_METHOD(uint32_t, SBTypeMemberFunction, GetNumberOfArguments,
1000 ());
1001 LLDB_REGISTER_METHOD(lldb::SBType, SBTypeMemberFunction,
1002 GetArgumentTypeAtIndex, (uint32_t));
1003 LLDB_REGISTER_METHOD(lldb::MemberFunctionKind, SBTypeMemberFunction,
1004 GetKind, ());
1005 LLDB_REGISTER_METHOD(bool, SBTypeMemberFunction, GetDescription,
1006 (lldb::SBStream &, lldb::DescriptionLevel));