LLDB mainline
SBType.cpp
Go to the documentation of this file.
1//===-- SBType.cpp --------------------------------------------------------===//
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#include "lldb/API/SBType.h"
10#include "Utils.h"
11#include "lldb/API/SBDefines.h"
12#include "lldb/API/SBModule.h"
13#include "lldb/API/SBStream.h"
15#include "lldb/Core/Mangled.h"
19#include "lldb/Symbol/Type.h"
24#include "lldb/Utility/Scalar.h"
25#include "lldb/Utility/Stream.h"
26
27#include "llvm/ADT/APSInt.h"
28#include "llvm/Support/MathExtras.h"
29
30#include <memory>
31#include <optional>
32
33using namespace lldb;
34using namespace lldb_private;
35
37
38SBType::SBType(const CompilerType &type) : m_opaque_sp(new TypeImpl(type)) {}
39
41 : m_opaque_sp(new TypeImpl(type_sp)) {}
42
43SBType::SBType(const lldb::TypeImplSP &type_impl_sp)
44 : m_opaque_sp(type_impl_sp) {}
45
47 LLDB_INSTRUMENT_VA(this, rhs);
48
49 if (this != &rhs) {
51 }
52}
53
54// SBType::SBType (TypeImpl* impl) :
55// m_opaque_up(impl)
56//{}
57//
59 LLDB_INSTRUMENT_VA(this, rhs);
60
61 if (!IsValid())
62 return !rhs.IsValid();
63
64 if (!rhs.IsValid())
65 return false;
66
67 return *m_opaque_sp.get() == *rhs.m_opaque_sp.get();
68}
69
71 LLDB_INSTRUMENT_VA(this, rhs);
72
73 if (!IsValid())
74 return rhs.IsValid();
75
76 if (!rhs.IsValid())
77 return true;
78
79 return *m_opaque_sp.get() != *rhs.m_opaque_sp.get();
80}
81
83
84void SBType::SetSP(const lldb::TypeImplSP &type_impl_sp) {
85 m_opaque_sp = type_impl_sp;
86}
87
89 LLDB_INSTRUMENT_VA(this, rhs);
90
91 if (this != &rhs) {
93 }
94 return *this;
95}
96
97SBType::~SBType() = default;
98
100 if (m_opaque_sp.get() == nullptr)
101 m_opaque_sp = std::make_shared<TypeImpl>();
102 return *m_opaque_sp;
103}
104
105const TypeImpl &SBType::ref() const {
106 // "const SBAddress &addr" should already have checked "addr.IsValid()" prior
107 // to calling this function. In case you didn't we will assert and die to let
108 // you know.
109 assert(m_opaque_sp.get());
110 return *m_opaque_sp;
111}
112
113bool SBType::IsValid() const {
114 LLDB_INSTRUMENT_VA(this);
115 return this->operator bool();
116}
117SBType::operator bool() const {
118 LLDB_INSTRUMENT_VA(this);
119
120 if (m_opaque_sp.get() == nullptr)
121 return false;
122
123 return m_opaque_sp->IsValid();
124}
125
127 LLDB_INSTRUMENT_VA(this);
128
129 if (IsValid())
130 if (std::optional<uint64_t> size =
131 m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr))
132 return *size;
133 return 0;
134}
135
137 LLDB_INSTRUMENT_VA(this);
138
139 if (!IsValid())
140 return 0;
141
142 std::optional<uint64_t> bit_align =
143 m_opaque_sp->GetCompilerType(/*prefer_dynamic=*/false)
144 .GetTypeBitAlign(nullptr);
145 return llvm::divideCeil(bit_align.value_or(0), 8);
146}
147
149 LLDB_INSTRUMENT_VA(this);
150
151 if (!IsValid())
152 return false;
153 return m_opaque_sp->GetCompilerType(true).IsPointerType();
154}
155
157 LLDB_INSTRUMENT_VA(this);
158
159 if (!IsValid())
160 return false;
161 return m_opaque_sp->GetCompilerType(true).IsArrayType(nullptr, nullptr,
162 nullptr);
163}
164
166 LLDB_INSTRUMENT_VA(this);
167
168 if (!IsValid())
169 return false;
170 return m_opaque_sp->GetCompilerType(true).IsVectorType(nullptr, nullptr);
171}
172
174 LLDB_INSTRUMENT_VA(this);
175
176 if (!IsValid())
177 return false;
178 return m_opaque_sp->GetCompilerType(true).IsReferenceType();
179}
180
182 LLDB_INSTRUMENT_VA(this);
183
184 if (!IsValid())
185 return SBType();
186
187 return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointerType())));
188}
189
191 LLDB_INSTRUMENT_VA(this);
192
193 if (!IsValid())
194 return SBType();
195 return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointeeType())));
196}
197
199 LLDB_INSTRUMENT_VA(this);
200
201 if (!IsValid())
202 return SBType();
203 return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetReferenceType())));
204}
205
207 LLDB_INSTRUMENT_VA(this);
208
209 if (!IsValid())
210 return SBType();
211 return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetTypedefedType())));
212}
213
215 LLDB_INSTRUMENT_VA(this);
216
217 if (!IsValid())
218 return SBType();
219 return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetDereferencedType())));
220}
221
223 LLDB_INSTRUMENT_VA(this);
224
225 if (!IsValid())
226 return SBType();
227 return SBType(TypeImplSP(new TypeImpl(
228 m_opaque_sp->GetCompilerType(true).GetArrayElementType(nullptr))));
229}
230
232 LLDB_INSTRUMENT_VA(this, size);
233
234 if (!IsValid())
235 return SBType();
236 return SBType(TypeImplSP(
237 new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayType(size))));
238}
239
241 LLDB_INSTRUMENT_VA(this);
242
243 SBType type_sb;
244 if (IsValid()) {
245 CompilerType vector_element_type;
246 if (m_opaque_sp->GetCompilerType(true).IsVectorType(&vector_element_type,
247 nullptr))
248 type_sb.SetSP(TypeImplSP(new TypeImpl(vector_element_type)));
249 }
250 return type_sb;
251}
252
254 LLDB_INSTRUMENT_VA(this);
255
256 if (!IsValid())
257 return false;
258 return m_opaque_sp->GetCompilerType(true).IsFunctionType();
259}
260
262 LLDB_INSTRUMENT_VA(this);
263
264 if (!IsValid())
265 return false;
266 return m_opaque_sp->GetCompilerType(true).IsPolymorphicClass();
267}
268
270 LLDB_INSTRUMENT_VA(this);
271
272 if (!IsValid())
273 return false;
274 return m_opaque_sp->GetCompilerType(true).IsTypedefType();
275}
276
278 LLDB_INSTRUMENT_VA(this);
279
280 if (!IsValid())
281 return false;
282 return m_opaque_sp->GetCompilerType(true).IsAnonymousType();
283}
284
286 LLDB_INSTRUMENT_VA(this);
287
288 if (!IsValid())
289 return false;
290 return m_opaque_sp->GetCompilerType(true).IsScopedEnumerationType();
291}
292
294 LLDB_INSTRUMENT_VA(this);
295
296 if (!IsValid())
297 return false;
298 return m_opaque_sp->GetCompilerType(true).IsAggregateType();
299}
300
302 LLDB_INSTRUMENT_VA(this);
303
304 if (IsValid()) {
305 CompilerType return_type(
306 m_opaque_sp->GetCompilerType(true).GetFunctionReturnType());
307 if (return_type.IsValid())
308 return SBType(return_type);
309 }
310 return lldb::SBType();
311}
312
314 LLDB_INSTRUMENT_VA(this);
315
316 SBTypeList sb_type_list;
317 if (IsValid()) {
318 CompilerType func_type(m_opaque_sp->GetCompilerType(true));
319 size_t count = func_type.GetNumberOfFunctionArguments();
320 for (size_t i = 0; i < count; i++) {
321 sb_type_list.Append(SBType(func_type.GetFunctionArgumentAtIndex(i)));
322 }
323 }
324 return sb_type_list;
325}
326
328 LLDB_INSTRUMENT_VA(this);
329
330 if (IsValid()) {
331 return m_opaque_sp->GetCompilerType(true).GetNumMemberFunctions();
332 }
333 return 0;
334}
335
337 LLDB_INSTRUMENT_VA(this, idx);
338
339 SBTypeMemberFunction sb_func_type;
340 if (IsValid())
341 sb_func_type.reset(new TypeMemberFunctionImpl(
342 m_opaque_sp->GetCompilerType(true).GetMemberFunctionAtIndex(idx)));
343 return sb_func_type;
344}
345
347
349 : m_opaque_up(decl ? std::make_unique<CompilerDecl>(decl) : nullptr) {}
350
352 LLDB_INSTRUMENT_VA(this, rhs);
353
355}
356
358 LLDB_INSTRUMENT_VA(this, rhs);
359
361 return *this;
362}
363
365
366SBTypeStaticField::operator bool() const {
367 LLDB_INSTRUMENT_VA(this);
368
369 return IsValid();
370}
371
373 LLDB_INSTRUMENT_VA(this);
374
375 return m_opaque_up != nullptr;
376}
377
379 LLDB_INSTRUMENT_VA(this);
380
381 if (!IsValid())
382 return "";
383 return m_opaque_up->GetName().GetCString();
384}
385
387 LLDB_INSTRUMENT_VA(this);
388
389 if (!IsValid())
390 return "";
391 return m_opaque_up->GetMangledName().GetCString();
392}
393
395 LLDB_INSTRUMENT_VA(this);
396
397 if (!IsValid())
398 return SBType();
399 return SBType(m_opaque_up->GetType());
400}
401
403 LLDB_INSTRUMENT_VA(this, target);
404
405 if (!IsValid())
406 return SBValue();
407
408 Scalar value = m_opaque_up->GetConstantValue();
409 if (!value.IsValid())
410 return SBValue();
411 DataExtractor data;
412 value.GetData(data);
413 auto value_obj_sp = ValueObjectConstResult::Create(
414 target.GetSP().get(), m_opaque_up->GetType(), m_opaque_up->GetName(),
415 data);
416 return SBValue(std::move(value_obj_sp));
417}
418
420 LLDB_INSTRUMENT_VA(this);
421
422 if (!IsValid())
423 return SBType();
424 return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetUnqualifiedType())));
425}
426
428 LLDB_INSTRUMENT_VA(this);
429
430 if (IsValid())
431 return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetCanonicalType())));
432 return SBType();
433}
434
436 LLDB_INSTRUMENT_VA(this);
437
438 if (IsValid()) {
439 return SBType(
440 m_opaque_sp->GetCompilerType(true).GetEnumerationIntegerType());
441 }
442 return SBType();
443}
444
446 LLDB_INSTRUMENT_VA(this);
447
448 if (IsValid())
449 return m_opaque_sp->GetCompilerType(false).GetBasicTypeEnumeration();
450 return eBasicTypeInvalid;
451}
452
454 LLDB_INSTRUMENT_VA(this, basic_type);
455
456 if (IsValid() && m_opaque_sp->IsValid())
457 if (auto ts = m_opaque_sp->GetTypeSystem(false))
458 return SBType(ts->GetBasicTypeFromAST(basic_type));
459 return SBType();
460}
461
463 LLDB_INSTRUMENT_VA(this);
464
465 if (IsValid())
466 return m_opaque_sp->GetCompilerType(true).GetNumDirectBaseClasses();
467 return 0;
468}
469
471 LLDB_INSTRUMENT_VA(this);
472
473 if (IsValid())
474 return m_opaque_sp->GetCompilerType(true).GetNumVirtualBaseClasses();
475 return 0;
476}
477
479 LLDB_INSTRUMENT_VA(this);
480
481 if (IsValid())
482 return m_opaque_sp->GetCompilerType(true).GetNumFields();
483 return 0;
484}
485
487 lldb::DescriptionLevel description_level) {
488 LLDB_INSTRUMENT_VA(this, description, description_level);
489
490 Stream &strm = description.ref();
491
492 if (m_opaque_sp) {
493 m_opaque_sp->GetDescription(strm, description_level);
494 } else
495 strm.PutCString("No value");
496
497 return true;
498}
499
501 LLDB_INSTRUMENT_VA(this, idx);
502
503 SBTypeMember sb_type_member;
504 if (IsValid()) {
505 uint32_t bit_offset = 0;
506 CompilerType base_class_type =
507 m_opaque_sp->GetCompilerType(true).GetDirectBaseClassAtIndex(
508 idx, &bit_offset);
509 if (base_class_type.IsValid())
510 sb_type_member.reset(new TypeMemberImpl(
511 TypeImplSP(new TypeImpl(base_class_type)), bit_offset));
512 }
513 return sb_type_member;
514}
515
517 LLDB_INSTRUMENT_VA(this, idx);
518
519 SBTypeMember sb_type_member;
520 if (IsValid()) {
521 uint32_t bit_offset = 0;
522 CompilerType base_class_type =
523 m_opaque_sp->GetCompilerType(true).GetVirtualBaseClassAtIndex(
524 idx, &bit_offset);
525 if (base_class_type.IsValid())
526 sb_type_member.reset(new TypeMemberImpl(
527 TypeImplSP(new TypeImpl(base_class_type)), bit_offset));
528 }
529 return sb_type_member;
530}
531
533 LLDB_INSTRUMENT_VA(this, name);
534
535 if (!IsValid() || !name)
536 return SBTypeStaticField();
537
538 return SBTypeStaticField(m_opaque_sp->GetCompilerType(/*prefer_dynamic=*/true)
539 .GetStaticFieldWithName(name));
540}
541
543 LLDB_INSTRUMENT_VA(this);
544
545 SBTypeEnumMemberList sb_enum_member_list;
546 if (IsValid()) {
547 CompilerType this_type(m_opaque_sp->GetCompilerType(true));
548 if (this_type.IsValid()) {
549 this_type.ForEachEnumerator([&sb_enum_member_list](
550 const CompilerType &integer_type,
551 ConstString name,
552 const llvm::APSInt &value) -> bool {
553 SBTypeEnumMember enum_member(
555 lldb::TypeImplSP(new TypeImpl(integer_type)), name, value)));
556 sb_enum_member_list.Append(enum_member);
557 return true; // Keep iterating
558 });
559 }
560 }
561 return sb_enum_member_list;
562}
563
565 LLDB_INSTRUMENT_VA(this, idx);
566
567 SBTypeMember sb_type_member;
568 if (IsValid()) {
569 CompilerType this_type(m_opaque_sp->GetCompilerType(false));
570 if (this_type.IsValid()) {
571 uint64_t bit_offset = 0;
572 uint32_t bitfield_bit_size = 0;
573 bool is_bitfield = false;
574 std::string name_sstr;
575 CompilerType field_type(this_type.GetFieldAtIndex(
576 idx, name_sstr, &bit_offset, &bitfield_bit_size, &is_bitfield));
577 if (field_type.IsValid()) {
578 ConstString name;
579 if (!name_sstr.empty())
580 name.SetCString(name_sstr.c_str());
581 sb_type_member.reset(
582 new TypeMemberImpl(TypeImplSP(new TypeImpl(field_type)), bit_offset,
583 name, bitfield_bit_size, is_bitfield));
584 }
585 }
586 }
587 return sb_type_member;
588}
589
591 LLDB_INSTRUMENT_VA(this);
592
593 if (!IsValid())
594 return false;
595 CompilerType compiler_type = m_opaque_sp->GetCompilerType(false);
596 // Only return true if we have a complete type and it wasn't forcefully
597 // completed.
598 if (compiler_type.IsCompleteType())
599 return !compiler_type.IsForcefullyCompleted();
600 return false;
601}
602
604 LLDB_INSTRUMENT_VA(this);
605
606 if (!IsValid())
607 return 0;
608 return m_opaque_sp->GetCompilerType(true).GetTypeInfo();
609}
610
612 LLDB_INSTRUMENT_VA(this);
613
614 lldb::SBModule sb_module;
615 if (!IsValid())
616 return sb_module;
617
618 sb_module.SetSP(m_opaque_sp->GetModule());
619 return sb_module;
620}
621
622const char *SBType::GetName() {
623 LLDB_INSTRUMENT_VA(this);
624
625 if (!IsValid())
626 return "";
627 return m_opaque_sp->GetName().GetCString();
628}
629
631 LLDB_INSTRUMENT_VA(this);
632
633 if (!IsValid())
634 return "";
635 return m_opaque_sp->GetDisplayTypeName().GetCString();
636}
637
638lldb::TypeClass SBType::GetTypeClass() {
639 LLDB_INSTRUMENT_VA(this);
640
641 if (IsValid())
642 return m_opaque_sp->GetCompilerType(true).GetTypeClass();
643 return lldb::eTypeClassInvalid;
644}
645
647 LLDB_INSTRUMENT_VA(this);
648
649 if (IsValid())
650 return m_opaque_sp->GetCompilerType(false).GetNumTemplateArguments(
651 /*expand_pack=*/true);
652 return 0;
653}
654
656 LLDB_INSTRUMENT_VA(this, idx);
657
658 if (!IsValid())
659 return SBType();
660
661 CompilerType type;
662 const bool expand_pack = true;
663 switch(GetTemplateArgumentKind(idx)) {
665 type = m_opaque_sp->GetCompilerType(false).GetTypeTemplateArgument(
666 idx, expand_pack);
667 break;
669 type = m_opaque_sp->GetCompilerType(false)
670 .GetIntegralTemplateArgument(idx, expand_pack)
671 ->type;
672 break;
673 default:
674 break;
675 }
676 if (type.IsValid())
677 return SBType(type);
678 return SBType();
679}
680
682 LLDB_INSTRUMENT_VA(this, idx);
683
684 if (IsValid())
685 return m_opaque_sp->GetCompilerType(false).GetTemplateArgumentKind(
686 idx, /*expand_pack=*/true);
688}
689
691 LLDB_INSTRUMENT_VA(this, name);
692
693 if (!IsValid())
694 return SBType();
695 return SBType(m_opaque_sp->FindDirectNestedType(name));
696}
697
698SBTypeList::SBTypeList() : m_opaque_up(new TypeListImpl()) {
699 LLDB_INSTRUMENT_VA(this);
700}
701
703 : m_opaque_up(new TypeListImpl()) {
704 LLDB_INSTRUMENT_VA(this, rhs);
705
706 for (uint32_t i = 0, rhs_size = const_cast<SBTypeList &>(rhs).GetSize();
707 i < rhs_size; i++)
708 Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i));
709}
710
712 LLDB_INSTRUMENT_VA(this);
713 return this->operator bool();
714}
715SBTypeList::operator bool() const {
716 LLDB_INSTRUMENT_VA(this);
717
718 return (m_opaque_up != nullptr);
719}
720
722 LLDB_INSTRUMENT_VA(this, rhs);
723
724 if (this != &rhs) {
725 m_opaque_up = std::make_unique<TypeListImpl>();
726 for (uint32_t i = 0, rhs_size = const_cast<SBTypeList &>(rhs).GetSize();
727 i < rhs_size; i++)
728 Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i));
729 }
730 return *this;
731}
732
734 LLDB_INSTRUMENT_VA(this, type);
735
736 if (type.IsValid())
737 m_opaque_up->Append(type.m_opaque_sp);
738}
739
741 LLDB_INSTRUMENT_VA(this, index);
742
743 if (m_opaque_up)
744 return SBType(m_opaque_up->GetTypeAtIndex(index));
745 return SBType();
746}
747
749 LLDB_INSTRUMENT_VA(this);
750
751 return m_opaque_up->GetSize();
752}
753
754SBTypeList::~SBTypeList() = default;
755
757
759
761 LLDB_INSTRUMENT_VA(this, rhs);
762
763 if (this != &rhs) {
764 if (rhs.IsValid())
765 m_opaque_up = std::make_unique<TypeMemberImpl>(rhs.ref());
766 }
767}
768
770 LLDB_INSTRUMENT_VA(this, rhs);
771
772 if (this != &rhs) {
773 if (rhs.IsValid())
774 m_opaque_up = std::make_unique<TypeMemberImpl>(rhs.ref());
775 }
776 return *this;
777}
778
780 LLDB_INSTRUMENT_VA(this);
781 return this->operator bool();
782}
783SBTypeMember::operator bool() const {
784 LLDB_INSTRUMENT_VA(this);
785
786 return m_opaque_up.get();
787}
788
790 LLDB_INSTRUMENT_VA(this);
791
792 if (m_opaque_up)
793 return m_opaque_up->GetName().GetCString();
794 return nullptr;
795}
796
798 LLDB_INSTRUMENT_VA(this);
799
800 SBType sb_type;
801 if (m_opaque_up) {
802 sb_type.SetSP(m_opaque_up->GetTypeImpl());
803 }
804 return sb_type;
805}
806
808 LLDB_INSTRUMENT_VA(this);
809
810 if (m_opaque_up)
811 return m_opaque_up->GetBitOffset() / 8u;
812 return 0;
813}
814
816 LLDB_INSTRUMENT_VA(this);
817
818 if (m_opaque_up)
819 return m_opaque_up->GetBitOffset();
820 return 0;
821}
822
824 LLDB_INSTRUMENT_VA(this);
825
826 if (m_opaque_up)
827 return m_opaque_up->GetIsBitfield();
828 return false;
829}
830
832 LLDB_INSTRUMENT_VA(this);
833
834 if (m_opaque_up)
835 return m_opaque_up->GetBitfieldBitSize();
836 return 0;
837}
838
840 lldb::DescriptionLevel description_level) {
841 LLDB_INSTRUMENT_VA(this, description, description_level);
842
843 Stream &strm = description.ref();
844
845 if (m_opaque_up) {
846 const uint32_t bit_offset = m_opaque_up->GetBitOffset();
847 const uint32_t byte_offset = bit_offset / 8u;
848 const uint32_t byte_bit_offset = bit_offset % 8u;
849 const char *name = m_opaque_up->GetName().GetCString();
850 if (byte_bit_offset)
851 strm.Printf("+%u + %u bits: (", byte_offset, byte_bit_offset);
852 else
853 strm.Printf("+%u: (", byte_offset);
854
855 TypeImplSP type_impl_sp(m_opaque_up->GetTypeImpl());
856 if (type_impl_sp)
857 type_impl_sp->GetDescription(strm, description_level);
858
859 strm.Printf(") %s", name);
860 if (m_opaque_up->GetIsBitfield()) {
861 const uint32_t bitfield_bit_size = m_opaque_up->GetBitfieldBitSize();
862 strm.Printf(" : %u", bitfield_bit_size);
863 }
864 } else {
865 strm.PutCString("No value");
866 }
867 return true;
868}
869
870void SBTypeMember::reset(TypeMemberImpl *type_member_impl) {
871 m_opaque_up.reset(type_member_impl);
872}
873
875 if (m_opaque_up == nullptr)
876 m_opaque_up = std::make_unique<TypeMemberImpl>();
877 return *m_opaque_up;
878}
879
881
883
885
887 : m_opaque_sp(rhs.m_opaque_sp) {
888 LLDB_INSTRUMENT_VA(this, rhs);
889}
890
893 LLDB_INSTRUMENT_VA(this, rhs);
894
895 if (this != &rhs)
897 return *this;
898}
899
901 LLDB_INSTRUMENT_VA(this);
902 return this->operator bool();
903}
904SBTypeMemberFunction::operator bool() const {
905 LLDB_INSTRUMENT_VA(this);
906
907 return m_opaque_sp.get();
908}
909
911 LLDB_INSTRUMENT_VA(this);
912
913 if (m_opaque_sp)
914 return m_opaque_sp->GetName().GetCString();
915 return nullptr;
916}
917
919 LLDB_INSTRUMENT_VA(this);
920
921 if (!m_opaque_sp)
922 return nullptr;
923
924 ConstString mangled_str = m_opaque_sp->GetMangledName();
925 if (!mangled_str)
926 return nullptr;
927
928 Mangled mangled(mangled_str);
929 return mangled.GetDemangledName().GetCString();
930}
931
933 LLDB_INSTRUMENT_VA(this);
934
935 if (m_opaque_sp)
936 return m_opaque_sp->GetMangledName().GetCString();
937 return nullptr;
938}
939
941 LLDB_INSTRUMENT_VA(this);
942
943 SBType sb_type;
944 if (m_opaque_sp) {
945 sb_type.SetSP(lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetType())));
946 }
947 return sb_type;
948}
949
951 LLDB_INSTRUMENT_VA(this);
952
953 SBType sb_type;
954 if (m_opaque_sp) {
955 sb_type.SetSP(lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetReturnType())));
956 }
957 return sb_type;
958}
959
961 LLDB_INSTRUMENT_VA(this);
962
963 if (m_opaque_sp)
964 return m_opaque_sp->GetNumArguments();
965 return 0;
966}
967
969 LLDB_INSTRUMENT_VA(this, i);
970
971 SBType sb_type;
972 if (m_opaque_sp) {
973 sb_type.SetSP(
974 lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetArgumentAtIndex(i))));
975 }
976 return sb_type;
977}
978
980 LLDB_INSTRUMENT_VA(this);
981
982 if (m_opaque_sp)
983 return m_opaque_sp->GetKind();
985}
986
988 lldb::SBStream &description, lldb::DescriptionLevel description_level) {
989 LLDB_INSTRUMENT_VA(this, description, description_level);
990
991 Stream &strm = description.ref();
992
993 if (m_opaque_sp)
994 return m_opaque_sp->GetDescription(strm);
995
996 return false;
997}
998
1000 m_opaque_sp.reset(type_member_impl);
1001}
1002
1004 if (!m_opaque_sp)
1005 m_opaque_sp = std::make_shared<TypeMemberFunctionImpl>();
1006 return *m_opaque_sp.get();
1007}
1008
1010 return *m_opaque_sp.get();
1011}
#define LLDB_INSTRUMENT_VA(...)
void SetSP(const ModuleSP &module_sp)
Definition: SBModule.cpp:211
lldb_private::Stream & ref()
Definition: SBStream.cpp:177
lldb::TargetSP GetSP() const
Definition: SBTarget.cpp:585
void Append(SBTypeEnumMember entry)
std::unique_ptr< lldb_private::TypeListImpl > m_opaque_up
Definition: SBType.h:311
lldb::SBType GetTypeAtIndex(uint32_t index)
Definition: SBType.cpp:740
uint32_t GetSize()
Definition: SBType.cpp:748
lldb::SBTypeList & operator=(const lldb::SBTypeList &rhs)
Definition: SBType.cpp:721
bool IsValid()
Definition: SBType.cpp:711
void Append(lldb::SBType type)
Definition: SBType.cpp:733
lldb::SBType GetArgumentTypeAtIndex(uint32_t)
Definition: SBType.cpp:968
const char * GetMangledName()
Definition: SBType.cpp:932
void reset(lldb_private::TypeMemberFunctionImpl *)
Definition: SBType.cpp:999
lldb::MemberFunctionKind GetKind()
Definition: SBType.cpp:979
lldb::SBType GetReturnType()
Definition: SBType.cpp:950
const char * GetName()
Definition: SBType.cpp:910
lldb::SBTypeMemberFunction & operator=(const lldb::SBTypeMemberFunction &rhs)
Definition: SBType.cpp:892
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
Definition: SBType.cpp:987
lldb::TypeMemberFunctionImplSP m_opaque_sp
Definition: SBType.h:107
uint32_t GetNumberOfArguments()
Definition: SBType.cpp:960
lldb::SBType GetType()
Definition: SBType.cpp:940
const char * GetDemangledName()
Definition: SBType.cpp:918
lldb_private::TypeMemberFunctionImpl & ref()
Definition: SBType.cpp:1003
std::unique_ptr< lldb_private::TypeMemberImpl > m_opaque_up
Definition: SBType.h:62
void reset(lldb_private::TypeMemberImpl *)
Definition: SBType.cpp:870
lldb::SBTypeMember & operator=(const lldb::SBTypeMember &rhs)
Definition: SBType.cpp:769
const char * GetName()
Definition: SBType.cpp:789
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
Definition: SBType.cpp:839
uint64_t GetOffsetInBits()
Definition: SBType.cpp:815
uint64_t GetOffsetInBytes()
Definition: SBType.cpp:807
lldb::SBType GetType()
Definition: SBType.cpp:797
uint32_t GetBitfieldSizeInBits()
Definition: SBType.cpp:831
bool IsValid() const
Definition: SBType.cpp:779
lldb_private::TypeMemberImpl & ref()
Definition: SBType.cpp:874
const char * GetName()
Definition: SBType.cpp:378
lldb::SBTypeStaticField & operator=(const lldb::SBTypeStaticField &rhs)
Definition: SBType.cpp:357
const char * GetMangledName()
Definition: SBType.cpp:386
lldb::SBType GetType()
Definition: SBType.cpp:394
lldb::SBValue GetConstantValue(lldb::SBTarget target)
Definition: SBType.cpp:402
std::unique_ptr< lldb_private::CompilerDecl > m_opaque_up
Definition: SBType.h:136
bool IsValid() const
Definition: SBType.cpp:372
friend class SBType
Definition: SBType.h:132
bool IsArrayType()
Definition: SBType.cpp:156
uint32_t GetNumberOfTemplateArguments()
Definition: SBType.cpp:646
uint32_t GetNumberOfDirectBaseClasses()
Definition: SBType.cpp:462
lldb::SBType FindDirectNestedType(const char *name)
Definition: SBType.cpp:690
lldb::SBType GetReferenceType()
Definition: SBType.cpp:198
lldb::SBType GetArrayType(uint64_t size)
Definition: SBType.cpp:231
lldb::SBType GetVectorElementType()
Definition: SBType.cpp:240
uint32_t GetNumberOfFields()
Definition: SBType.cpp:478
lldb::SBType GetDereferencedType()
Definition: SBType.cpp:214
lldb::SBModule GetModule()
Definition: SBType.cpp:611
lldb::BasicType GetBasicType()
Definition: SBType.cpp:445
bool IsPolymorphicClass()
Definition: SBType.cpp:261
uint32_t GetTypeFlags()
Definition: SBType.cpp:603
lldb::TypeImplSP GetSP()
Definition: SBType.cpp:82
bool IsAggregateType()
Definition: SBType.cpp:293
bool IsReferenceType()
Definition: SBType.cpp:173
lldb::SBTypeMember GetDirectBaseClassAtIndex(uint32_t idx)
Definition: SBType.cpp:500
bool IsVectorType()
Definition: SBType.cpp:165
lldb::TemplateArgumentKind GetTemplateArgumentKind(uint32_t idx)
Return the TemplateArgumentKind of the template argument at index idx.
Definition: SBType.cpp:681
lldb::SBTypeMemberFunction GetMemberFunctionAtIndex(uint32_t idx)
Definition: SBType.cpp:336
lldb::SBType GetPointerType()
Definition: SBType.cpp:181
uint32_t GetNumberOfMemberFunctions()
Definition: SBType.cpp:327
lldb::SBType GetTemplateArgumentType(uint32_t idx)
Definition: SBType.cpp:655
lldb::TypeClass GetTypeClass()
Definition: SBType.cpp:638
lldb::SBType GetCanonicalType()
Definition: SBType.cpp:427
friend class SBTypeStaticField
Definition: SBType.h:278
bool operator!=(lldb::SBType &rhs)
Definition: SBType.cpp:70
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
Definition: SBType.cpp:486
lldb::SBTypeList GetFunctionArgumentTypes()
Definition: SBType.cpp:313
uint32_t GetNumberOfVirtualBaseClasses()
Definition: SBType.cpp:470
lldb::SBType GetTypedefedType()
Definition: SBType.cpp:206
lldb_private::TypeImpl & ref()
Definition: SBType.cpp:99
lldb::SBTypeStaticField GetStaticFieldWithName(const char *name)
Definition: SBType.cpp:532
lldb::SBType & operator=(const lldb::SBType &rhs)
Definition: SBType.cpp:88
lldb::SBType GetFunctionReturnType()
Definition: SBType.cpp:301
lldb::TypeImplSP m_opaque_sp
Definition: SBType.h:268
lldb::SBType GetUnqualifiedType()
Definition: SBType.cpp:419
lldb::SBTypeMember GetVirtualBaseClassAtIndex(uint32_t idx)
Definition: SBType.cpp:516
bool IsTypeComplete()
Definition: SBType.cpp:590
const char * GetDisplayTypeName()
Definition: SBType.cpp:630
lldb::SBType GetArrayElementType()
Definition: SBType.cpp:222
bool IsTypedefType()
Definition: SBType.cpp:269
bool IsAnonymousType()
Definition: SBType.cpp:277
bool IsPointerType()
Definition: SBType.cpp:148
const char * GetName()
Definition: SBType.cpp:622
lldb::SBType GetPointeeType()
Definition: SBType.cpp:190
lldb::SBTypeMember GetFieldAtIndex(uint32_t idx)
Definition: SBType.cpp:564
void SetSP(const lldb::TypeImplSP &type_impl_sp)
Definition: SBType.cpp:84
uint64_t GetByteSize()
Definition: SBType.cpp:126
bool IsValid() const
Definition: SBType.cpp:113
uint64_t GetByteAlign()
Definition: SBType.cpp:136
bool operator==(lldb::SBType &rhs)
Definition: SBType.cpp:58
lldb::SBType GetEnumerationIntegerType()
Definition: SBType.cpp:435
lldb::SBTypeEnumMemberList GetEnumMembers()
Definition: SBType.cpp:542
bool IsFunctionType()
Definition: SBType.cpp:253
bool IsScopedEnumerationType()
Definition: SBType.cpp:285
Represents a generic declaration such as a function declaration.
Definition: CompilerDecl.h:28
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
CompilerType GetFieldAtIndex(size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const
CompilerType GetFunctionArgumentAtIndex(const size_t index) const
void ForEachEnumerator(std::function< bool(const CompilerType &integer_type, ConstString name, const llvm::APSInt &value)> const &callback) const
If this type is an enumeration, iterate through all of its enumerators using a callback.
size_t GetNumberOfFunctionArguments() const
bool IsForcefullyCompleted() const
A uniqued constant string class.
Definition: ConstString.h:40
void SetCString(const char *cstr)
Set the C string value.
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
An data extractor class.
Definition: DataExtractor.h:48
A class that handles mangled names.
Definition: Mangled.h:33
ConstString GetDemangledName() const
Demangled name get accessor.
Definition: Mangled.cpp:270
bool GetData(DataExtractor &data, size_t limit_byte_size=UINT32_MAX) const
Definition: Scalar.cpp:85
bool IsValid() const
Definition: Scalar.h:107
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:134
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:65
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address=LLDB_INVALID_ADDRESS)
A class that represents a running process on the host machine.
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
Definition: SBAddress.h:15
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
@ eBasicTypeInvalid
std::shared_ptr< lldb_private::TypeEnumMemberImpl > TypeEnumMemberImplSP
Definition: lldb-forward.h:463
std::shared_ptr< lldb_private::Type > TypeSP
Definition: lldb-forward.h:457
@ eTemplateArgumentKindNull
@ eTemplateArgumentKindIntegral
@ eTemplateArgumentKindType
MemberFunctionKind
Kind of member function.
@ eMemberFunctionKindUnknown
Not sure what the type of this is.
std::shared_ptr< lldb_private::TypeImpl > TypeImplSP
Definition: lldb-forward.h:460