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