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/Scalar.h"
14 #include "lldb/Core/StreamFile.h"
15 #include "lldb/Symbol/ClangASTContext.h"
16 #include "lldb/Symbol/ClangExternalASTSourceCommon.h"
17 #include "lldb/Symbol/Type.h"
18 #include "lldb/Target/ExecutionContext.h"
19 #include "lldb/Target/Process.h"
20 #include "lldb/Utility/ConstString.h"
21 #include "lldb/Utility/DataBufferHeap.h"
22 #include "lldb/Utility/DataExtractor.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 uint64_t CompilerType::GetBitSize(ExecutionContextScope *exe_scope) const {
509 return m_type_system->GetBitSize(m_type, exe_scope);
514 uint64_t CompilerType::GetByteSize(ExecutionContextScope *exe_scope) const {
515 return (GetBitSize(exe_scope) + 7) / 8;
518 size_t CompilerType::GetTypeBitAlign() const {
520 return m_type_system->GetTypeBitAlign(m_type);
524 lldb::Encoding CompilerType::GetEncoding(uint64_t &count) const {
526 return lldb::eEncodingInvalid;
528 return m_type_system->GetEncoding(m_type, count);
531 lldb::Format CompilerType::GetFormat() const {
533 return lldb::eFormatDefault;
535 return m_type_system->GetFormat(m_type);
538 uint32_t CompilerType::GetNumChildren(bool omit_empty_base_classes) const {
541 return m_type_system->GetNumChildren(m_type, omit_empty_base_classes);
544 lldb::BasicType CompilerType::GetBasicTypeEnumeration() const {
546 return m_type_system->GetBasicTypeEnumeration(m_type);
547 return eBasicTypeInvalid;
550 void CompilerType::ForEachEnumerator(
551 std::function<bool(const CompilerType &integer_type,
552 const ConstString &name,
553 const llvm::APSInt &value)> const &callback) const {
555 return m_type_system->ForEachEnumerator(m_type, callback);
558 uint32_t CompilerType::GetNumFields() const {
561 return m_type_system->GetNumFields(m_type);
564 CompilerType CompilerType::GetFieldAtIndex(size_t idx, std::string &name,
565 uint64_t *bit_offset_ptr,
566 uint32_t *bitfield_bit_size_ptr,
567 bool *is_bitfield_ptr) const {
569 return CompilerType();
570 return m_type_system->GetFieldAtIndex(m_type, idx, name, bit_offset_ptr,
571 bitfield_bit_size_ptr, is_bitfield_ptr);
574 uint32_t CompilerType::GetNumDirectBaseClasses() const {
576 return m_type_system->GetNumDirectBaseClasses(m_type);
580 uint32_t CompilerType::GetNumVirtualBaseClasses() const {
582 return m_type_system->GetNumVirtualBaseClasses(m_type);
587 CompilerType::GetDirectBaseClassAtIndex(size_t idx,
588 uint32_t *bit_offset_ptr) const {
590 return m_type_system->GetDirectBaseClassAtIndex(m_type, idx,
592 return CompilerType();
596 CompilerType::GetVirtualBaseClassAtIndex(size_t idx,
597 uint32_t *bit_offset_ptr) const {
599 return m_type_system->GetVirtualBaseClassAtIndex(m_type, idx,
601 return CompilerType();
604 uint32_t CompilerType::GetIndexOfFieldWithName(
605 const char *name, CompilerType *field_compiler_type_ptr,
606 uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr,
607 bool *is_bitfield_ptr) const {
608 unsigned count = GetNumFields();
609 std::string field_name;
610 for (unsigned index = 0; index < count; index++) {
611 CompilerType field_compiler_type(
612 GetFieldAtIndex(index, field_name, bit_offset_ptr,
613 bitfield_bit_size_ptr, is_bitfield_ptr));
614 if (strcmp(field_name.c_str(), name) == 0) {
615 if (field_compiler_type_ptr)
616 *field_compiler_type_ptr = field_compiler_type;
623 CompilerType CompilerType::GetChildCompilerTypeAtIndex(
624 ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers,
625 bool omit_empty_base_classes, bool ignore_array_bounds,
626 std::string &child_name, uint32_t &child_byte_size,
627 int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size,
628 uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
629 bool &child_is_deref_of_parent, ValueObject *valobj,
630 uint64_t &language_flags) const {
632 return CompilerType();
633 return m_type_system->GetChildCompilerTypeAtIndex(
634 m_type, exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
635 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
636 child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
637 child_is_deref_of_parent, valobj, language_flags);
640 // Look for a child member (doesn't include base classes, but it does include
641 // their members) in the type hierarchy. Returns an index path into "clang_type"
642 // on how to reach the appropriate member.
661 // If we have a clang type that describes "class C", and we wanted to looked
664 // With omit_empty_base_classes == false we would get an integer array back
667 // The first index 1 is the child index for "class A" within class C
668 // The second index 1 is the child index for "m_b" within class A
670 // With omit_empty_base_classes == true we would get an integer array back with:
672 // The first index 0 is the child index for "class A" within class C (since
673 // class B doesn't have any members it doesn't count)
674 // The second index 1 is the child index for "m_b" within class A
676 size_t CompilerType::GetIndexOfChildMemberWithName(
677 const char *name, bool omit_empty_base_classes,
678 std::vector<uint32_t> &child_indexes) const {
679 if (IsValid() && name && name[0]) {
680 return m_type_system->GetIndexOfChildMemberWithName(
681 m_type, name, omit_empty_base_classes, child_indexes);
686 size_t CompilerType::GetNumTemplateArguments() const {
688 return m_type_system->GetNumTemplateArguments(m_type);
693 TemplateArgumentKind CompilerType::GetTemplateArgumentKind(size_t idx) const {
695 return m_type_system->GetTemplateArgumentKind(m_type, idx);
696 return eTemplateArgumentKindNull;
699 CompilerType CompilerType::GetTypeTemplateArgument(size_t idx) const {
701 return m_type_system->GetTypeTemplateArgument(m_type, idx);
703 return CompilerType();
706 llvm::Optional<CompilerType::IntegralTemplateArgument>
707 CompilerType::GetIntegralTemplateArgument(size_t idx) const {
709 return m_type_system->GetIntegralTemplateArgument(m_type, idx);
713 CompilerType CompilerType::GetTypeForFormatters() const {
715 return m_type_system->GetTypeForFormatters(m_type);
716 return CompilerType();
719 LazyBool CompilerType::ShouldPrintAsOneLiner(ValueObject *valobj) const {
721 return m_type_system->ShouldPrintAsOneLiner(m_type, valobj);
722 return eLazyBoolCalculate;
725 bool CompilerType::IsMeaninglessWithoutDynamicResolution() const {
727 return m_type_system->IsMeaninglessWithoutDynamicResolution(m_type);
731 // Get the index of the child of "clang_type" whose name matches. This function
732 // doesn't descend into the children, but only looks one level deep and name
733 // matches can include base class names.
736 CompilerType::GetIndexOfChildWithName(const char *name,
737 bool omit_empty_base_classes) const {
738 if (IsValid() && name && name[0]) {
739 return m_type_system->GetIndexOfChildWithName(m_type, name,
740 omit_empty_base_classes);
745 size_t CompilerType::ConvertStringToFloatValue(const char *s, uint8_t *dst,
746 size_t dst_size) const {
748 return m_type_system->ConvertStringToFloatValue(m_type, s, dst, dst_size);
752 //----------------------------------------------------------------------
754 //----------------------------------------------------------------------
755 #define DEPTH_INCREMENT 2
757 void CompilerType::DumpValue(ExecutionContext *exe_ctx, Stream *s,
758 lldb::Format format, const DataExtractor &data,
759 lldb::offset_t data_byte_offset,
760 size_t data_byte_size, uint32_t bitfield_bit_size,
761 uint32_t bitfield_bit_offset, bool show_types,
762 bool show_summary, bool verbose, uint32_t depth) {
765 m_type_system->DumpValue(m_type, exe_ctx, s, format, data, data_byte_offset,
766 data_byte_size, bitfield_bit_size,
767 bitfield_bit_offset, show_types, show_summary,
771 bool CompilerType::DumpTypeValue(Stream *s, lldb::Format format,
772 const DataExtractor &data,
773 lldb::offset_t byte_offset, size_t byte_size,
774 uint32_t bitfield_bit_size,
775 uint32_t bitfield_bit_offset,
776 ExecutionContextScope *exe_scope) {
779 return m_type_system->DumpTypeValue(m_type, s, format, data, byte_offset,
780 byte_size, bitfield_bit_size,
781 bitfield_bit_offset, exe_scope);
784 void CompilerType::DumpSummary(ExecutionContext *exe_ctx, Stream *s,
785 const DataExtractor &data,
786 lldb::offset_t data_byte_offset,
787 size_t data_byte_size) {
789 m_type_system->DumpSummary(m_type, exe_ctx, s, data, data_byte_offset,
793 void CompilerType::DumpTypeDescription() const {
795 m_type_system->DumpTypeDescription(m_type);
798 void CompilerType::DumpTypeDescription(Stream *s) const {
800 m_type_system->DumpTypeDescription(m_type, s);
804 bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
805 lldb::offset_t data_byte_offset,
806 size_t data_byte_size,
807 Scalar &value) const {
811 if (IsAggregateType()) {
812 return false; // Aggregate types don't have scalar values
815 lldb::Encoding encoding = GetEncoding(count);
817 if (encoding == lldb::eEncodingInvalid || count != 1)
820 const uint64_t byte_size = GetByteSize(nullptr);
821 lldb::offset_t offset = data_byte_offset;
823 case lldb::eEncodingInvalid:
825 case lldb::eEncodingVector:
827 case lldb::eEncodingUint:
828 if (byte_size <= sizeof(unsigned long long)) {
829 uint64_t uval64 = data.GetMaxU64(&offset, byte_size);
830 if (byte_size <= sizeof(unsigned int)) {
831 value = (unsigned int)uval64;
833 } else if (byte_size <= sizeof(unsigned long)) {
834 value = (unsigned long)uval64;
836 } else if (byte_size <= sizeof(unsigned long long)) {
837 value = (unsigned long long)uval64;
844 case lldb::eEncodingSint:
845 if (byte_size <= sizeof(long long)) {
846 int64_t sval64 = data.GetMaxS64(&offset, byte_size);
847 if (byte_size <= sizeof(int)) {
850 } else if (byte_size <= sizeof(long)) {
851 value = (long)sval64;
853 } else if (byte_size <= sizeof(long long)) {
854 value = (long long)sval64;
861 case lldb::eEncodingIEEE754:
862 if (byte_size <= sizeof(long double)) {
865 if (byte_size == sizeof(float)) {
866 if (sizeof(float) == sizeof(uint32_t)) {
867 u32 = data.GetU32(&offset);
868 value = *((float *)&u32);
870 } else if (sizeof(float) == sizeof(uint64_t)) {
871 u64 = data.GetU64(&offset);
872 value = *((float *)&u64);
875 } else if (byte_size == sizeof(double)) {
876 if (sizeof(double) == sizeof(uint32_t)) {
877 u32 = data.GetU32(&offset);
878 value = *((double *)&u32);
880 } else if (sizeof(double) == sizeof(uint64_t)) {
881 u64 = data.GetU64(&offset);
882 value = *((double *)&u64);
885 } else if (byte_size == sizeof(long double)) {
886 if (sizeof(long double) == sizeof(uint32_t)) {
887 u32 = data.GetU32(&offset);
888 value = *((long double *)&u32);
890 } else if (sizeof(long double) == sizeof(uint64_t)) {
891 u64 = data.GetU64(&offset);
892 value = *((long double *)&u64);
903 bool CompilerType::SetValueFromScalar(const Scalar &value, Stream &strm) {
907 // Aggregate types don't have scalar values
908 if (!IsAggregateType()) {
909 strm.GetFlags().Set(Stream::eBinary);
911 lldb::Encoding encoding = GetEncoding(count);
913 if (encoding == lldb::eEncodingInvalid || count != 1)
916 const uint64_t bit_width = GetBitSize(nullptr);
917 // This function doesn't currently handle non-byte aligned assignments
918 if ((bit_width % 8) != 0)
921 const uint64_t byte_size = (bit_width + 7) / 8;
923 case lldb::eEncodingInvalid:
925 case lldb::eEncodingVector:
927 case lldb::eEncodingUint:
930 strm.PutHex8(value.UInt());
933 strm.PutHex16(value.UInt());
936 strm.PutHex32(value.UInt());
939 strm.PutHex64(value.ULongLong());
946 case lldb::eEncodingSint:
949 strm.PutHex8(value.SInt());
952 strm.PutHex16(value.SInt());
955 strm.PutHex32(value.SInt());
958 strm.PutHex64(value.SLongLong());
965 case lldb::eEncodingIEEE754:
966 if (byte_size <= sizeof(long double)) {
967 if (byte_size == sizeof(float)) {
968 strm.PutFloat(value.Float());
970 } else if (byte_size == sizeof(double)) {
971 strm.PutDouble(value.Double());
973 } else if (byte_size == sizeof(long double)) {
974 strm.PutDouble(value.LongDouble());
984 bool CompilerType::ReadFromMemory(lldb_private::ExecutionContext *exe_ctx,
985 lldb::addr_t addr, AddressType address_type,
986 lldb_private::DataExtractor &data) {
990 // Can't convert a file address to anything valid without more
991 // context (which Module it came from)
992 if (address_type == eAddressTypeFile)
995 if (!GetCompleteType())
998 const uint64_t byte_size =
999 GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
1000 if (data.GetByteSize() < byte_size) {
1001 lldb::DataBufferSP data_sp(new DataBufferHeap(byte_size, '\0'));
1002 data.SetData(data_sp);
1005 uint8_t *dst = const_cast<uint8_t *>(data.PeekData(0, byte_size));
1006 if (dst != nullptr) {
1007 if (address_type == eAddressTypeHost) {
1010 // The address is an address in this process, so just copy it
1011 memcpy(dst, reinterpret_cast<uint8_t *>(addr), byte_size);
1014 Process *process = nullptr;
1016 process = exe_ctx->GetProcessPtr();
1019 return process->ReadMemory(addr, dst, byte_size, error) == byte_size;
1026 bool CompilerType::WriteToMemory(lldb_private::ExecutionContext *exe_ctx,
1027 lldb::addr_t addr, AddressType address_type,
1028 StreamString &new_value) {
1032 // Can't convert a file address to anything valid without more
1033 // context (which Module it came from)
1034 if (address_type == eAddressTypeFile)
1037 if (!GetCompleteType())
1040 const uint64_t byte_size =
1041 GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
1043 if (byte_size > 0) {
1044 if (address_type == eAddressTypeHost) {
1045 // The address is an address in this process, so just copy it
1046 memcpy((void *)addr, new_value.GetData(), byte_size);
1049 Process *process = nullptr;
1051 process = exe_ctx->GetProcessPtr();
1054 return process->WriteMemory(addr, new_value.GetData(), byte_size,
1055 error) == byte_size;
1062 // clang::CXXRecordDecl *
1063 // CompilerType::GetAsCXXRecordDecl (lldb::opaque_compiler_type_t
1064 // opaque_compiler_qual_type)
1066 // if (opaque_compiler_qual_type)
1068 // clang::QualType::getFromOpaquePtr(opaque_compiler_qual_type)->getAsCXXRecordDecl();
1072 bool lldb_private::operator==(const lldb_private::CompilerType &lhs,
1073 const lldb_private::CompilerType &rhs) {
1074 return lhs.GetTypeSystem() == rhs.GetTypeSystem() &&
1075 lhs.GetOpaqueQualType() == rhs.GetOpaqueQualType();
1078 bool lldb_private::operator!=(const lldb_private::CompilerType &lhs,
1079 const lldb_private::CompilerType &rhs) {
1080 return lhs.GetTypeSystem() != rhs.GetTypeSystem() ||
1081 lhs.GetOpaqueQualType() != rhs.GetOpaqueQualType();