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"
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 = llvm::expectedToOptional(
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(std::make_shared<TypeImpl>(m_opaque_sp->GetPointerType()));
188}
189
191 LLDB_INSTRUMENT_VA(this);
192
193 if (!IsValid())
194 return SBType();
195 return SBType(std::make_shared<TypeImpl>(m_opaque_sp->GetPointeeType()));
196}
197
199 LLDB_INSTRUMENT_VA(this);
200
201 if (!IsValid())
202 return SBType();
203 return SBType(std::make_shared<TypeImpl>(m_opaque_sp->GetReferenceType()));
204}
205
207 LLDB_INSTRUMENT_VA(this);
208
209 if (!IsValid())
210 return SBType();
211 return SBType(std::make_shared<TypeImpl>(m_opaque_sp->GetTypedefedType()));
212}
213
215 LLDB_INSTRUMENT_VA(this);
216
217 if (!IsValid())
218 return SBType();
219 return SBType(std::make_shared<TypeImpl>(m_opaque_sp->GetDereferencedType()));
220}
221
223 LLDB_INSTRUMENT_VA(this);
224
225 if (!IsValid())
226 return SBType();
227 return SBType(std::make_shared<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(std::make_shared<TypeImpl>(
237 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(std::make_shared<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
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(std::make_shared<TypeImpl>(m_opaque_sp->GetUnqualifiedType()));
425}
426
428 LLDB_INSTRUMENT_VA(this);
429
430 if (IsValid())
431 return SBType(std::make_shared<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 std::make_shared<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 std::make_shared<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(
550 [&sb_enum_member_list](const CompilerType &integer_type,
551 ConstString name,
552 const llvm::APSInt &value) -> bool {
553 SBTypeEnumMember enum_member(std::make_shared<TypeEnumMemberImpl>(
554 std::make_shared<TypeImpl>(integer_type), name, value));
555 sb_enum_member_list.Append(enum_member);
556 return true; // Keep iterating
557 });
558 }
559 }
560 return sb_enum_member_list;
561}
562
564 LLDB_INSTRUMENT_VA(this, idx);
565
566 SBTypeMember sb_type_member;
567 if (IsValid()) {
568 CompilerType this_type(m_opaque_sp->GetCompilerType(false));
569 if (this_type.IsValid()) {
570 uint64_t bit_offset = 0;
571 uint32_t bitfield_bit_size = 0;
572 bool is_bitfield = false;
573 std::string name_sstr;
574 CompilerType field_type(this_type.GetFieldAtIndex(
575 idx, name_sstr, &bit_offset, &bitfield_bit_size, &is_bitfield));
576 if (field_type.IsValid()) {
577 ConstString name;
578 if (!name_sstr.empty())
579 name.SetCString(name_sstr.c_str());
580 sb_type_member.reset(new TypeMemberImpl(
581 std::make_shared<TypeImpl>(field_type), bit_offset, name,
582 bitfield_bit_size, is_bitfield));
583 }
584 }
585 }
586 return sb_type_member;
587}
588
590 LLDB_INSTRUMENT_VA(this);
591
592 if (!IsValid())
593 return false;
594 CompilerType compiler_type = m_opaque_sp->GetCompilerType(false);
595 // Only return true if we have a complete type and it wasn't forcefully
596 // completed.
597 if (compiler_type.IsCompleteType())
598 return !compiler_type.IsForcefullyCompleted();
599 return false;
600}
601
603 LLDB_INSTRUMENT_VA(this);
604
605 if (!IsValid())
606 return 0;
607 return m_opaque_sp->GetCompilerType(true).GetTypeInfo();
608}
609
611 LLDB_INSTRUMENT_VA(this);
612
613 lldb::SBModule sb_module;
614 if (!IsValid())
615 return sb_module;
616
617 sb_module.SetSP(m_opaque_sp->GetModule());
618 return sb_module;
619}
620
621const char *SBType::GetName() {
622 LLDB_INSTRUMENT_VA(this);
623
624 if (!IsValid())
625 return "";
626 return m_opaque_sp->GetName().GetCString();
627}
628
630 LLDB_INSTRUMENT_VA(this);
631
632 if (!IsValid())
633 return "";
634 return m_opaque_sp->GetDisplayTypeName().GetCString();
635}
636
637lldb::TypeClass SBType::GetTypeClass() {
638 LLDB_INSTRUMENT_VA(this);
639
640 if (IsValid())
641 return m_opaque_sp->GetCompilerType(true).GetTypeClass();
642 return lldb::eTypeClassInvalid;
643}
644
646 LLDB_INSTRUMENT_VA(this);
647
648 if (IsValid())
649 return m_opaque_sp->GetCompilerType(false).GetNumTemplateArguments(
650 /*expand_pack=*/true);
651 return 0;
652}
653
655 LLDB_INSTRUMENT_VA(this, idx);
656
657 if (!IsValid())
658 return SBType();
659
660 CompilerType type;
661 const bool expand_pack = true;
662 switch(GetTemplateArgumentKind(idx)) {
664 type = m_opaque_sp->GetCompilerType(false).GetTypeTemplateArgument(
665 idx, expand_pack);
666 break;
668 type = m_opaque_sp->GetCompilerType(false)
669 .GetIntegralTemplateArgument(idx, expand_pack)
670 ->type;
671 break;
672 default:
673 break;
674 }
675 if (type.IsValid())
676 return SBType(type);
677 return SBType();
678}
679
681 LLDB_INSTRUMENT_VA(this, idx);
682
683 if (IsValid())
684 return m_opaque_sp->GetCompilerType(false).GetTemplateArgumentKind(
685 idx, /*expand_pack=*/true);
687}
688
690 uint32_t idx) {
691 LLDB_INSTRUMENT_VA(this, target, idx);
692
693 if (!IsValid())
694 return {};
695
696 std::optional<CompilerType::IntegralTemplateArgument> arg;
697 const bool expand_pack = true;
698 switch (GetTemplateArgumentKind(idx)) {
701 arg = m_opaque_sp->GetCompilerType(false).GetIntegralTemplateArgument(
702 idx, expand_pack);
703 break;
704 default:
705 break;
706 }
707
708 if (!arg)
709 return {};
710
711 DataExtractor data;
712 arg->value.GetData(data);
713
714 ExecutionContext exe_ctx;
715 auto target_sp = target.GetSP();
716 if (!target_sp)
717 return {};
718
719 target_sp->CalculateExecutionContext(exe_ctx);
720
721 return ValueObject::CreateValueObjectFromData("value", data, exe_ctx,
722 arg->type);
723}
724
726 LLDB_INSTRUMENT_VA(this, name);
727
728 if (!IsValid())
729 return SBType();
730 return SBType(m_opaque_sp->FindDirectNestedType(name));
731}
732
736
738 : m_opaque_up(new TypeListImpl()) {
739 LLDB_INSTRUMENT_VA(this, rhs);
740
741 for (uint32_t i = 0, rhs_size = const_cast<SBTypeList &>(rhs).GetSize();
742 i < rhs_size; i++)
743 Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i));
744}
745
747 LLDB_INSTRUMENT_VA(this);
748 return this->operator bool();
749}
750SBTypeList::operator bool() const {
751 LLDB_INSTRUMENT_VA(this);
752
753 return (m_opaque_up != nullptr);
754}
755
757 LLDB_INSTRUMENT_VA(this, rhs);
758
759 if (this != &rhs) {
760 m_opaque_up = std::make_unique<TypeListImpl>();
761 for (uint32_t i = 0, rhs_size = const_cast<SBTypeList &>(rhs).GetSize();
762 i < rhs_size; i++)
763 Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i));
764 }
765 return *this;
766}
767
769 LLDB_INSTRUMENT_VA(this, type);
770
771 if (type.IsValid())
772 m_opaque_up->Append(type.m_opaque_sp);
773}
774
776 LLDB_INSTRUMENT_VA(this, index);
777
778 if (m_opaque_up)
779 return SBType(m_opaque_up->GetTypeAtIndex(index));
780 return SBType();
781}
782
784 LLDB_INSTRUMENT_VA(this);
785
786 return m_opaque_up->GetSize();
787}
788
789SBTypeList::~SBTypeList() = default;
790
792
794
796 LLDB_INSTRUMENT_VA(this, rhs);
797
798 if (this != &rhs) {
799 if (rhs.IsValid())
800 m_opaque_up = std::make_unique<TypeMemberImpl>(rhs.ref());
801 }
802}
803
805 LLDB_INSTRUMENT_VA(this, rhs);
806
807 if (this != &rhs) {
808 if (rhs.IsValid())
809 m_opaque_up = std::make_unique<TypeMemberImpl>(rhs.ref());
810 }
811 return *this;
812}
813
815 LLDB_INSTRUMENT_VA(this);
816 return this->operator bool();
817}
818SBTypeMember::operator bool() const {
819 LLDB_INSTRUMENT_VA(this);
820
821 return m_opaque_up.get();
822}
823
825 LLDB_INSTRUMENT_VA(this);
826
827 if (m_opaque_up)
828 return m_opaque_up->GetName().GetCString();
829 return nullptr;
830}
831
833 LLDB_INSTRUMENT_VA(this);
834
835 SBType sb_type;
836 if (m_opaque_up) {
837 sb_type.SetSP(m_opaque_up->GetTypeImpl());
838 }
839 return sb_type;
840}
841
843 LLDB_INSTRUMENT_VA(this);
844
845 if (m_opaque_up)
846 return m_opaque_up->GetBitOffset() / 8u;
847 return 0;
848}
849
851 LLDB_INSTRUMENT_VA(this);
852
853 if (m_opaque_up)
854 return m_opaque_up->GetBitOffset();
855 return 0;
856}
857
859 LLDB_INSTRUMENT_VA(this);
860
861 if (m_opaque_up)
862 return m_opaque_up->GetIsBitfield();
863 return false;
864}
865
867 LLDB_INSTRUMENT_VA(this);
868
869 if (m_opaque_up)
870 return m_opaque_up->GetBitfieldBitSize();
871 return 0;
872}
873
875 lldb::DescriptionLevel description_level) {
876 LLDB_INSTRUMENT_VA(this, description, description_level);
877
878 Stream &strm = description.ref();
879
880 if (m_opaque_up) {
881 const uint32_t bit_offset = m_opaque_up->GetBitOffset();
882 const uint32_t byte_offset = bit_offset / 8u;
883 const uint32_t byte_bit_offset = bit_offset % 8u;
884 const char *name = m_opaque_up->GetName().GetCString();
885 if (byte_bit_offset)
886 strm.Printf("+%u + %u bits: (", byte_offset, byte_bit_offset);
887 else
888 strm.Printf("+%u: (", byte_offset);
889
890 TypeImplSP type_impl_sp(m_opaque_up->GetTypeImpl());
891 if (type_impl_sp)
892 type_impl_sp->GetDescription(strm, description_level);
893
894 strm.Printf(") %s", name);
895 if (m_opaque_up->GetIsBitfield()) {
896 const uint32_t bitfield_bit_size = m_opaque_up->GetBitfieldBitSize();
897 strm.Printf(" : %u", bitfield_bit_size);
898 }
899 } else {
900 strm.PutCString("No value");
901 }
902 return true;
903}
904
905void SBTypeMember::reset(TypeMemberImpl *type_member_impl) {
906 m_opaque_up.reset(type_member_impl);
907}
908
910 if (m_opaque_up == nullptr)
911 m_opaque_up = std::make_unique<TypeMemberImpl>();
912 return *m_opaque_up;
913}
914
916
918
920
925
928 LLDB_INSTRUMENT_VA(this, rhs);
929
930 if (this != &rhs)
932 return *this;
933}
934
936 LLDB_INSTRUMENT_VA(this);
937 return this->operator bool();
938}
939SBTypeMemberFunction::operator bool() const {
940 LLDB_INSTRUMENT_VA(this);
941
942 return m_opaque_sp.get();
943}
944
946 LLDB_INSTRUMENT_VA(this);
947
948 if (m_opaque_sp)
949 return m_opaque_sp->GetName().GetCString();
950 return nullptr;
951}
952
954 LLDB_INSTRUMENT_VA(this);
955
956 if (!m_opaque_sp)
957 return nullptr;
958
959 ConstString mangled_str = m_opaque_sp->GetMangledName();
960 if (!mangled_str)
961 return nullptr;
962
963 Mangled mangled(mangled_str);
964 return mangled.GetDemangledName().GetCString();
965}
966
968 LLDB_INSTRUMENT_VA(this);
969
970 if (m_opaque_sp)
971 return m_opaque_sp->GetMangledName().GetCString();
972 return nullptr;
973}
974
976 LLDB_INSTRUMENT_VA(this);
977
978 SBType sb_type;
979 if (m_opaque_sp) {
980 sb_type.SetSP(std::make_shared<TypeImpl>(m_opaque_sp->GetType()));
981 }
982 return sb_type;
983}
984
986 LLDB_INSTRUMENT_VA(this);
987
988 SBType sb_type;
989 if (m_opaque_sp) {
990 sb_type.SetSP(std::make_shared<TypeImpl>(m_opaque_sp->GetReturnType()));
991 }
992 return sb_type;
993}
994
996 LLDB_INSTRUMENT_VA(this);
997
998 if (m_opaque_sp)
999 return m_opaque_sp->GetNumArguments();
1000 return 0;
1001}
1002
1004 LLDB_INSTRUMENT_VA(this, i);
1005
1006 SBType sb_type;
1007 if (m_opaque_sp) {
1008 sb_type.SetSP(
1009 std::make_shared<TypeImpl>(m_opaque_sp->GetArgumentAtIndex(i)));
1010 }
1011 return sb_type;
1012}
1013
1021
1023 lldb::SBStream &description, lldb::DescriptionLevel description_level) {
1024 LLDB_INSTRUMENT_VA(this, description, description_level);
1025
1026 Stream &strm = description.ref();
1027
1028 if (m_opaque_sp)
1029 return m_opaque_sp->GetDescription(strm);
1030
1031 return false;
1032}
1033
1035 m_opaque_sp.reset(type_member_impl);
1036}
1037
1039 if (!m_opaque_sp)
1040 m_opaque_sp = std::make_shared<TypeMemberFunctionImpl>();
1041 return *m_opaque_sp.get();
1042}
1043
1045 return *m_opaque_sp.get();
1046}
#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:578
void Append(SBTypeEnumMember entry)
std::unique_ptr< lldb_private::TypeListImpl > m_opaque_up
Definition SBType.h:318
lldb::SBType GetTypeAtIndex(uint32_t index)
Definition SBType.cpp:775
uint32_t GetSize()
Definition SBType.cpp:783
lldb::SBTypeList & operator=(const lldb::SBTypeList &rhs)
Definition SBType.cpp:756
void Append(lldb::SBType type)
Definition SBType.cpp:768
lldb::SBType GetArgumentTypeAtIndex(uint32_t)
Definition SBType.cpp:1003
const char * GetMangledName()
Definition SBType.cpp:967
void reset(lldb_private::TypeMemberFunctionImpl *)
Definition SBType.cpp:1034
lldb::MemberFunctionKind GetKind()
Definition SBType.cpp:1014
lldb::SBType GetReturnType()
Definition SBType.cpp:985
const char * GetName()
Definition SBType.cpp:945
lldb::SBTypeMemberFunction & operator=(const lldb::SBTypeMemberFunction &rhs)
Definition SBType.cpp:927
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
Definition SBType.cpp:1022
lldb::TypeMemberFunctionImplSP m_opaque_sp
Definition SBType.h:107
uint32_t GetNumberOfArguments()
Definition SBType.cpp:995
lldb::SBType GetType()
Definition SBType.cpp:975
friend class SBType
Definition SBType.h:99
const char * GetDemangledName()
Definition SBType.cpp:953
lldb_private::TypeMemberFunctionImpl & ref()
Definition SBType.cpp:1038
std::unique_ptr< lldb_private::TypeMemberImpl > m_opaque_up
Definition SBType.h:62
void reset(lldb_private::TypeMemberImpl *)
Definition SBType.cpp:905
lldb::SBTypeMember & operator=(const lldb::SBTypeMember &rhs)
Definition SBType.cpp:804
const char * GetName()
Definition SBType.cpp:824
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
Definition SBType.cpp:874
uint64_t GetOffsetInBits()
Definition SBType.cpp:850
uint64_t GetOffsetInBytes()
Definition SBType.cpp:842
lldb::SBType GetType()
Definition SBType.cpp:832
uint32_t GetBitfieldSizeInBits()
Definition SBType.cpp:866
bool IsValid() const
Definition SBType.cpp:814
friend class SBType
Definition SBType.h:54
lldb_private::TypeMemberImpl & ref()
Definition SBType.cpp:909
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:645
uint32_t GetNumberOfDirectBaseClasses()
Definition SBType.cpp:462
lldb::SBType FindDirectNestedType(const char *name)
Definition SBType.cpp:725
lldb::SBType GetReferenceType()
Definition SBType.cpp:198
lldb::SBType GetArrayType(uint64_t size)
Definition SBType.cpp:231
lldb::SBType GetVectorElementType()
Definition SBType.cpp:240
lldb::SBValue GetTemplateArgumentValue(lldb::SBTarget target, uint32_t idx)
Returns the value of the non-type template parameter at index idx.
Definition SBType.cpp:689
uint32_t GetNumberOfFields()
Definition SBType.cpp:478
lldb::SBType GetDereferencedType()
Definition SBType.cpp:214
friend class SBTypeEnumMember
Definition SBType.h:280
lldb::SBModule GetModule()
Definition SBType.cpp:610
lldb::BasicType GetBasicType()
Definition SBType.cpp:445
bool IsPolymorphicClass()
Definition SBType.cpp:261
uint32_t GetTypeFlags()
Definition SBType.cpp:602
lldb::TypeImplSP GetSP()
Definition SBType.cpp:82
friend class SBTypeEnumMemberList
Definition SBType.h:281
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:680
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:654
lldb::TypeClass GetTypeClass()
Definition SBType.cpp:637
lldb::SBType GetCanonicalType()
Definition SBType.cpp:427
friend class SBTypeStaticField
Definition SBType.h:285
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
friend class SBTypeMemberFunction
Definition SBType.h:284
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
friend class SBTypeList
Definition SBType.h:286
lldb::TypeImplSP m_opaque_sp
Definition SBType.h:275
lldb::SBType GetUnqualifiedType()
Definition SBType.cpp:419
lldb::SBTypeMember GetVirtualBaseClassAtIndex(uint32_t idx)
Definition SBType.cpp:516
bool IsTypeComplete()
Definition SBType.cpp:589
friend class SBTypeMember
Definition SBType.h:283
const char * GetDisplayTypeName()
Definition SBType.cpp:629
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:621
lldb::SBType GetPointeeType()
Definition SBType.cpp:190
lldb::SBTypeMember GetFieldAtIndex(uint32_t idx)
Definition SBType.cpp:563
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.
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.
const char * GetCString() const
Get the string value as a C string.
An data extractor class.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A class that handles mangled names.
Definition Mangled.h:34
ConstString GetDemangledName() const
Demangled name get accessor.
Definition Mangled.cpp:284
bool GetData(DataExtractor &data) const
Get data with a byte size of GetByteSize().
Definition Scalar.cpp:85
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:65
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address=LLDB_INVALID_ADDRESS)
static lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type)
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
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:120
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:134