1 //===-- CompilerType.cpp ----------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Symbol/CompilerType.h"
12 #include "lldb/Core/Debugger.h"
13 #include "lldb/Core/StreamFile.h"
14 #include "lldb/Symbol/ClangASTContext.h"
15 #include "lldb/Symbol/ClangExternalASTSourceCommon.h"
16 #include "lldb/Symbol/Type.h"
17 #include "lldb/Target/ExecutionContext.h"
18 #include "lldb/Target/Process.h"
19 #include "lldb/Utility/ConstString.h"
20 #include "lldb/Utility/DataBufferHeap.h"
21 #include "lldb/Utility/DataExtractor.h"
22 #include "lldb/Utility/Scalar.h"
23 #include "lldb/Utility/Stream.h"
24 #include "lldb/Utility/StreamString.h"
30 using namespace lldb_private;
32 CompilerType::CompilerType(TypeSystem *type_system,
33 lldb::opaque_compiler_type_t type)
34 : m_type(type), m_type_system(type_system) {}
36 CompilerType::CompilerType(clang::ASTContext *ast, clang::QualType qual_type)
37 : m_type(qual_type.getAsOpaquePtr()),
38 m_type_system(ClangASTContext::GetASTContext(ast)) {
39 #ifdef LLDB_CONFIGURATION_DEBUG
41 assert(m_type_system != nullptr);
45 CompilerType::~CompilerType() {}
47 //----------------------------------------------------------------------
49 //----------------------------------------------------------------------
51 bool CompilerType::IsAggregateType() const {
53 return m_type_system->IsAggregateType(m_type);
57 bool CompilerType::IsAnonymousType() const {
59 return m_type_system->IsAnonymousType(m_type);
63 bool CompilerType::IsArrayType(CompilerType *element_type_ptr, uint64_t *size,
64 bool *is_incomplete) const {
66 return m_type_system->IsArrayType(m_type, element_type_ptr, size,
70 element_type_ptr->Clear();
74 *is_incomplete = false;
78 bool CompilerType::IsVectorType(CompilerType *element_type,
79 uint64_t *size) const {
81 return m_type_system->IsVectorType(m_type, element_type, size);
85 bool CompilerType::IsRuntimeGeneratedType() const {
87 return m_type_system->IsRuntimeGeneratedType(m_type);
91 bool CompilerType::IsCharType() const {
93 return m_type_system->IsCharType(m_type);
97 bool CompilerType::IsCompleteType() const {
99 return m_type_system->IsCompleteType(m_type);
103 bool CompilerType::IsConst() const {
105 return m_type_system->IsConst(m_type);
109 bool CompilerType::IsCStringType(uint32_t &length) const {
111 return m_type_system->IsCStringType(m_type, length);
115 bool CompilerType::IsFunctionType(bool *is_variadic_ptr) const {
117 return m_type_system->IsFunctionType(m_type, is_variadic_ptr);
121 // Used to detect "Homogeneous Floating-point Aggregates"
123 CompilerType::IsHomogeneousAggregate(CompilerType *base_type_ptr) const {
125 return m_type_system->IsHomogeneousAggregate(m_type, base_type_ptr);
129 size_t CompilerType::GetNumberOfFunctionArguments() const {
131 return m_type_system->GetNumberOfFunctionArguments(m_type);
136 CompilerType::GetFunctionArgumentAtIndex(const size_t index) const {
138 return m_type_system->GetFunctionArgumentAtIndex(m_type, index);
139 return CompilerType();
142 bool CompilerType::IsFunctionPointerType() const {
144 return m_type_system->IsFunctionPointerType(m_type);
148 bool CompilerType::IsBlockPointerType(
149 CompilerType *function_pointer_type_ptr) const {
151 return m_type_system->IsBlockPointerType(m_type, function_pointer_type_ptr);
155 bool CompilerType::IsIntegerType(bool &is_signed) const {
157 return m_type_system->IsIntegerType(m_type, is_signed);
161 bool CompilerType::IsEnumerationType(bool &is_signed) const {
163 return m_type_system->IsEnumerationType(m_type, is_signed);
167 bool CompilerType::IsIntegerOrEnumerationType(bool &is_signed) const {
168 return IsIntegerType(is_signed) || IsEnumerationType(is_signed);
171 bool CompilerType::IsPointerType(CompilerType *pointee_type) const {
173 return m_type_system->IsPointerType(m_type, pointee_type);
176 pointee_type->Clear();
180 bool CompilerType::IsPointerOrReferenceType(CompilerType *pointee_type) const {
182 return m_type_system->IsPointerOrReferenceType(m_type, pointee_type);
185 pointee_type->Clear();
189 bool CompilerType::IsReferenceType(CompilerType *pointee_type,
190 bool *is_rvalue) const {
192 return m_type_system->IsReferenceType(m_type, pointee_type, is_rvalue);
195 pointee_type->Clear();
199 bool CompilerType::ShouldTreatScalarValueAsAddress() const {
201 return m_type_system->ShouldTreatScalarValueAsAddress(m_type);
205 bool CompilerType::IsFloatingPointType(uint32_t &count,
206 bool &is_complex) const {
208 return m_type_system->IsFloatingPointType(m_type, count, is_complex);
215 bool CompilerType::IsDefined() const {
217 return m_type_system->IsDefined(m_type);
221 bool CompilerType::IsPolymorphicClass() const {
223 return m_type_system->IsPolymorphicClass(m_type);
228 bool CompilerType::IsPossibleDynamicType(CompilerType *dynamic_pointee_type,
229 bool check_cplusplus,
230 bool check_objc) const {
232 return m_type_system->IsPossibleDynamicType(m_type, dynamic_pointee_type,
233 check_cplusplus, check_objc);
237 bool CompilerType::IsScalarType() const {
241 return m_type_system->IsScalarType(m_type);
244 bool CompilerType::IsTypedefType() const {
247 return m_type_system->IsTypedefType(m_type);
250 bool CompilerType::IsVoidType() const {
253 return m_type_system->IsVoidType(m_type);
256 bool CompilerType::IsPointerToScalarType() const {
260 return IsPointerType() && GetPointeeType().IsScalarType();
263 bool CompilerType::IsArrayOfScalarType() const {
264 CompilerType element_type;
265 if (IsArrayType(&element_type, nullptr, nullptr))
266 return element_type.IsScalarType();
270 bool CompilerType::IsBeingDefined() const {
273 return m_type_system->IsBeingDefined(m_type);
276 //----------------------------------------------------------------------
278 //----------------------------------------------------------------------
280 bool CompilerType::GetCompleteType() const {
283 return m_type_system->GetCompleteType(m_type);
286 //----------------------------------------------------------------------
287 // AST related queries
288 //----------------------------------------------------------------------
289 size_t CompilerType::GetPointerByteSize() const {
291 return m_type_system->GetPointerByteSize();
295 ConstString CompilerType::GetConstQualifiedTypeName() const {
296 return GetConstTypeName();
299 ConstString CompilerType::GetConstTypeName() const {
301 ConstString type_name(GetTypeName());
305 return ConstString("<invalid>");
308 ConstString CompilerType::GetTypeName() const {
310 return m_type_system->GetTypeName(m_type);
312 return ConstString("<invalid>");
315 ConstString CompilerType::GetDisplayTypeName() const { return GetTypeName(); }
317 uint32_t CompilerType::GetTypeInfo(
318 CompilerType *pointee_or_element_compiler_type) const {
322 return m_type_system->GetTypeInfo(m_type, pointee_or_element_compiler_type);
325 lldb::LanguageType CompilerType::GetMinimumLanguage() {
327 return lldb::eLanguageTypeC;
329 return m_type_system->GetMinimumLanguage(m_type);
332 lldb::TypeClass CompilerType::GetTypeClass() const {
334 return lldb::eTypeClassInvalid;
336 return m_type_system->GetTypeClass(m_type);
339 void CompilerType::SetCompilerType(TypeSystem *type_system,
340 lldb::opaque_compiler_type_t type) {
341 m_type_system = type_system;
345 void CompilerType::SetCompilerType(clang::ASTContext *ast,
346 clang::QualType qual_type) {
347 m_type_system = ClangASTContext::GetASTContext(ast);
348 m_type = qual_type.getAsOpaquePtr();
351 unsigned CompilerType::GetTypeQualifiers() const {
353 return m_type_system->GetTypeQualifiers(m_type);
357 //----------------------------------------------------------------------
358 // Creating related types
359 //----------------------------------------------------------------------
361 CompilerType CompilerType::GetArrayElementType(uint64_t *stride) const {
363 return m_type_system->GetArrayElementType(m_type, stride);
365 return CompilerType();
368 CompilerType CompilerType::GetArrayType(uint64_t size) const {
370 return m_type_system->GetArrayType(m_type, size);
372 return CompilerType();
375 CompilerType CompilerType::GetCanonicalType() const {
377 return m_type_system->GetCanonicalType(m_type);
378 return CompilerType();
381 CompilerType CompilerType::GetFullyUnqualifiedType() const {
383 return m_type_system->GetFullyUnqualifiedType(m_type);
384 return CompilerType();
387 int CompilerType::GetFunctionArgumentCount() const {
389 return m_type_system->GetFunctionArgumentCount(m_type);
394 CompilerType CompilerType::GetFunctionArgumentTypeAtIndex(size_t idx) const {
396 return m_type_system->GetFunctionArgumentTypeAtIndex(m_type, idx);
398 return CompilerType();
401 CompilerType CompilerType::GetFunctionReturnType() const {
403 return m_type_system->GetFunctionReturnType(m_type);
405 return CompilerType();
408 size_t CompilerType::GetNumMemberFunctions() const {
410 return m_type_system->GetNumMemberFunctions(m_type);
415 TypeMemberFunctionImpl CompilerType::GetMemberFunctionAtIndex(size_t idx) {
417 return m_type_system->GetMemberFunctionAtIndex(m_type, idx);
419 return TypeMemberFunctionImpl();
422 CompilerType CompilerType::GetNonReferenceType() const {
424 return m_type_system->GetNonReferenceType(m_type);
425 return CompilerType();
428 CompilerType CompilerType::GetPointeeType() const {
430 return m_type_system->GetPointeeType(m_type);
432 return CompilerType();
435 CompilerType CompilerType::GetPointerType() const {
437 return m_type_system->GetPointerType(m_type);
439 return CompilerType();
442 CompilerType CompilerType::GetLValueReferenceType() const {
444 return m_type_system->GetLValueReferenceType(m_type);
446 return CompilerType();
449 CompilerType CompilerType::GetRValueReferenceType() const {
451 return m_type_system->GetRValueReferenceType(m_type);
453 return CompilerType();
456 CompilerType CompilerType::AddConstModifier() const {
458 return m_type_system->AddConstModifier(m_type);
460 return CompilerType();
463 CompilerType CompilerType::AddVolatileModifier() const {
465 return m_type_system->AddVolatileModifier(m_type);
467 return CompilerType();
470 CompilerType CompilerType::AddRestrictModifier() const {
472 return m_type_system->AddRestrictModifier(m_type);
474 return CompilerType();
478 CompilerType::CreateTypedef(const char *name,
479 const CompilerDeclContext &decl_ctx) const {
481 return m_type_system->CreateTypedef(m_type, name, decl_ctx);
483 return CompilerType();
486 CompilerType CompilerType::GetTypedefedType() const {
488 return m_type_system->GetTypedefedType(m_type);
490 return CompilerType();
493 //----------------------------------------------------------------------
494 // Create related types using the current type's AST
495 //----------------------------------------------------------------------
498 CompilerType::GetBasicTypeFromAST(lldb::BasicType basic_type) const {
500 return m_type_system->GetBasicTypeFromAST(basic_type);
501 return CompilerType();
503 //----------------------------------------------------------------------
504 // Exploring the type
505 //----------------------------------------------------------------------
507 llvm::Optional<uint64_t>
508 CompilerType::GetBitSize(ExecutionContextScope *exe_scope) const {
510 return m_type_system->GetBitSize(m_type, exe_scope);
514 llvm::Optional<uint64_t>
515 CompilerType::GetByteSize(ExecutionContextScope *exe_scope) const {
516 if (llvm::Optional<uint64_t> bit_size = GetBitSize(exe_scope))
517 return (*bit_size + 7) / 8;
521 size_t CompilerType::GetTypeBitAlign() const {
523 return m_type_system->GetTypeBitAlign(m_type);
527 lldb::Encoding CompilerType::GetEncoding(uint64_t &count) const {
529 return lldb::eEncodingInvalid;
531 return m_type_system->GetEncoding(m_type, count);
534 lldb::Format CompilerType::GetFormat() const {
536 return lldb::eFormatDefault;
538 return m_type_system->GetFormat(m_type);
541 uint32_t CompilerType::GetNumChildren(bool omit_empty_base_classes,
542 const ExecutionContext *exe_ctx) const {
545 return m_type_system->GetNumChildren(m_type, omit_empty_base_classes,
549 lldb::BasicType CompilerType::GetBasicTypeEnumeration() const {
551 return m_type_system->GetBasicTypeEnumeration(m_type);
552 return eBasicTypeInvalid;
555 void CompilerType::ForEachEnumerator(
556 std::function<bool(const CompilerType &integer_type,
557 const ConstString &name,
558 const llvm::APSInt &value)> const &callback) const {
560 return m_type_system->ForEachEnumerator(m_type, callback);
563 uint32_t CompilerType::GetNumFields() const {
566 return m_type_system->GetNumFields(m_type);
569 CompilerType CompilerType::GetFieldAtIndex(size_t idx, std::string &name,
570 uint64_t *bit_offset_ptr,
571 uint32_t *bitfield_bit_size_ptr,
572 bool *is_bitfield_ptr) const {
574 return CompilerType();
575 return m_type_system->GetFieldAtIndex(m_type, idx, name, bit_offset_ptr,
576 bitfield_bit_size_ptr, is_bitfield_ptr);
579 uint32_t CompilerType::GetNumDirectBaseClasses() const {
581 return m_type_system->GetNumDirectBaseClasses(m_type);
585 uint32_t CompilerType::GetNumVirtualBaseClasses() const {
587 return m_type_system->GetNumVirtualBaseClasses(m_type);
592 CompilerType::GetDirectBaseClassAtIndex(size_t idx,
593 uint32_t *bit_offset_ptr) const {
595 return m_type_system->GetDirectBaseClassAtIndex(m_type, idx,
597 return CompilerType();
601 CompilerType::GetVirtualBaseClassAtIndex(size_t idx,
602 uint32_t *bit_offset_ptr) const {
604 return m_type_system->GetVirtualBaseClassAtIndex(m_type, idx,
606 return CompilerType();
609 uint32_t CompilerType::GetIndexOfFieldWithName(
610 const char *name, CompilerType *field_compiler_type_ptr,
611 uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr,
612 bool *is_bitfield_ptr) const {
613 unsigned count = GetNumFields();
614 std::string field_name;
615 for (unsigned index = 0; index < count; index++) {
616 CompilerType field_compiler_type(
617 GetFieldAtIndex(index, field_name, bit_offset_ptr,
618 bitfield_bit_size_ptr, is_bitfield_ptr));
619 if (strcmp(field_name.c_str(), name) == 0) {
620 if (field_compiler_type_ptr)
621 *field_compiler_type_ptr = field_compiler_type;
628 CompilerType CompilerType::GetChildCompilerTypeAtIndex(
629 ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers,
630 bool omit_empty_base_classes, bool ignore_array_bounds,
631 std::string &child_name, uint32_t &child_byte_size,
632 int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size,
633 uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
634 bool &child_is_deref_of_parent, ValueObject *valobj,
635 uint64_t &language_flags) const {
637 return CompilerType();
638 return m_type_system->GetChildCompilerTypeAtIndex(
639 m_type, exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
640 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
641 child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
642 child_is_deref_of_parent, valobj, language_flags);
645 // Look for a child member (doesn't include base classes, but it does include
646 // their members) in the type hierarchy. Returns an index path into
647 // "clang_type" on how to reach the appropriate member.
666 // If we have a clang type that describes "class C", and we wanted to looked
669 // With omit_empty_base_classes == false we would get an integer array back
670 // with: { 1, 1 } The first index 1 is the child index for "class A" within
671 // class C The second index 1 is the child index for "m_b" within class A
673 // With omit_empty_base_classes == true we would get an integer array back
674 // with: { 0, 1 } The first index 0 is the child index for "class A" within
675 // class C (since class B doesn't have any members it doesn't count) The second
676 // index 1 is the child index for "m_b" within class A
678 size_t CompilerType::GetIndexOfChildMemberWithName(
679 const char *name, bool omit_empty_base_classes,
680 std::vector<uint32_t> &child_indexes) const {
681 if (IsValid() && name && name[0]) {
682 return m_type_system->GetIndexOfChildMemberWithName(
683 m_type, name, omit_empty_base_classes, child_indexes);
688 size_t CompilerType::GetNumTemplateArguments() const {
690 return m_type_system->GetNumTemplateArguments(m_type);
695 TemplateArgumentKind CompilerType::GetTemplateArgumentKind(size_t idx) const {
697 return m_type_system->GetTemplateArgumentKind(m_type, idx);
698 return eTemplateArgumentKindNull;
701 CompilerType CompilerType::GetTypeTemplateArgument(size_t idx) const {
703 return m_type_system->GetTypeTemplateArgument(m_type, idx);
705 return CompilerType();
708 llvm::Optional<CompilerType::IntegralTemplateArgument>
709 CompilerType::GetIntegralTemplateArgument(size_t idx) const {
711 return m_type_system->GetIntegralTemplateArgument(m_type, idx);
715 CompilerType CompilerType::GetTypeForFormatters() const {
717 return m_type_system->GetTypeForFormatters(m_type);
718 return CompilerType();
721 LazyBool CompilerType::ShouldPrintAsOneLiner(ValueObject *valobj) const {
723 return m_type_system->ShouldPrintAsOneLiner(m_type, valobj);
724 return eLazyBoolCalculate;
727 bool CompilerType::IsMeaninglessWithoutDynamicResolution() const {
729 return m_type_system->IsMeaninglessWithoutDynamicResolution(m_type);
733 // Get the index of the child of "clang_type" whose name matches. This function
734 // doesn't descend into the children, but only looks one level deep and name
735 // matches can include base class names.
738 CompilerType::GetIndexOfChildWithName(const char *name,
739 bool omit_empty_base_classes) const {
740 if (IsValid() && name && name[0]) {
741 return m_type_system->GetIndexOfChildWithName(m_type, name,
742 omit_empty_base_classes);
747 size_t CompilerType::ConvertStringToFloatValue(const char *s, uint8_t *dst,
748 size_t dst_size) const {
750 return m_type_system->ConvertStringToFloatValue(m_type, s, dst, dst_size);
754 //----------------------------------------------------------------------
756 //----------------------------------------------------------------------
757 #define DEPTH_INCREMENT 2
759 void CompilerType::DumpValue(ExecutionContext *exe_ctx, Stream *s,
760 lldb::Format format, const DataExtractor &data,
761 lldb::offset_t data_byte_offset,
762 size_t data_byte_size, uint32_t bitfield_bit_size,
763 uint32_t bitfield_bit_offset, bool show_types,
764 bool show_summary, bool verbose, uint32_t depth) {
767 m_type_system->DumpValue(m_type, exe_ctx, s, format, data, data_byte_offset,
768 data_byte_size, bitfield_bit_size,
769 bitfield_bit_offset, show_types, show_summary,
773 bool CompilerType::DumpTypeValue(Stream *s, lldb::Format format,
774 const DataExtractor &data,
775 lldb::offset_t byte_offset, size_t byte_size,
776 uint32_t bitfield_bit_size,
777 uint32_t bitfield_bit_offset,
778 ExecutionContextScope *exe_scope) {
781 return m_type_system->DumpTypeValue(m_type, s, format, data, byte_offset,
782 byte_size, bitfield_bit_size,
783 bitfield_bit_offset, exe_scope);
786 void CompilerType::DumpSummary(ExecutionContext *exe_ctx, Stream *s,
787 const DataExtractor &data,
788 lldb::offset_t data_byte_offset,
789 size_t data_byte_size) {
791 m_type_system->DumpSummary(m_type, exe_ctx, s, data, data_byte_offset,
795 void CompilerType::DumpTypeDescription() const {
797 m_type_system->DumpTypeDescription(m_type);
800 void CompilerType::DumpTypeDescription(Stream *s) const {
802 m_type_system->DumpTypeDescription(m_type, s);
806 bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
807 lldb::offset_t data_byte_offset,
808 size_t data_byte_size,
809 Scalar &value) const {
813 if (IsAggregateType()) {
814 return false; // Aggregate types don't have scalar values
817 lldb::Encoding encoding = GetEncoding(count);
819 if (encoding == lldb::eEncodingInvalid || count != 1)
822 llvm::Optional<uint64_t> byte_size = GetByteSize(nullptr);
825 lldb::offset_t offset = data_byte_offset;
827 case lldb::eEncodingInvalid:
829 case lldb::eEncodingVector:
831 case lldb::eEncodingUint:
832 if (*byte_size <= sizeof(unsigned long long)) {
833 uint64_t uval64 = data.GetMaxU64(&offset, *byte_size);
834 if (*byte_size <= sizeof(unsigned int)) {
835 value = (unsigned int)uval64;
837 } else if (*byte_size <= sizeof(unsigned long)) {
838 value = (unsigned long)uval64;
840 } else if (*byte_size <= sizeof(unsigned long long)) {
841 value = (unsigned long long)uval64;
848 case lldb::eEncodingSint:
849 if (*byte_size <= sizeof(long long)) {
850 int64_t sval64 = data.GetMaxS64(&offset, *byte_size);
851 if (*byte_size <= sizeof(int)) {
854 } else if (*byte_size <= sizeof(long)) {
855 value = (long)sval64;
857 } else if (*byte_size <= sizeof(long long)) {
858 value = (long long)sval64;
865 case lldb::eEncodingIEEE754:
866 if (*byte_size <= sizeof(long double)) {
869 if (*byte_size == sizeof(float)) {
870 if (sizeof(float) == sizeof(uint32_t)) {
871 u32 = data.GetU32(&offset);
872 value = *((float *)&u32);
874 } else if (sizeof(float) == sizeof(uint64_t)) {
875 u64 = data.GetU64(&offset);
876 value = *((float *)&u64);
879 } else if (*byte_size == sizeof(double)) {
880 if (sizeof(double) == sizeof(uint32_t)) {
881 u32 = data.GetU32(&offset);
882 value = *((double *)&u32);
884 } else if (sizeof(double) == sizeof(uint64_t)) {
885 u64 = data.GetU64(&offset);
886 value = *((double *)&u64);
889 } else if (*byte_size == sizeof(long double)) {
890 if (sizeof(long double) == sizeof(uint32_t)) {
891 u32 = data.GetU32(&offset);
892 value = *((long double *)&u32);
894 } else if (sizeof(long double) == sizeof(uint64_t)) {
895 u64 = data.GetU64(&offset);
896 value = *((long double *)&u64);
907 bool CompilerType::SetValueFromScalar(const Scalar &value, Stream &strm) {
911 // Aggregate types don't have scalar values
912 if (!IsAggregateType()) {
913 strm.GetFlags().Set(Stream::eBinary);
915 lldb::Encoding encoding = GetEncoding(count);
917 if (encoding == lldb::eEncodingInvalid || count != 1)
920 llvm::Optional<uint64_t> bit_width = GetBitSize(nullptr);
924 // This function doesn't currently handle non-byte aligned assignments
925 if ((*bit_width % 8) != 0)
928 const uint64_t byte_size = (*bit_width + 7) / 8;
930 case lldb::eEncodingInvalid:
932 case lldb::eEncodingVector:
934 case lldb::eEncodingUint:
937 strm.PutHex8(value.UInt());
940 strm.PutHex16(value.UInt());
943 strm.PutHex32(value.UInt());
946 strm.PutHex64(value.ULongLong());
953 case lldb::eEncodingSint:
956 strm.PutHex8(value.SInt());
959 strm.PutHex16(value.SInt());
962 strm.PutHex32(value.SInt());
965 strm.PutHex64(value.SLongLong());
972 case lldb::eEncodingIEEE754:
973 if (byte_size <= sizeof(long double)) {
974 if (byte_size == sizeof(float)) {
975 strm.PutFloat(value.Float());
977 } else if (byte_size == sizeof(double)) {
978 strm.PutDouble(value.Double());
980 } else if (byte_size == sizeof(long double)) {
981 strm.PutDouble(value.LongDouble());
991 bool CompilerType::ReadFromMemory(lldb_private::ExecutionContext *exe_ctx,
992 lldb::addr_t addr, AddressType address_type,
993 lldb_private::DataExtractor &data) {
997 // Can't convert a file address to anything valid without more context (which
998 // Module it came from)
999 if (address_type == eAddressTypeFile)
1002 if (!GetCompleteType())
1006 GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
1010 if (data.GetByteSize() < *byte_size) {
1011 lldb::DataBufferSP data_sp(new DataBufferHeap(*byte_size, '\0'));
1012 data.SetData(data_sp);
1015 uint8_t *dst = const_cast<uint8_t *>(data.PeekData(0, *byte_size));
1016 if (dst != nullptr) {
1017 if (address_type == eAddressTypeHost) {
1020 // The address is an address in this process, so just copy it
1021 memcpy(dst, reinterpret_cast<uint8_t *>(addr), *byte_size);
1024 Process *process = nullptr;
1026 process = exe_ctx->GetProcessPtr();
1029 return process->ReadMemory(addr, dst, *byte_size, error) == *byte_size;
1036 bool CompilerType::WriteToMemory(lldb_private::ExecutionContext *exe_ctx,
1037 lldb::addr_t addr, AddressType address_type,
1038 StreamString &new_value) {
1042 // Can't convert a file address to anything valid without more context (which
1043 // Module it came from)
1044 if (address_type == eAddressTypeFile)
1047 if (!GetCompleteType())
1051 GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
1055 if (*byte_size > 0) {
1056 if (address_type == eAddressTypeHost) {
1057 // The address is an address in this process, so just copy it
1058 memcpy((void *)addr, new_value.GetData(), *byte_size);
1061 Process *process = nullptr;
1063 process = exe_ctx->GetProcessPtr();
1066 return process->WriteMemory(addr, new_value.GetData(), *byte_size,
1067 error) == *byte_size;
1074 bool lldb_private::operator==(const lldb_private::CompilerType &lhs,
1075 const lldb_private::CompilerType &rhs) {
1076 return lhs.GetTypeSystem() == rhs.GetTypeSystem() &&
1077 lhs.GetOpaqueQualType() == rhs.GetOpaqueQualType();
1080 bool lldb_private::operator!=(const lldb_private::CompilerType &lhs,
1081 const lldb_private::CompilerType &rhs) {
1082 return !(lhs == rhs);