1 //===-- Type.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 // Other libraries and framework includes
12 #include "lldb/Core/DataExtractor.h"
13 #include "lldb/Core/DataBufferHeap.h"
14 #include "lldb/Core/Module.h"
15 #include "lldb/Core/Scalar.h"
16 #include "lldb/Core/StreamString.h"
18 #include "lldb/Symbol/ClangASTType.h"
19 #include "lldb/Symbol/ClangASTContext.h"
20 #include "lldb/Symbol/ObjectFile.h"
21 #include "lldb/Symbol/SymbolContextScope.h"
22 #include "lldb/Symbol/SymbolFile.h"
23 #include "lldb/Symbol/SymbolVendor.h"
24 #include "lldb/Symbol/Type.h"
25 #include "lldb/Symbol/TypeList.h"
27 #include "lldb/Target/ExecutionContext.h"
28 #include "lldb/Target/Process.h"
29 #include "lldb/Target/Target.h"
31 #include "llvm/ADT/StringRef.h"
33 #include "clang/AST/Decl.h"
36 using namespace lldb_private;
38 class TypeAppendVisitor
41 TypeAppendVisitor(TypeListImpl &type_list) :
42 m_type_list(type_list)
47 operator() (const lldb::TypeSP& type)
49 m_type_list.Append(TypeImplSP(new TypeImpl(type)));
54 TypeListImpl &m_type_list;
58 TypeListImpl::Append (const lldb_private::TypeList &type_list)
60 TypeAppendVisitor cb(*this);
61 type_list.ForEach(cb);
66 SymbolFileType::GetType ()
70 Type *resolved_type = m_symbol_file.ResolveTypeUID (GetID());
72 m_type_sp = resolved_type->shared_from_this();
74 return m_type_sp.get();
81 SymbolFile* symbol_file,
82 const ConstString &name,
84 SymbolContextScope *context,
85 user_id_t encoding_uid,
86 EncodingDataType encoding_uid_type,
87 const Declaration& decl,
88 const ClangASTType &clang_type,
89 ResolveState clang_type_resolve_state
91 std::enable_shared_from_this<Type> (),
94 m_symbol_file (symbol_file),
96 m_encoding_type (nullptr),
97 m_encoding_uid (encoding_uid),
98 m_encoding_uid_type (encoding_uid_type),
99 m_byte_size (byte_size),
101 m_clang_type (clang_type)
103 m_flags.clang_type_resolve_state = (clang_type ? clang_type_resolve_state : eResolveStateUnresolved);
104 m_flags.is_complete_objc_class = false;
108 std::enable_shared_from_this<Type> (),
110 m_name ("<INVALID TYPE>"),
111 m_symbol_file (nullptr),
113 m_encoding_type (nullptr),
114 m_encoding_uid (LLDB_INVALID_UID),
115 m_encoding_uid_type (eEncodingInvalid),
120 m_flags.clang_type_resolve_state = eResolveStateUnresolved;
121 m_flags.is_complete_objc_class = false;
125 Type::Type (const Type &rhs) :
126 std::enable_shared_from_this<Type> (rhs),
129 m_symbol_file (rhs.m_symbol_file),
130 m_context (rhs.m_context),
131 m_encoding_type (rhs.m_encoding_type),
132 m_encoding_uid (rhs.m_encoding_uid),
133 m_encoding_uid_type (rhs.m_encoding_uid_type),
134 m_byte_size (rhs.m_byte_size),
136 m_clang_type (rhs.m_clang_type),
137 m_flags (rhs.m_flags)
142 Type::operator= (const Type& rhs)
152 Type::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_name)
154 *s << "id = " << (const UserID&)*this;
156 // Call the name accessor to make sure we resolve the type name
159 const ConstString &type_name = GetName();
162 *s << ", name = \"" << type_name << '"';
163 ConstString qualified_type_name (GetQualifiedName());
164 if (qualified_type_name != type_name)
166 *s << ", qualified = \"" << qualified_type_name << '"';
171 // Call the get byte size accesor so we resolve our byte size
173 s->Printf(", byte-size = %" PRIu64, m_byte_size);
174 bool show_fullpaths = (level == lldb::eDescriptionLevelVerbose);
175 m_decl.Dump(s, show_fullpaths);
177 if (m_clang_type.IsValid())
179 *s << ", clang_type = \"";
180 GetClangForwardType().DumpTypeDescription(s);
183 else if (m_encoding_uid != LLDB_INVALID_UID)
185 s->Printf(", type_uid = 0x%8.8" PRIx64, m_encoding_uid);
186 switch (m_encoding_uid_type)
188 case eEncodingInvalid: break;
189 case eEncodingIsUID: s->PutCString(" (unresolved type)"); break;
190 case eEncodingIsConstUID: s->PutCString(" (unresolved const type)"); break;
191 case eEncodingIsRestrictUID: s->PutCString(" (unresolved restrict type)"); break;
192 case eEncodingIsVolatileUID: s->PutCString(" (unresolved volatile type)"); break;
193 case eEncodingIsTypedefUID: s->PutCString(" (unresolved typedef)"); break;
194 case eEncodingIsPointerUID: s->PutCString(" (unresolved pointer)"); break;
195 case eEncodingIsLValueReferenceUID: s->PutCString(" (unresolved L value reference)"); break;
196 case eEncodingIsRValueReferenceUID: s->PutCString(" (unresolved R value reference)"); break;
197 case eEncodingIsSyntheticUID: s->PutCString(" (synthetic type)"); break;
204 Type::Dump (Stream *s, bool show_context)
206 s->Printf("%p: ", static_cast<void*>(this));
208 *s << "Type" << static_cast<const UserID&>(*this) << ' ';
210 *s << ", name = \"" << m_name << "\"";
212 if (m_byte_size != 0)
213 s->Printf(", size = %" PRIu64, m_byte_size);
215 if (show_context && m_context != nullptr)
217 s->PutCString(", context = ( ");
218 m_context->DumpSymbolContext(s);
222 bool show_fullpaths = false;
223 m_decl.Dump (s,show_fullpaths);
225 if (m_clang_type.IsValid())
227 *s << ", clang_type = " << m_clang_type.GetOpaqueQualType() << ' ';
228 GetClangForwardType().DumpTypeDescription (s);
230 else if (m_encoding_uid != LLDB_INVALID_UID)
232 *s << ", type_data = " << (uint64_t)m_encoding_uid;
233 switch (m_encoding_uid_type)
235 case eEncodingInvalid: break;
236 case eEncodingIsUID: s->PutCString(" (unresolved type)"); break;
237 case eEncodingIsConstUID: s->PutCString(" (unresolved const type)"); break;
238 case eEncodingIsRestrictUID: s->PutCString(" (unresolved restrict type)"); break;
239 case eEncodingIsVolatileUID: s->PutCString(" (unresolved volatile type)"); break;
240 case eEncodingIsTypedefUID: s->PutCString(" (unresolved typedef)"); break;
241 case eEncodingIsPointerUID: s->PutCString(" (unresolved pointer)"); break;
242 case eEncodingIsLValueReferenceUID: s->PutCString(" (unresolved L value reference)"); break;
243 case eEncodingIsRValueReferenceUID: s->PutCString(" (unresolved R value reference)"); break;
244 case eEncodingIsSyntheticUID: s->PutCString(" (synthetic type)"); break;
250 // s->Printf(", access = %u", m_access);
258 m_name = GetClangForwardType().GetConstTypeName();
263 Type::DumpTypeName(Stream *s)
265 GetName().Dump(s, "<invalid-type-name>");
272 ExecutionContext *exe_ctx,
274 const DataExtractor &data,
275 uint32_t data_byte_offset,
282 if (ResolveClangType(eResolveStateForward))
288 s->Printf("Type{0x%8.8" PRIx64 "} ", GetID());
293 GetClangForwardType().DumpValue (exe_ctx,
295 format == lldb::eFormatDefault ? GetFormat() : format,
299 0, // Bitfield bit size
300 0, // Bitfield bit offset
309 Type::GetEncodingType ()
311 if (m_encoding_type == nullptr && m_encoding_uid != LLDB_INVALID_UID)
312 m_encoding_type = m_symbol_file->ResolveTypeUID(m_encoding_uid);
313 return m_encoding_type;
321 if (m_byte_size == 0)
323 switch (m_encoding_uid_type)
325 case eEncodingInvalid:
326 case eEncodingIsSyntheticUID:
329 case eEncodingIsConstUID:
330 case eEncodingIsRestrictUID:
331 case eEncodingIsVolatileUID:
332 case eEncodingIsTypedefUID:
334 Type *encoding_type = GetEncodingType ();
336 m_byte_size = encoding_type->GetByteSize();
337 if (m_byte_size == 0)
338 m_byte_size = GetClangLayoutType().GetByteSize();
342 // If we are a pointer or reference, then this is just a pointer size;
343 case eEncodingIsPointerUID:
344 case eEncodingIsLValueReferenceUID:
345 case eEncodingIsRValueReferenceUID:
346 m_byte_size = m_symbol_file->GetClangASTContext().GetPointerByteSize();
355 Type::GetNumChildren (bool omit_empty_base_classes)
357 return GetClangForwardType().GetNumChildren(omit_empty_base_classes);
361 Type::IsAggregateType ()
363 return GetClangForwardType().IsAggregateType();
367 Type::GetTypedefType()
369 lldb::TypeSP type_sp;
372 Type *typedef_type = m_symbol_file->ResolveTypeUID(m_encoding_uid);
374 type_sp = typedef_type->shared_from_this();
384 return GetClangForwardType().GetFormat();
390 Type::GetEncoding (uint64_t &count)
392 // Make sure we resolve our type if it already hasn't been.
393 return GetClangForwardType().GetEncoding(count);
397 Type::DumpValueInMemory
399 ExecutionContext *exe_ctx,
401 lldb::addr_t address,
402 AddressType address_type,
408 if (address != LLDB_INVALID_ADDRESS)
411 Target *target = nullptr;
413 target = exe_ctx->GetTargetPtr();
415 data.SetByteOrder (target->GetArchitecture().GetByteOrder());
416 if (ReadFromMemory (exe_ctx, address, address_type, data))
418 DumpValue(exe_ctx, s, data, 0, show_types, show_summary, verbose);
427 Type::ReadFromMemory (ExecutionContext *exe_ctx, lldb::addr_t addr, AddressType address_type, DataExtractor &data)
429 if (address_type == eAddressTypeFile)
431 // Can't convert a file address to anything valid without more
432 // context (which Module it came from)
436 const uint64_t byte_size = GetByteSize();
437 if (data.GetByteSize() < byte_size)
439 lldb::DataBufferSP data_sp(new DataBufferHeap (byte_size, '\0'));
440 data.SetData(data_sp);
443 uint8_t* dst = (uint8_t*)data.PeekData(0, byte_size);
446 if (address_type == eAddressTypeHost)
448 // The address is an address in this process, so just copy it
451 memcpy (dst, (uint8_t*)nullptr + addr, byte_size);
458 Process *process = exe_ctx->GetProcessPtr();
462 return exe_ctx->GetProcessPtr()->ReadMemory(addr, dst, byte_size, error) == byte_size;
472 Type::WriteToMemory (ExecutionContext *exe_ctx, lldb::addr_t addr, AddressType address_type, DataExtractor &data)
481 return GetSymbolFile()->GetTypeList();
485 Type::GetDeclaration () const
491 Type::ResolveClangType (ResolveState clang_type_resolve_state)
493 Type *encoding_type = nullptr;
494 if (!m_clang_type.IsValid())
496 encoding_type = GetEncodingType();
499 switch (m_encoding_uid_type)
503 ClangASTType encoding_clang_type = encoding_type->GetClangForwardType();
504 if (encoding_clang_type.IsValid())
506 m_clang_type = encoding_clang_type;
507 m_flags.clang_type_resolve_state = encoding_type->m_flags.clang_type_resolve_state;
512 case eEncodingIsConstUID:
513 m_clang_type = encoding_type->GetClangForwardType().AddConstModifier();
516 case eEncodingIsRestrictUID:
517 m_clang_type = encoding_type->GetClangForwardType().AddRestrictModifier();
520 case eEncodingIsVolatileUID:
521 m_clang_type = encoding_type->GetClangForwardType().AddVolatileModifier();
524 case eEncodingIsTypedefUID:
525 m_clang_type = encoding_type->GetClangForwardType().CreateTypedefType (GetName().AsCString(),
526 GetSymbolFile()->GetClangDeclContextContainingTypeUID(GetID()));
530 case eEncodingIsPointerUID:
531 m_clang_type = encoding_type->GetClangForwardType().GetPointerType();
534 case eEncodingIsLValueReferenceUID:
535 m_clang_type = encoding_type->GetClangForwardType().GetLValueReferenceType();
538 case eEncodingIsRValueReferenceUID:
539 m_clang_type = encoding_type->GetClangForwardType().GetRValueReferenceType();
543 assert(!"Unhandled encoding_data_type.");
549 // We have no encoding type, return void?
550 ClangASTType void_clang_type (ClangASTContext::GetBasicType(GetClangASTContext().getASTContext(), eBasicTypeVoid));
551 switch (m_encoding_uid_type)
554 m_clang_type = void_clang_type;
557 case eEncodingIsConstUID:
558 m_clang_type = void_clang_type.AddConstModifier ();
561 case eEncodingIsRestrictUID:
562 m_clang_type = void_clang_type.AddRestrictModifier ();
565 case eEncodingIsVolatileUID:
566 m_clang_type = void_clang_type.AddVolatileModifier ();
569 case eEncodingIsTypedefUID:
570 m_clang_type = void_clang_type.CreateTypedefType (GetName().AsCString(),
571 GetSymbolFile()->GetClangDeclContextContainingTypeUID(GetID()));
574 case eEncodingIsPointerUID:
575 m_clang_type = void_clang_type.GetPointerType ();
578 case eEncodingIsLValueReferenceUID:
579 m_clang_type = void_clang_type.GetLValueReferenceType ();
582 case eEncodingIsRValueReferenceUID:
583 m_clang_type = void_clang_type.GetRValueReferenceType ();
587 assert(!"Unhandled encoding_data_type.");
593 // Check if we have a forward reference to a class/struct/union/enum?
594 if (m_clang_type.IsValid() && m_flags.clang_type_resolve_state < clang_type_resolve_state)
596 m_flags.clang_type_resolve_state = eResolveStateFull;
597 if (!m_clang_type.IsDefined ())
599 // We have a forward declaration, we need to resolve it to a complete definition.
600 m_symbol_file->ResolveClangOpaqueTypeDefinition (m_clang_type);
604 // If we have an encoding type, then we need to make sure it is
605 // resolved appropriately.
606 if (m_encoding_uid != LLDB_INVALID_UID)
608 if (encoding_type == nullptr)
609 encoding_type = GetEncodingType();
612 ResolveState encoding_clang_type_resolve_state = clang_type_resolve_state;
614 if (clang_type_resolve_state == eResolveStateLayout)
616 switch (m_encoding_uid_type)
618 case eEncodingIsPointerUID:
619 case eEncodingIsLValueReferenceUID:
620 case eEncodingIsRValueReferenceUID:
621 encoding_clang_type_resolve_state = eResolveStateForward;
627 encoding_type->ResolveClangType (encoding_clang_type_resolve_state);
630 return m_clang_type.IsValid();
633 Type::GetEncodingMask ()
635 uint32_t encoding_mask = 1u << m_encoding_uid_type;
636 Type *encoding_type = GetEncodingType();
637 assert (encoding_type != this);
639 encoding_mask |= encoding_type->GetEncodingMask ();
640 return encoding_mask;
644 Type::GetClangFullType ()
646 ResolveClangType(eResolveStateFull);
651 Type::GetClangLayoutType ()
653 ResolveClangType(eResolveStateLayout);
658 Type::GetClangForwardType ()
660 ResolveClangType (eResolveStateForward);
665 Type::GetClangASTContext ()
667 return m_symbol_file->GetClangASTContext();
671 Type::Compare(const Type &a, const Type &b)
673 // Just compare the UID values for now...
674 lldb::user_id_t a_uid = a.GetID();
675 lldb::user_id_t b_uid = b.GetID();
681 // if (a.getQualType() == b.getQualType())
686 #if 0 // START REMOVE
687 // Move this into ClangASTType
689 Type::CreateClangPointerType (Type *type)
692 return GetClangASTContext().CreatePointerType(type->GetClangForwardType());
696 Type::CreateClangTypedefType (Type *typedef_type, Type *base_type)
698 assert(typedef_type && base_type);
699 return GetClangASTContext().CreateTypedefType (typedef_type->GetName().AsCString(),
700 base_type->GetClangForwardType(),
701 typedef_type->GetSymbolFile()->GetClangDeclContextContainingTypeUID(typedef_type->GetID()));
705 Type::CreateClangLValueReferenceType (Type *type)
708 return GetClangASTContext().CreateLValueReferenceType(type->GetClangForwardType());
712 Type::CreateClangRValueReferenceType (Type *type)
715 return GetClangASTContext().CreateRValueReferenceType (type->GetClangForwardType());
720 Type::IsRealObjCClass()
722 // For now we are just skipping ObjC classes that get made by hand from the runtime, because
723 // those don't have any information. We could extend this to only return true for "full
724 // definitions" if we can figure that out.
726 if (m_clang_type.IsObjCObjectOrInterfaceType() && GetByteSize() != 0)
733 Type::GetQualifiedName ()
735 return GetClangForwardType().GetConstTypeName();
740 Type::GetTypeScopeAndBasename (const char* &name_cstr,
742 std::string &basename,
743 TypeClass &type_class)
745 // Protect against null c string.
747 type_class = eTypeClassAny;
749 if (name_cstr && name_cstr[0])
751 llvm::StringRef name_strref(name_cstr);
752 if (name_strref.startswith("struct "))
755 type_class = eTypeClassStruct;
757 else if (name_strref.startswith("class "))
760 type_class = eTypeClassClass;
762 else if (name_strref.startswith("union "))
765 type_class = eTypeClassUnion;
767 else if (name_strref.startswith("enum "))
770 type_class = eTypeClassEnumeration;
772 else if (name_strref.startswith("typedef "))
775 type_class = eTypeClassTypedef;
777 const char *basename_cstr = name_cstr;
778 const char* namespace_separator = ::strstr (basename_cstr, "::");
779 if (namespace_separator)
781 const char* template_arg_char = ::strchr (basename_cstr, '<');
782 while (namespace_separator != nullptr)
784 if (template_arg_char && namespace_separator > template_arg_char) // but namespace'd template arguments are still good to go
786 basename_cstr = namespace_separator + 2;
787 namespace_separator = strstr(basename_cstr, "::");
789 if (basename_cstr > name_cstr)
791 scope.assign (name_cstr, basename_cstr - name_cstr);
792 basename.assign (basename_cstr);
805 return m_symbol_file->GetObjectFile()->GetModule();
810 TypeAndOrName::TypeAndOrName () : m_type_pair(), m_type_name()
815 TypeAndOrName::TypeAndOrName (TypeSP &in_type_sp) : m_type_pair(in_type_sp)
818 m_type_name = in_type_sp->GetName();
821 TypeAndOrName::TypeAndOrName (const char *in_type_str) : m_type_name(in_type_str)
825 TypeAndOrName::TypeAndOrName (const TypeAndOrName &rhs) : m_type_pair (rhs.m_type_pair), m_type_name (rhs.m_type_name)
830 TypeAndOrName::TypeAndOrName (ConstString &in_type_const_string) : m_type_name (in_type_const_string)
835 TypeAndOrName::operator= (const TypeAndOrName &rhs)
839 m_type_name = rhs.m_type_name;
840 m_type_pair = rhs.m_type_pair;
846 TypeAndOrName::operator==(const TypeAndOrName &other) const
848 if (m_type_pair != other.m_type_pair)
850 if (m_type_name != other.m_type_name)
856 TypeAndOrName::operator!=(const TypeAndOrName &other) const
858 if (m_type_pair != other.m_type_pair)
860 if (m_type_name != other.m_type_name)
866 TypeAndOrName::GetName () const
871 return m_type_pair.GetName();
872 return ConstString("<invalid>");
876 TypeAndOrName::SetName (const ConstString &type_name)
878 m_type_name = type_name;
882 TypeAndOrName::SetName (const char *type_name_cstr)
884 m_type_name.SetCString (type_name_cstr);
888 TypeAndOrName::SetTypeSP (lldb::TypeSP type_sp)
890 m_type_pair.SetType(type_sp);
892 m_type_name = m_type_pair.GetName();
896 TypeAndOrName::SetClangASTType (ClangASTType clang_type)
898 m_type_pair.SetType(clang_type);
900 m_type_name = m_type_pair.GetName();
904 TypeAndOrName::IsEmpty() const
906 if ((bool)m_type_name || (bool)m_type_pair)
913 TypeAndOrName::Clear ()
920 TypeAndOrName::HasName () const
922 return (bool)m_type_name;
926 TypeAndOrName::HasTypeSP () const
928 return m_type_pair.GetTypeSP().get() != nullptr;
932 TypeAndOrName::HasClangASTType () const
934 return m_type_pair.GetClangASTType().IsValid();
938 TypeImpl::TypeImpl() :
945 TypeImpl::TypeImpl(const TypeImpl& rhs) :
946 m_module_wp (rhs.m_module_wp),
947 m_static_type(rhs.m_static_type),
948 m_dynamic_type(rhs.m_dynamic_type)
952 TypeImpl::TypeImpl (const lldb::TypeSP &type_sp) :
960 TypeImpl::TypeImpl (const ClangASTType &clang_type) :
965 SetType (clang_type);
968 TypeImpl::TypeImpl (const lldb::TypeSP &type_sp, const ClangASTType &dynamic) :
970 m_static_type (type_sp),
971 m_dynamic_type(dynamic)
973 SetType (type_sp, dynamic);
976 TypeImpl::TypeImpl (const ClangASTType &static_type, const ClangASTType &dynamic_type) :
981 SetType (static_type, dynamic_type);
984 TypeImpl::TypeImpl (const TypePair &pair, const ClangASTType &dynamic) :
989 SetType (pair, dynamic);
993 TypeImpl::SetType (const lldb::TypeSP &type_sp)
995 m_static_type.SetType(type_sp);
997 m_module_wp = type_sp->GetModule();
999 m_module_wp = lldb::ModuleWP();
1003 TypeImpl::SetType (const ClangASTType &clang_type)
1005 m_module_wp = lldb::ModuleWP();
1006 m_static_type.SetType (clang_type);
1010 TypeImpl::SetType (const lldb::TypeSP &type_sp, const ClangASTType &dynamic)
1013 m_dynamic_type = dynamic;
1017 TypeImpl::SetType (const ClangASTType &clang_type, const ClangASTType &dynamic)
1019 m_module_wp = lldb::ModuleWP();
1020 m_static_type.SetType (clang_type);
1021 m_dynamic_type = dynamic;
1025 TypeImpl::SetType (const TypePair &pair, const ClangASTType &dynamic)
1027 m_module_wp = pair.GetModule();
1028 m_static_type = pair;
1029 m_dynamic_type = dynamic;
1033 TypeImpl::operator = (const TypeImpl& rhs)
1037 m_module_wp = rhs.m_module_wp;
1038 m_static_type = rhs.m_static_type;
1039 m_dynamic_type = rhs.m_dynamic_type;
1045 TypeImpl::CheckModule (lldb::ModuleSP &module_sp) const
1047 // Check if we have a module for this type. If we do and the shared pointer is
1048 // can be successfully initialized with m_module_wp, return true. Else return false
1049 // if we didn't have a module, or if we had a module and it has been deleted. Any
1050 // functions doing anything with a TypeSP in this TypeImpl class should call this
1051 // function and only do anything with the ivars if this function returns true. If
1052 // we have a module, the "module_sp" will be filled in with a strong reference to the
1053 // module so that the module will at least stay around long enough for the type
1054 // query to succeed.
1055 module_sp = m_module_wp.lock();
1058 lldb::ModuleWP empty_module_wp;
1059 // If either call to "std::weak_ptr::owner_before(...) value returns true, this
1060 // indicates that m_module_wp once contained (possibly still does) a reference
1061 // to a valid shared pointer. This helps us know if we had a valid reference to
1062 // a section which is now invalid because the module it was in was deleted
1063 if (empty_module_wp.owner_before(m_module_wp) || m_module_wp.owner_before(empty_module_wp))
1065 // m_module_wp had a valid reference to a module, but all strong references
1066 // have been released and the module has been deleted
1070 // We either successfully locked the module, or didn't have one to begin with
1075 TypeImpl::operator == (const TypeImpl& rhs) const
1077 return m_static_type == rhs.m_static_type && m_dynamic_type == rhs.m_dynamic_type;
1081 TypeImpl::operator != (const TypeImpl& rhs) const
1083 return m_static_type != rhs.m_static_type || m_dynamic_type != rhs.m_dynamic_type;
1087 TypeImpl::IsValid() const
1089 // just a name is not valid
1091 if (CheckModule (module_sp))
1092 return m_static_type.IsValid() || m_dynamic_type.IsValid();
1096 TypeImpl::operator bool () const
1104 m_module_wp = lldb::ModuleWP();
1105 m_static_type.Clear();
1106 m_dynamic_type.Clear();
1110 TypeImpl::GetName () const
1113 if (CheckModule (module_sp))
1116 return m_dynamic_type.GetTypeName();
1117 return m_static_type.GetName ();
1119 return ConstString();
1123 TypeImpl::GetDisplayTypeName () const
1126 if (CheckModule (module_sp))
1129 return m_dynamic_type.GetDisplayTypeName();
1130 return m_static_type.GetDisplayTypeName();
1132 return ConstString();
1136 TypeImpl::GetPointerType () const
1139 if (CheckModule (module_sp))
1141 if (m_dynamic_type.IsValid())
1143 return TypeImpl(m_static_type, m_dynamic_type.GetPointerType());
1145 return TypeImpl(m_static_type.GetPointerType());
1151 TypeImpl::GetPointeeType () const
1154 if (CheckModule (module_sp))
1156 if (m_dynamic_type.IsValid())
1158 return TypeImpl(m_static_type, m_dynamic_type.GetPointeeType());
1160 return TypeImpl(m_static_type.GetPointeeType());
1166 TypeImpl::GetReferenceType () const
1169 if (CheckModule (module_sp))
1171 if (m_dynamic_type.IsValid())
1173 return TypeImpl(m_static_type, m_dynamic_type.GetLValueReferenceType());
1175 return TypeImpl(m_static_type.GetReferenceType());
1181 TypeImpl::GetTypedefedType () const
1184 if (CheckModule (module_sp))
1186 if (m_dynamic_type.IsValid())
1188 return TypeImpl(m_static_type, m_dynamic_type.GetTypedefedType());
1190 return TypeImpl(m_static_type.GetTypedefedType());
1196 TypeImpl::GetDereferencedType () const
1199 if (CheckModule (module_sp))
1201 if (m_dynamic_type.IsValid())
1203 return TypeImpl(m_static_type, m_dynamic_type.GetNonReferenceType());
1205 return TypeImpl(m_static_type.GetDereferencedType());
1211 TypeImpl::GetUnqualifiedType() const
1214 if (CheckModule (module_sp))
1216 if (m_dynamic_type.IsValid())
1218 return TypeImpl(m_static_type, m_dynamic_type.GetFullyUnqualifiedType());
1220 return TypeImpl(m_static_type.GetUnqualifiedType());
1226 TypeImpl::GetCanonicalType() const
1229 if (CheckModule (module_sp))
1231 if (m_dynamic_type.IsValid())
1233 return TypeImpl(m_static_type, m_dynamic_type.GetCanonicalType());
1235 return TypeImpl(m_static_type.GetCanonicalType());
1241 TypeImpl::GetClangASTType (bool prefer_dynamic)
1244 if (CheckModule (module_sp))
1248 if (m_dynamic_type.IsValid())
1249 return m_dynamic_type;
1251 return m_static_type.GetClangASTType();
1253 return ClangASTType();
1257 TypeImpl::GetClangASTContext (bool prefer_dynamic)
1260 if (CheckModule (module_sp))
1264 if (m_dynamic_type.IsValid())
1265 return m_dynamic_type.GetASTContext();
1267 return m_static_type.GetClangASTContext();
1273 TypeImpl::GetDescription (lldb_private::Stream &strm,
1274 lldb::DescriptionLevel description_level)
1277 if (CheckModule (module_sp))
1279 if (m_dynamic_type.IsValid())
1281 strm.Printf("Dynamic:\n");
1282 m_dynamic_type.DumpTypeDescription(&strm);
1283 strm.Printf("\nStatic:\n");
1285 m_static_type.GetClangASTType().DumpTypeDescription(&strm);
1289 strm.PutCString("Invalid TypeImpl module for type has been deleted\n");
1294 TypeEnumMemberImpl::TypeEnumMemberImpl (const clang::EnumConstantDecl* enum_member_decl,
1295 const lldb_private::ClangASTType& integer_type) :
1296 m_integer_type_sp(),
1302 if (enum_member_decl)
1304 m_integer_type_sp.reset(new TypeImpl(integer_type));
1305 m_name = ConstString(enum_member_decl->getNameAsString().c_str());
1306 m_value = enum_member_decl->getInitVal();