Type.h revision 4b40711e7950310afb74835820eb669004cd8c44
1//===-- Type.h --------------------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef liblldb_Type_h_ 11#define liblldb_Type_h_ 12 13#include "lldb/lldb-private.h" 14#include "lldb/Core/ClangForward.h" 15#include "lldb/Core/UserID.h" 16#include "lldb/Symbol/Declaration.h" 17#include <set> 18 19namespace lldb_private { 20 21class Type : public UserID 22{ 23public: 24 typedef enum 25 { 26 eEncodingInvalid, 27 eEncodingIsUID, ///< This type is the type whose UID is m_encoding_uid 28 eEncodingIsConstUID, ///< This type is the type whose UID is m_encoding_uid with the const qualifier added 29 eEncodingIsRestrictUID, ///< This type is the type whose UID is m_encoding_uid with the restrict qualifier added 30 eEncodingIsVolatileUID, ///< This type is the type whose UID is m_encoding_uid with the volatile qualifier added 31 eEncodingIsTypedefUID, ///< This type is pointer to a type whose UID is m_encoding_uid 32 eEncodingIsPointerUID, ///< This type is pointer to a type whose UID is m_encoding_uid 33 eEncodingIsLValueReferenceUID, ///< This type is L value reference to a type whose UID is m_encoding_uid 34 eEncodingIsRValueReferenceUID, ///< This type is R value reference to a type whose UID is m_encoding_uid 35 eEncodingIsSyntheticUID, 36 eEncodingIsTypePtr ///< m_encoding_data is a "lldb_private::Type *" 37 } EncodingDataType; 38 39 Type (lldb::user_id_t uid, 40 SymbolFile* symbol_file, 41 const ConstString &name, 42 uint32_t byte_size, 43 SymbolContextScope *context, 44 uintptr_t encoding_uid, 45 EncodingDataType encoding_type, 46 const Declaration& decl, 47 lldb::clang_type_t clang_qual_type, 48 bool is_forward_decl); 49 50 // This makes an invalid type. Used for functions that return a Type when they 51 // get an error. 52 Type(); 53 54 const Type& 55 operator= (const Type& rhs); 56 57 void 58 Dump(Stream *s, bool show_context); 59 60 void 61 DumpTypeName(Stream *s); 62 63 64 void 65 GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_name); 66 67 SymbolFile * 68 GetSymbolFile() 69 { 70 return m_symbol_file; 71 } 72 const SymbolFile * 73 GetSymbolFile() const 74 { 75 return m_symbol_file; 76 } 77 78 TypeList* 79 GetTypeList(); 80 81 const ConstString& 82 GetName(); 83 84 uint64_t 85 GetByteSize(); 86 87 uint32_t 88 GetNumChildren (bool omit_empty_base_classes); 89 90 bool 91 IsAggregateType (); 92 93 bool 94 IsValidType () 95 { 96 return m_encoding_data_type != eEncodingInvalid; 97 } 98 99 void 100 SetByteSize(uint32_t byte_size); 101 102 const ConstString & 103 GetName () const 104 { 105 return m_name; 106 } 107 108 void 109 DumpValue(ExecutionContext *exe_ctx, 110 Stream *s, 111 const DataExtractor &data, 112 uint32_t data_offset, 113 bool show_type, 114 bool show_summary, 115 bool verbose, 116 lldb::Format format = lldb::eFormatDefault); 117 118 bool 119 DumpValueInMemory(ExecutionContext *exe_ctx, 120 Stream *s, 121 lldb::addr_t address, 122 lldb::AddressType address_type, 123 bool show_types, 124 bool show_summary, 125 bool verbose); 126 127 bool 128 ReadFromMemory (ExecutionContext *exe_ctx, 129 lldb::addr_t address, 130 lldb::AddressType address_type, 131 DataExtractor &data); 132 133 bool 134 WriteToMemory (ExecutionContext *exe_ctx, 135 lldb::addr_t address, 136 lldb::AddressType address_type, 137 DataExtractor &data); 138 139 bool 140 GetIsDeclaration() const; 141 142 void 143 SetIsDeclaration(bool b); 144 145 bool 146 GetIsExternal() const; 147 148 void 149 SetIsExternal(bool b); 150 151 lldb::Format 152 GetFormat (); 153 154 lldb::Encoding 155 GetEncoding (uint32_t &count); 156 157 SymbolContextScope * 158 GetSymbolContextScope() 159 { 160 return m_context; 161 } 162 const SymbolContextScope * 163 GetSymbolContextScope() const 164 { 165 return m_context; 166 } 167 void 168 SetSymbolContextScope(SymbolContextScope *context) 169 { 170 m_context = context; 171 } 172 173 const lldb_private::Declaration & 174 GetDeclaration () const; 175 176 lldb::clang_type_t 177 GetClangType (bool forward_decl_is_ok = false); 178 179 clang::ASTContext * 180 GetClangAST (); 181 182 ClangASTContext & 183 GetClangASTContext (); 184 185 lldb::clang_type_t 186 GetChildClangTypeAtIndex (const char *parent_name, 187 uint32_t idx, 188 bool transparent_pointers, 189 bool omit_empty_base_classes, 190 ConstString& name, 191 uint32_t &child_byte_size, 192 int32_t &child_byte_offset, 193 uint32_t &child_bitfield_bit_size, 194 uint32_t &child_bitfield_bit_offset); 195 196 static int 197 Compare(const Type &a, const Type &b); 198 199protected: 200 ConstString m_name; 201 SymbolFile *m_symbol_file; 202 SymbolContextScope *m_context; // The symbol context in which this type is defined 203 uint64_t m_byte_size; 204 EncodingDataType m_encoding_data_type; 205 uintptr_t m_encoding_data; 206 Declaration m_decl; 207 lldb::clang_type_t m_clang_qual_type; 208 bool m_is_forward_decl; 209 210 Type * 211 GetEncodingType () 212 { 213 if (m_encoding_data_type == eEncodingIsTypePtr) 214 return (Type *)m_encoding_data; 215 return NULL; 216 } 217 bool ResolveClangType(bool forward_decl_is_ok = false); 218}; 219 220} // namespace lldb_private 221 222#endif // liblldb_Type_h_ 223 224