diff options
39 files changed, 609 insertions, 394 deletions
diff --git a/lldb/include/lldb/Core/Value.h b/lldb/include/lldb/Core/Value.h index 87eb7272525..1961104ba9c 100644 --- a/lldb/include/lldb/Core/Value.h +++ b/lldb/include/lldb/Core/Value.h @@ -72,7 +72,7 @@ public: GetProxyTarget(); void * - GetOpaqueClangQualType(); + GetClangType(); ValueType GetValueType() const; diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 9c89710f960..fc61060d75e 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -45,7 +45,7 @@ public: GetClangAST () = 0; virtual void * - GetOpaqueClangQualType () = 0; + GetClangType () = 0; virtual lldb::ValueType GetValueType() const = 0; diff --git a/lldb/include/lldb/Core/ValueObjectChild.h b/lldb/include/lldb/Core/ValueObjectChild.h index c632c8eb78a..bfa9d962ab8 100644 --- a/lldb/include/lldb/Core/ValueObjectChild.h +++ b/lldb/include/lldb/Core/ValueObjectChild.h @@ -52,7 +52,7 @@ public: GetClangAST (); virtual void * - GetOpaqueClangQualType (); + GetClangType (); virtual lldb::ValueType GetValueType() const; diff --git a/lldb/include/lldb/Core/ValueObjectRegister.h b/lldb/include/lldb/Core/ValueObjectRegister.h index fe3ac480caa..98f538ce254 100644 --- a/lldb/include/lldb/Core/ValueObjectRegister.h +++ b/lldb/include/lldb/Core/ValueObjectRegister.h @@ -38,7 +38,7 @@ public: GetClangAST (); virtual void * - GetOpaqueClangQualType (); + GetClangType (); virtual lldb::ValueType GetValueType () const @@ -83,7 +83,7 @@ public: GetClangAST (); virtual void * - GetOpaqueClangQualType (); + GetClangType (); virtual lldb::ValueType GetValueType () const @@ -131,7 +131,7 @@ public: GetClangAST (); virtual void * - GetOpaqueClangQualType (); + GetClangType (); virtual lldb::ValueType GetValueType () const diff --git a/lldb/include/lldb/Core/ValueObjectVariable.h b/lldb/include/lldb/Core/ValueObjectVariable.h index f3d91dde39d..496f5c831dd 100644 --- a/lldb/include/lldb/Core/ValueObjectVariable.h +++ b/lldb/include/lldb/Core/ValueObjectVariable.h @@ -37,7 +37,7 @@ public: GetClangAST (); virtual void * - GetOpaqueClangQualType (); + GetClangType (); virtual ConstString GetTypeName(); diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 073b3329210..3aed5750345 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -77,61 +77,61 @@ public: // Basic Types //------------------------------------------------------------------ - void * + lldb::clang_type_t GetBuiltinTypeForEncodingAndBitSize (lldb::Encoding encoding, uint32_t bit_size); - static void * + static lldb::clang_type_t GetBuiltinTypeForEncodingAndBitSize (clang::ASTContext *ast_context, lldb::Encoding encoding, uint32_t bit_size); - void * + lldb::clang_type_t GetBuiltinTypeForDWARFEncodingAndBitSize ( const char *type_name, uint32_t dw_ate, uint32_t bit_size); - static void * + static lldb::clang_type_t GetBuiltInType_void(clang::ASTContext *ast_context); - void * + lldb::clang_type_t GetBuiltInType_void() { return GetBuiltInType_void(getASTContext()); } - void * + lldb::clang_type_t GetBuiltInType_objc_id(); - void * + lldb::clang_type_t GetBuiltInType_objc_Class(); - void * + lldb::clang_type_t GetBuiltInType_objc_selector(); - void * + lldb::clang_type_t GetCStringType(bool is_const); - void * + lldb::clang_type_t GetVoidPtrType(bool is_const); - static void * + static lldb::clang_type_t GetVoidPtrType(clang::ASTContext *ast_context, bool is_const); - static void * + static lldb::clang_type_t CopyType(clang::ASTContext *dest_context, clang::ASTContext *source_context, - void *clang_type); + lldb::clang_type_t clang_type); static bool AreTypesSame(clang::ASTContext *ast_context, - void *type1, - void *type2); + lldb::clang_type_t type1, + lldb::clang_type_t type2); bool - AreTypesSame(void *type1, - void *type2) + AreTypesSame(lldb::clang_type_t type1, + lldb::clang_type_t type2) { return ClangASTContext::AreTypesSame(getASTContext(), type1, type2); } @@ -140,20 +140,20 @@ public: // CVR modifiers //------------------------------------------------------------------ - static void * - AddConstModifier (void *clang_type); + static lldb::clang_type_t + AddConstModifier (lldb::clang_type_t clang_type); - static void * - AddRestrictModifier (void *clang_type); + static lldb::clang_type_t + AddRestrictModifier (lldb::clang_type_t clang_type); - static void * - AddVolatileModifier (void *clang_type); + static lldb::clang_type_t + AddVolatileModifier (lldb::clang_type_t clang_type); //------------------------------------------------------------------ // Structure, Unions, Classes //------------------------------------------------------------------ - void * + lldb::clang_type_t CreateRecordType (const char *name, int kind, clang::DeclContext *decl_ctx, @@ -161,16 +161,16 @@ public: static bool AddFieldToRecordType (clang::ASTContext *ast_context, - void *record_qual_type, + lldb::clang_type_t record_qual_type, const char *name, - void *field_type, + lldb::clang_type_t field_type, lldb::AccessType access, uint32_t bitfield_bit_size); bool - AddFieldToRecordType (void *record_qual_type, + AddFieldToRecordType (lldb::clang_type_t record_qual_type, const char *name, - void *field_type, + lldb::clang_type_t field_type, lldb::AccessType access, uint32_t bitfield_bit_size) { @@ -184,18 +184,18 @@ public: static clang::CXXMethodDecl * AddMethodToCXXRecordType (clang::ASTContext *ast_context, - void *record_opaque_type, + lldb::clang_type_t record_opaque_type, const char *name, - void *method_type, + lldb::clang_type_t method_type, lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline); clang::CXXMethodDecl * - AddMethodToCXXRecordType (void *record_opaque_type, + AddMethodToCXXRecordType (lldb::clang_type_t record_opaque_type, const char *name, - void *method_type, + lldb::clang_type_t method_type, lldb::AccessType access, bool is_virtual, bool is_static, @@ -225,12 +225,12 @@ public: RecordHasFields (const clang::RecordDecl *record_decl); void - SetDefaultAccessForRecordFields (void *clang_type, + SetDefaultAccessForRecordFields (lldb::clang_type_t clang_type, int default_accessibility, int *assigned_accessibilities, size_t num_assigned_accessibilities); - void * + lldb::clang_type_t CreateObjCClass (const char *name, clang::DeclContext *decl_ctx, bool isForwardDecl, @@ -238,17 +238,17 @@ public: static bool AddObjCClassIVar (clang::ASTContext *ast_context, - void *class_opaque_type, + lldb::clang_type_t class_opaque_type, const char *name, - void *ivar_opaque_type, + lldb::clang_type_t ivar_opaque_type, lldb::AccessType access, uint32_t bitfield_bit_size, bool isSynthesized); bool - AddObjCClassIVar (void *class_opaque_type, + AddObjCClassIVar (lldb::clang_type_t class_opaque_type, const char *name, - void *ivar_opaque_type, + lldb::clang_type_t ivar_opaque_type, lldb::AccessType access, uint32_t bitfield_bit_size, bool isSynthesized) @@ -263,11 +263,11 @@ public: } bool - SetObjCSuperClass (void *class_clang_type, - void *superclass_clang_type); + SetObjCSuperClass (lldb::clang_type_t class_clang_type, + lldb::clang_type_t superclass_clang_type); static bool - ObjCTypeHasIVars (void *class_clang_type, bool check_superclass); + ObjCTypeHasIVars (lldb::clang_type_t class_clang_type, bool check_superclass); static bool ObjCDeclHasIVars (clang::ObjCInterfaceDecl *class_interface_decl, @@ -276,15 +276,15 @@ public: static clang::ObjCMethodDecl * AddMethodToObjCObjectType (clang::ASTContext *ast_context, - void *class_opaque_type, + lldb::clang_type_t class_opaque_type, const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]") - void *method_opaque_type, + lldb::clang_type_t method_opaque_type, lldb::AccessType access); clang::ObjCMethodDecl * - AddMethodToObjCObjectType (void *class_opaque_type, + AddMethodToObjCObjectType (lldb::clang_type_t class_opaque_type, const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]") - void *method_opaque_type, + lldb::clang_type_t method_opaque_type, lldb::AccessType access) { return AddMethodToObjCObjectType (getASTContext(), @@ -299,15 +299,15 @@ public: // Aggregate Types //------------------------------------------------------------------ static bool - IsAggregateType (void *clang_type); + IsAggregateType (lldb::clang_type_t clang_type); static uint32_t - GetNumChildren (void *clang_type, + GetNumChildren (lldb::clang_type_t clang_type, bool omit_empty_base_classes); - void * + lldb::clang_type_t GetChildClangTypeAtIndex (const char *parent_name, - void * parent_clang_type, + lldb::clang_type_t parent_clang_type, uint32_t idx, bool transparent_pointers, bool omit_empty_base_classes, @@ -317,10 +317,10 @@ public: uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset); - static void * + static lldb::clang_type_t GetChildClangTypeAtIndex (clang::ASTContext *ast_context, const char *parent_name, - void * parent_clang_type, + lldb::clang_type_t parent_clang_type, uint32_t idx, bool transparent_pointers, bool omit_empty_base_classes, @@ -334,7 +334,7 @@ public: // and member member names in "clang_type" only, not descendants. static uint32_t GetIndexOfChildWithName (clang::ASTContext *ast_context, - void *clang_type, + lldb::clang_type_t clang_type, const char *name, bool omit_empty_base_classes); @@ -345,7 +345,7 @@ public: // so we catch all names that match a given child name, not just the first. static size_t GetIndexOfChildMemberWithName (clang::ASTContext *ast_context, - void *clang_type, + lldb::clang_type_t clang_type, const char *name, bool omit_empty_base_classes, std::vector<uint32_t>& child_indexes); @@ -355,7 +355,7 @@ public: //------------------------------------------------------------------ bool - SetTagTypeKind (void * tag_qual_type, + SetTagTypeKind (lldb::clang_type_t tag_qual_type, int kind); //------------------------------------------------------------------ @@ -363,7 +363,7 @@ public: //------------------------------------------------------------------ clang::CXXBaseSpecifier * - CreateBaseClassSpecifier (void * base_class_type, + CreateBaseClassSpecifier (lldb::clang_type_t base_class_type, lldb::AccessType access, bool is_virtual, bool base_of_class); @@ -373,7 +373,7 @@ public: unsigned num_base_classes); bool - SetBaseClassesForClassType (void * class_clang_type, + SetBaseClassesForClassType (lldb::clang_type_t class_clang_type, clang::CXXBaseSpecifier const * const *base_classes, unsigned num_base_classes); @@ -382,7 +382,7 @@ public: //------------------------------------------------------------------ static clang::DeclContext * - GetDeclContextForType (void * qual_type); + GetDeclContextForType (lldb::clang_type_t qual_type); //------------------------------------------------------------------ // Namespace Declarations @@ -399,21 +399,21 @@ public: clang::FunctionDecl * CreateFunctionDeclaration (const char *name, - void * function_Type, + lldb::clang_type_t function_Type, int storage, bool is_inline); - static void * + static lldb::clang_type_t CreateFunctionType (clang::ASTContext *ast_context, - void *result_type, - void **args, + lldb::clang_type_t result_type, + lldb::clang_type_t *args, unsigned num_args, bool is_variadic, unsigned type_quals); - void * - CreateFunctionType (void *result_type, - void **args, + lldb::clang_type_t + CreateFunctionType (lldb::clang_type_t result_type, + lldb::clang_type_t *args, unsigned num_args, bool is_variadic, unsigned type_quals) @@ -428,7 +428,7 @@ public: clang::ParmVarDecl * CreateParameterDeclaration (const char *name, - void *param_type, + lldb::clang_type_t param_type, int storage); void @@ -440,8 +440,8 @@ public: // Array Types //------------------------------------------------------------------ - void * - CreateArrayType (void * element_type, + lldb::clang_type_t + CreateArrayType (lldb::clang_type_t element_type, size_t element_count, uint32_t bit_stride); @@ -449,20 +449,23 @@ public: // Tag Declarations //------------------------------------------------------------------ bool - StartTagDeclarationDefinition (void * qual_type); + StartTagDeclarationDefinition (lldb::clang_type_t qual_type); bool - CompleteTagDeclarationDefinition (void * qual_type); + CompleteTagDeclarationDefinition (lldb::clang_type_t qual_type); //------------------------------------------------------------------ // Enumeration Types //------------------------------------------------------------------ - void * - CreateEnumerationType (const Declaration &decl, const char *name, void *integer_qual_type); + lldb::clang_type_t + CreateEnumerationType (const Declaration &decl, const char *name, lldb::clang_type_t integer_qual_type); + static lldb::clang_type_t + GetEnumerationIntegerType (lldb::clang_type_t enum_clang_type); + bool - AddEnumerationValueToEnumerationType (void * enum_qual_type, - void * enumerator_qual_type, + AddEnumerationValueToEnumerationType (lldb::clang_type_t enum_qual_type, + lldb::clang_type_t enumerator_qual_type, const Declaration &decl, const char *name, int64_t enum_value, @@ -471,66 +474,66 @@ public: //------------------------------------------------------------------ // Pointers & References //------------------------------------------------------------------ - void * - CreatePointerType (void *clang_type); + lldb::clang_type_t + CreatePointerType (lldb::clang_type_t clang_type); - void * - CreateLValueReferenceType (void *clang_type); + lldb::clang_type_t + CreateLValueReferenceType (lldb::clang_type_t clang_type); - void * - CreateRValueReferenceType (void *clang_type); + lldb::clang_type_t + CreateRValueReferenceType (lldb::clang_type_t clang_type); - void * - CreateMemberPointerType (void * clang_pointee_type, - void * clang_class_type); + lldb::clang_type_t + CreateMemberPointerType (lldb::clang_type_t clang_pointee_type, + lldb::clang_type_t clang_class_type); size_t GetPointerBitSize (); static bool - IsIntegerType (void *clang_type, bool &is_signed); + IsIntegerType (lldb::clang_type_t clang_type, bool &is_signed); static bool - IsPointerType (void *clang_type, void **target_type = NULL); + IsPointerType (lldb::clang_type_t clang_type, lldb::clang_type_t *target_type = NULL); static bool - IsPointerOrReferenceType (void *clang_type, void **target_type = NULL); + IsPointerOrReferenceType (lldb::clang_type_t clang_type, lldb::clang_type_t *target_type = NULL); static bool - IsCStringType (void *clang_type, uint32_t &length); + IsCStringType (lldb::clang_type_t clang_type, uint32_t &length); static bool - IsFunctionPointerType (void *clang_type); + IsFunctionPointerType (lldb::clang_type_t clang_type); static bool - IsArrayType (void *clang_type, void **member_type = NULL, uint64_t *size = NULL); + IsArrayType (lldb::clang_type_t clang_type, lldb::clang_type_t *member_type = NULL, uint64_t *size = NULL); //------------------------------------------------------------------ // Typedefs //------------------------------------------------------------------ - void * + lldb::clang_type_t CreateTypedefType (const char *name, - void *clang_type, + lldb::clang_type_t clang_type, clang::DeclContext *decl_ctx); //------------------------------------------------------------------ // Type names //------------------------------------------------------------------ static std::string - GetTypeName(void *clang_type); + GetTypeName(lldb::clang_type_t clang_type); static bool - IsFloatingPointType (void *clang_type, uint32_t &count, bool &is_complex); + IsFloatingPointType (lldb::clang_type_t clang_type, uint32_t &count, bool &is_complex); static bool - IsCXXClassType (void *clang_type); + IsCXXClassType (lldb::clang_type_t clang_type); static bool - IsObjCClassType (void *clang_type); + IsObjCClassType (lldb::clang_type_t clang_type); //static bool //ConvertFloatValueToString (clang::ASTContext *ast_context, - // void *clang_type, + // lldb::clang_type_t clang_type, // const uint8_t* bytes, // size_t byte_size, // int apint_byte_order, @@ -538,7 +541,7 @@ public: static size_t ConvertStringToFloatValue (clang::ASTContext *ast_context, - void *clang_type, + lldb::clang_type_t clang_type, const char *s, uint8_t *dst, size_t dst_size); @@ -547,7 +550,7 @@ public: // Qualifiers //------------------------------------------------------------------ static unsigned - GetTypeQualifiers(void *clang_type); + GetTypeQualifiers(lldb::clang_type_t clang_type); protected: //------------------------------------------------------------------ // Classes that inherit from ClangASTContext can see and modify these diff --git a/lldb/include/lldb/Symbol/ClangASTType.h b/lldb/include/lldb/Symbol/ClangASTType.h index 0e92edfb3a6..8f8dcdd3c20 100644 --- a/lldb/include/lldb/Symbol/ClangASTType.h +++ b/lldb/include/lldb/Symbol/ClangASTType.h @@ -189,6 +189,13 @@ public: size_t data_byte_size, Scalar &value); + + bool + IsDefined(); + + static bool + IsDefined (void *opaque_clang_qual_type); + bool SetValueFromScalar (const Scalar &value, Stream &strm); diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index da91e1c8801..d0007234f94 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -70,6 +70,7 @@ public: virtual size_t ParseTypes (const SymbolContext& sc) = 0; virtual size_t ParseVariablesForContext (const SymbolContext& sc) = 0; virtual Type* ResolveTypeUID (lldb::user_id_t type_uid) = 0; + virtual lldb::clang_type_t ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type) = 0; virtual clang::DeclContext* GetClangDeclContextForTypeUID (lldb::user_id_t type_uid) { return NULL; } virtual uint32_t ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) = 0; virtual uint32_t ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) = 0; diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h index 762e7c41537..80e156c6a06 100644 --- a/lldb/include/lldb/Symbol/Type.h +++ b/lldb/include/lldb/Symbol/Type.h @@ -35,16 +35,16 @@ public: eTypeUIDSynthetic } EncodingUIDType; - Type(lldb::user_id_t uid, - SymbolFile* symbol_file, - const ConstString &name, - uint64_t byte_size, - SymbolContextScope *context, - lldb::user_id_t encoding_uid, - EncodingUIDType encoding_type, - const Declaration& decl, - void *clang_qual_type); - + Type (lldb::user_id_t uid, + SymbolFile* symbol_file, + const ConstString &name, + uint64_t byte_size, + SymbolContextScope *context, + lldb::user_id_t encoding_uid, + EncodingUIDType encoding_type, + const Declaration& decl, + lldb::clang_type_t clang_qual_type); + // This makes an invalid type. Used for functions that return a Type when they // get an error. Type(); @@ -171,8 +171,8 @@ public: const lldb_private::Declaration & GetDeclaration () const; - void * - GetOpaqueClangQualType (); + lldb::clang_type_t + GetClangType (bool forward_decl_is_ok = false); clang::ASTContext * GetClangAST (); @@ -180,7 +180,7 @@ public: ClangASTContext & GetClangASTContext (); - void * + lldb::clang_type_t GetChildClangTypeAtIndex (const char *parent_name, uint32_t idx, bool transparent_pointers, @@ -202,9 +202,9 @@ protected: lldb::user_id_t m_encoding_uid; EncodingUIDType m_encoding_uid_type; Declaration m_decl; - void *m_clang_qual_type; + lldb::clang_type_t m_clang_qual_type; - bool ResolveClangType(); + bool ResolveClangType(bool forward_decl_is_ok = false); }; } // namespace lldb_private diff --git a/lldb/include/lldb/Symbol/TypeList.h b/lldb/include/lldb/Symbol/TypeList.h index 9a488dbc8bf..b9dc24d9800 100644 --- a/lldb/include/lldb/Symbol/TypeList.h +++ b/lldb/include/lldb/Symbol/TypeList.h @@ -56,27 +56,18 @@ public: GetClangASTContext (); void * - CreateClangPointerType (Type *type); + CreateClangPointerType (Type *type, bool forward_decl_is_ok); void * - CreateClangTypedefType (Type *typedef_type, Type *base_type); + CreateClangTypedefType (Type *typedef_type, Type *base_type, bool forward_decl_is_ok); // For C++98 references (&) void * - CreateClangLValueReferenceType (Type *type); + CreateClangLValueReferenceType (Type *type, bool forward_decl_is_ok); // For C++0x references (&&) void * - CreateClangRValueReferenceType (Type *type); - - void * - GetConstClangType (Type *type); - - void * - GetRestrictClangType (Type *type); - - void * - GetVolatileClangType (Type *type); + CreateClangRValueReferenceType (Type *type, bool forward_decl_is_ok); private: typedef std::vector<lldb::TypeSP> collection; diff --git a/lldb/include/lldb/lldb-types.h b/lldb/include/lldb/lldb-types.h index 492a5f8f779..d838c4f2ecd 100644 --- a/lldb/include/lldb/lldb-types.h +++ b/lldb/include/lldb/lldb-types.h @@ -93,6 +93,7 @@ namespace lldb { typedef int32_t pid_t; typedef uint32_t tid_t; typedef int32_t break_id_t; + typedef void * clang_type_t; //---------------------------------------------------------------------- // Every register is described in detail including its name, alternate diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 9ad57b1b26f..1b2fa64627b 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -2431,6 +2431,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 4b437f4e1b5..6f63f53d745 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -241,7 +241,7 @@ void * SBValue::GetOpaqueType() { if (m_opaque_sp) - return m_opaque_sp->GetOpaqueClangQualType(); + return m_opaque_sp->GetClangType(); return NULL; } diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 5250ab5e51b..26c2aced8f5 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -360,7 +360,7 @@ public: { const char *sum_cstr = valobj->GetSummaryAsCString(exe_scope); - const bool is_aggregate = ClangASTContext::IsAggregateType (valobj->GetOpaqueClangQualType()); + const bool is_aggregate = ClangASTContext::IsAggregateType (valobj->GetClangType()); if (val_cstr) s.PutCString(val_cstr); @@ -384,7 +384,7 @@ public: if (is_aggregate) s.PutChar('{'); - bool is_ptr_or_ref = ClangASTContext::IsPointerOrReferenceType (valobj->GetOpaqueClangQualType()); + bool is_ptr_or_ref = ClangASTContext::IsPointerOrReferenceType (valobj->GetClangType()); if (is_ptr_or_ref && ptr_depth == 0) return; diff --git a/lldb/source/Commands/CommandObjectImage.cpp b/lldb/source/Commands/CommandObjectImage.cpp index 8c17221b9a7..30e9195e9fd 100644 --- a/lldb/source/Commands/CommandObjectImage.cpp +++ b/lldb/source/Commands/CommandObjectImage.cpp @@ -429,7 +429,7 @@ LookupTypeInModule { // Resolve the clang type so that any forward references // to types that haven't yet been parsed will get parsed. - type_sp->GetOpaqueClangQualType (); + type_sp->GetClangType (); type_sp->GetDescription (&strm, eDescriptionLevelFull, true); } strm.EOL(); diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp index 8ccb67c620e..de6500ef938 100644 --- a/lldb/source/Core/Value.cpp +++ b/lldb/source/Core/Value.cpp @@ -417,10 +417,10 @@ Value::GetValueByteSize (clang::ASTContext *ast_context, Error *error_ptr) } void * -Value::GetOpaqueClangQualType () +Value::GetClangType () { if (m_context_type == eContextTypeValue) - return ((Value*)m_context)->GetOpaqueClangQualType(); + return ((Value*)m_context)->GetClangType(); switch (m_context_type) { @@ -436,12 +436,12 @@ Value::GetOpaqueClangQualType () case eContextTypeDCType: if (GetType()) - return GetType()->GetOpaqueClangQualType(); + return GetType()->GetClangType(); break; case eContextTypeDCVariable: if (GetVariable()) - return GetVariable()->GetType()->GetOpaqueClangQualType(); + return GetVariable()->GetType()->GetClangType(); break; } @@ -669,7 +669,7 @@ Value::ResolveValue(ExecutionContext *exe_ctx, clang::ASTContext *ast_context) if (m_context_type == eContextTypeOpaqueClangQualType) { - void *opaque_clang_qual_type = GetOpaqueClangQualType(); + void *opaque_clang_qual_type = GetClangType(); switch (m_value_type) { case eValueTypeScalar: // raw scalar value diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index e98e552cd96..ae53a838af5 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -263,7 +263,7 @@ ValueObject::GetIndexOfChildWithName (const ConstString &name) { bool omit_empty_base_classes = true; return ClangASTContext::GetIndexOfChildWithName (GetClangAST(), - GetOpaqueClangQualType(), + GetClangType(), name.AsCString(), omit_empty_base_classes); } @@ -276,7 +276,7 @@ ValueObject::GetChildMemberWithName (const ConstString &name, bool can_create) // need a vector of indexes that can get us down to the correct child std::vector<uint32_t> child_indexes; clang::ASTContext *clang_ast = GetClangAST(); - void *clang_type = GetOpaqueClangQualType(); + void *clang_type = GetClangType(); bool omit_empty_base_classes = true; const size_t num_child_indexes = ClangASTContext::GetIndexOfChildMemberWithName (clang_ast, clang_type, @@ -349,7 +349,7 @@ ValueObject::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int3 uint32_t child_bitfield_bit_offset = 0; const bool transparent_pointers = synthetic_array_member == false; clang::ASTContext *clang_ast = GetClangAST(); - void *clang_type = GetOpaqueClangQualType(); + void *clang_type = GetClangType(); void *child_clang_type; child_clang_type = ClangASTContext::GetChildClangTypeAtIndex (clang_ast, GetName().AsCString(), @@ -390,7 +390,7 @@ ValueObject::GetSummaryAsCString (ExecutionContextScope *exe_scope) { if (m_summary_str.empty()) { - void *clang_type = GetOpaqueClangQualType(); + void *clang_type = GetClangType(); // See if this is a pointer to a C string? uint32_t fixed_length = 0; @@ -561,7 +561,7 @@ const char * ValueObject::GetValueAsCString (ExecutionContextScope *exe_scope) { // If our byte size is zero this is an aggregate type that has children - if (ClangASTContext::IsAggregateType (GetOpaqueClangQualType()) == false) + if (ClangASTContext::IsAggregateType (GetClangType()) == false) { if (UpdateValueIfNeeded(exe_scope)) { @@ -575,7 +575,7 @@ ValueObject::GetValueAsCString (ExecutionContextScope *exe_scope) case Value::eContextTypeDCType: case Value::eContextTypeDCVariable: { - void *clang_type = GetOpaqueClangQualType (); + void *clang_type = GetClangType (); if (clang_type) { StreamString sstr; @@ -665,7 +665,7 @@ ValueObject::SetValueFromCString (ExecutionContextScope *exe_scope, const char * return false; uint32_t count = 0; - lldb::Encoding encoding = ClangASTType::GetEncoding (GetOpaqueClangQualType(), count); + lldb::Encoding encoding = ClangASTType::GetEncoding (GetClangType(), count); char *end = NULL; const size_t byte_size = GetByteSize(); @@ -717,7 +717,7 @@ ValueObject::SetValueFromCString (ExecutionContextScope *exe_scope, const char * m_data.SetByteOrder(eByteOrderHost); const size_t converted_byte_size = ClangASTContext::ConvertStringToFloatValue ( GetClangAST(), - GetOpaqueClangQualType(), + GetClangType(), value_str, dst, byte_size); @@ -756,7 +756,7 @@ ValueObject::Write () lldb::LanguageType ValueObject::GetObjectRuntimeLanguage () { - void *opaque_qual_type = GetOpaqueClangQualType(); + void *opaque_qual_type = GetClangType(); if (opaque_qual_type == NULL) return lldb::eLanguageTypeC; @@ -805,13 +805,13 @@ ValueObject::GetSyntheticChild (const ConstString &key) const bool ValueObject::IsPointerType () { - return ClangASTContext::IsPointerType (GetOpaqueClangQualType()); + return ClangASTContext::IsPointerType (GetClangType()); } bool ValueObject::IsPointerOrReferenceType () { - return ClangASTContext::IsPointerOrReferenceType(GetOpaqueClangQualType()); + return ClangASTContext::IsPointerOrReferenceType(GetClangType()); } ValueObjectSP diff --git a/lldb/source/Core/ValueObjectChild.cpp b/lldb/source/Core/ValueObjectChild.cpp index 73af56c07d2..03986822f51 100644 --- a/lldb/source/Core/ValueObjectChild.cpp +++ b/lldb/source/Core/ValueObjectChild.cpp @@ -52,7 +52,7 @@ ValueObjectChild::~ValueObjectChild() } void * -ValueObjectChild::GetOpaqueClangQualType() +ValueObjectChild::GetClangType() { return m_clang_type; } @@ -104,7 +104,7 @@ ValueObjectChild::GetTypeName() { if (m_type_name.IsEmpty()) { - m_type_name = ClangASTType::GetClangTypeName (GetOpaqueClangQualType()); + m_type_name = ClangASTType::GetClangTypeName (GetClangType()); if (m_type_name) { if (m_bitfield_bit_size > 0) @@ -139,13 +139,13 @@ ValueObjectChild::UpdateValue (ExecutionContextScope *exe_scope) Value::ValueType value_type = parent->GetValue().GetValueType(); m_value.SetValueType (value_type); - if (ClangASTContext::IsPointerOrReferenceType (parent->GetOpaqueClangQualType())) + if (ClangASTContext::IsPointerOrReferenceType (parent->GetClangType())) { uint32_t offset = 0; m_value.GetScalar() = parent->GetDataExtractor().GetPointer(&offset); // For pointers, m_byte_offset should only ever be set if we // ValueObject::GetSyntheticArrayMemberFromPointer() was called - if (ClangASTContext::IsPointerType (parent->GetOpaqueClangQualType()) && m_byte_offset) + if (ClangASTContext::IsPointerType (parent->GetClangType()) && m_byte_offset) m_value.GetScalar() += m_byte_offset; if (value_type == Value::eValueTypeScalar || value_type == Value::eValueTypeFileAddress) diff --git a/lldb/source/Core/ValueObjectRegister.cpp b/lldb/source/Core/ValueObjectRegister.cpp index 5d5215fe83d..ff3dac8d561 100644 --- a/lldb/source/Core/ValueObjectRegister.cpp +++ b/lldb/source/Core/ValueObjectRegister.cpp @@ -43,7 +43,7 @@ ValueObjectRegisterContext::~ValueObjectRegisterContext() } void * -ValueObjectRegisterContext::GetOpaqueClangQualType () +ValueObjectRegisterContext::GetClangType () { return NULL; } @@ -120,7 +120,7 @@ ValueObjectRegisterSet::~ValueObjectRegisterSet() } void * -ValueObjectRegisterSet::GetOpaqueClangQualType () +ValueObjectRegisterSet::GetClangType () { return NULL; } @@ -228,7 +228,7 @@ ValueObjectRegister::~ValueObjectRegister() } void * -ValueObjectRegister::GetOpaqueClangQualType () +ValueObjectRegister::GetClangType () { if (m_clang_type == NULL && m_reg_info) { @@ -251,7 +251,7 @@ ConstString ValueObjectRegister::GetTypeName() { if (m_type_name.IsEmpty()) - m_type_name = ClangASTType::GetClangTypeName (GetOpaqueClangQualType()); + m_type_name = ClangASTType::GetClangTypeName (GetClangType()); return m_type_name; } diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp index cf465fb945f..759b5ce34e3 100644 --- a/lldb/source/Core/ValueObjectVariable.cpp +++ b/lldb/source/Core/ValueObjectVariable.cpp @@ -46,11 +46,11 @@ ValueObjectVariable::~ValueObjectVariable() } void * -ValueObjectVariable::GetOpaqueClangQualType () +ValueObjectVariable::GetClangType () { Type *var_type = m_variable_sp->GetType(); if (var_type) - return var_type->GetOpaqueClangQualType(); + return var_type->GetClangType(); return NULL; } @@ -172,7 +172,7 @@ ValueObjectVariable::UpdateValue (ExecutionContextScope *exe_scope) } } - if (ClangASTContext::IsAggregateType (GetOpaqueClangQualType())) + if (ClangASTContext::IsAggregateType (GetClangType())) { // this value object represents an aggregate type whose // children have values, but this object does not. So we diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index d1d576f1442..43c4150a0f9 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -709,7 +709,7 @@ ClangExpressionDeclMap::FindVariableInScope(StackFrame &frame, if (type->GetASTContext() == var->GetType()->GetClangAST()) { - if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var->GetType()->GetOpaqueClangQualType())) + if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var->GetType()->GetClangType())) return NULL; } else @@ -759,7 +759,7 @@ ClangExpressionDeclMap::GetDecls(NameSearchContext &context, if (!this_type) return; - TypeFromUser this_user_type(this_type->GetOpaqueClangQualType(), + TypeFromUser this_user_type(this_type->GetClangType(), this_type->GetClangAST()); m_object_pointer_type = this_user_type; @@ -836,7 +836,7 @@ ClangExpressionDeclMap::GetDecls(NameSearchContext &context, if (type.get()) { - TypeFromUser user_type(type->GetOpaqueClangQualType(), + TypeFromUser user_type(type->GetClangType(), type->GetClangAST()); AddOneType(context, user_type, false); @@ -866,7 +866,7 @@ ClangExpressionDeclMap::GetVariableValue(ExecutionContext &exe_ctx, return NULL; } - void *var_opaque_type = var_type->GetOpaqueClangQualType(); + void *var_opaque_type = var_type->GetClangType(); if (!var_opaque_type) { @@ -1043,7 +1043,7 @@ ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context, return; } - fun_opaque_type = fun_type->GetOpaqueClangQualType(); + fun_opaque_type = fun_type->GetClangType(); if (!fun_opaque_type) { diff --git a/lldb/source/Expression/ClangExpressionVariable.cpp b/lldb/source/Expression/ClangExpressionVariable.cpp index 88e78dae116..37fc6c2354b 100644 --- a/lldb/source/Expression/ClangExpressionVariable.cpp +++ b/lldb/source/Expression/ClangExpressionVariable.cpp @@ -97,7 +97,7 @@ ClangExpressionVariable::Print (Stream &output_stream, if (format == lldb::eFormatDefault) format = val.GetValueDefaultFormat (); - void *clang_type = val.GetOpaqueClangQualType (); + void *clang_type = val.GetClangType (); output_stream.Printf("%s = ", m_name.c_str()); diff --git a/lldb/source/Expression/ClangFunction.cpp b/lldb/source/Expression/ClangFunction.cpp index 4035479cc82..aaff16dbb6f 100644 --- a/lldb/source/Expression/ClangFunction.cpp +++ b/lldb/source/Expression/ClangFunction.cpp @@ -83,7 +83,7 @@ ClangFunction::ClangFunction(const char *target_triple, m_JITted (false) { m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress(); - m_function_return_qual_type = m_function_ptr->GetReturnType().GetOpaqueClangQualType(); + m_function_return_qual_type = m_function_ptr->GetReturnType().GetClangType(); } //---------------------------------------------------------------------- @@ -153,7 +153,7 @@ ClangFunction::CompileFunction (Stream &errors) else { Value *arg_value = m_arg_values.GetValueAtIndex(i); - void *clang_qual_type = arg_value->GetOpaqueClangQualType (); + void *clang_qual_type = arg_value->GetClangType (); if (clang_qual_type != NULL) { type_stdstr = ClangASTContext::GetTypeName(clang_qual_type); @@ -322,7 +322,7 @@ ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx, if (arg_value->GetValueType() == Value::eValueTypeHostAddress && arg_value->GetContextType() == Value::eContextTypeOpaqueClangQualType && - ClangASTContext::IsPointerType(arg_value->GetOpaqueClangQualType())) + ClangASTContext::IsPointerType(arg_value->GetClangType())) continue; const Scalar &arg_scalar = arg_value->ResolveValue(&exe_ctx, m_clang_ast_context->getASTContext()); diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index a29994ef4b0..eef35a1df31 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -2136,7 +2136,7 @@ DWARFExpression::Evaluate return false; } - void *array_type = array_val.GetOpaqueClangQualType(); + void *array_type = array_val.GetClangType(); void *member_type; uint64_t size = 0; @@ -2214,7 +2214,7 @@ DWARFExpression::Evaluate { case Value::eContextTypeOpaqueClangQualType: { - void *clang_type = stack.back().GetOpaqueClangQualType(); + void *clang_type = stack.back().GetClangType(); if (ClangASTContext::IsAggregateType (clang_type)) { @@ -2434,7 +2434,7 @@ DWARFExpression::Evaluate return false; } - void *ptr_type = tmp.GetOpaqueClangQualType(); + void *ptr_type = tmp.GetClangType(); void *target_type; if (!ClangASTContext::IsPointerType(ptr_type, &target_type)) @@ -2483,7 +2483,7 @@ DWARFExpression::Evaluate Value *proxy = expr_local_variable->CreateProxy(); stack.push_back(*proxy); delete proxy; - //stack.back().SetContext (Value::eContextTypeOpaqueClangQualType, expr_local_variable->GetOpaqueClangQualType()); + //stack.back().SetContext (Value::eContextTypeOpaqueClangQualType, expr_local_variable->GetClangType()); */ } break; diff --git a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp index 2fe0b7859bb..21adec86c60 100644 --- a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp @@ -236,7 +236,7 @@ ABIMacOSX_i386::PrepareNormalCall (Thread &thread, return false; case Value::eContextTypeOpaqueClangQualType: { - void *val_type = val->GetOpaqueClangQualType(); + void *val_type = val->GetClangType(); uint32_t cstr_length; if (ClangASTContext::IsCStringType (val_type, cstr_length)) @@ -435,7 +435,7 @@ ABIMacOSX_i386::GetArgumentValues (Thread &thread, return false; case Value::eContextTypeOpaqueClangQualType: { - void *value_type = value->GetOpaqueClangQualType(); + void *value_type = value->GetClangType(); bool is_signed; if (ClangASTContext::IsIntegerType (value_type, is_signed)) @@ -484,7 +484,7 @@ ABIMacOSX_i386::GetReturnValue (Thread &thread, RegisterContext *reg_ctx = thread.GetRegisterContext(); - void *value_type = value.GetOpaqueClangQualType(); + void *value_type = value.GetClangType(); bool is_signed; if (ClangASTContext::IsIntegerType (value_type, is_signed)) diff --git a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp index ba662e22233..ba7f06c1133 100644 --- a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -266,7 +266,7 @@ ABISysV_x86_64::GetArgumentValues (Thread &thread, return false; case Value::eContextTypeOpaqueClangQualType: { - void *value_type = value->GetOpaqueClangQualType(); + void *value_type = value->GetClangType(); bool is_signed; if (ClangASTContext::IsIntegerType (value_type, is_signed)) @@ -309,7 +309,7 @@ ABISysV_x86_64::GetReturnValue (Thread &thread, return false; case Value::eContextTypeOpaqueClangQualType: { - void *value_type = value.GetOpaqueClangQualType(); + void *value_type = value.GetClangType(); bool is_signed; RegisterContext *reg_ctx = thread.GetRegisterContext(); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp index 7ba7a9b6e1a..346dc5411ca 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp @@ -51,7 +51,7 @@ AppleObjCRuntimeV2::GetObjectDescription (Stream &str, ValueObject &object, Exec assert (m_process == exe_ctx.process); // ObjC objects can only be pointers: - if (!ClangASTContext::IsPointerType (object.GetOpaqueClangQualType())) + if (!ClangASTContext::IsPointerType (object.GetClangType())) return NULL; // Get the function address for the print function. @@ -63,7 +63,7 @@ AppleObjCRuntimeV2::GetObjectDescription (Stream &str, ValueObject &object, Exec Scalar scalar; if (!ClangASTType::GetValueAsScalar (object.GetClangAST(), - object.GetOpaqueClangQualType(), + object.GetClangType(), object.GetDataExtractor(), 0, object.GetByteSize(), diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 79861d6d195..31e313da637 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1007,10 +1007,9 @@ size_t SymbolFileDWARF::ParseChildMembers ( const SymbolContext& sc, - TypeSP& type_sp, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die, - void *class_clang_type, + clang_type_t class_clang_type, const LanguageType class_language, std::vector<clang::CXXBaseSpecifier *>& base_classes, std::vector<int>& member_accessibilities, @@ -1098,7 +1097,7 @@ SymbolFileDWARF::ParseChildMembers accessibility = default_accessibility; member_accessibilities.push_back(accessibility); - type_list->GetClangASTContext().AddFieldToRecordType (type_sp->GetOpaqueClangQualType(), name, member_type->GetOpaqueClangQualType(), accessibility, bit_size); + type_list->GetClangASTContext().AddFieldToRecordType (class_clang_type, name, member_type->GetClangType(), accessibility, bit_size); } } break; @@ -1170,11 +1169,11 @@ SymbolFileDWARF::ParseChildMembers if (class_language == eLanguageTypeObjC) { - type_list->GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_dctype->GetOpaqueClangQualType()); + type_list->GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_dctype->GetClangType()); } else { - base_classes.push_back (type_list->GetClangASTContext().CreateBaseClassSpecifier (base_class_dctype->GetOpaqueClangQualType(), accessibility, is_virtual, is_base_of_class)); + base_classes.push_back (type_list->GetClangASTContext().CreateBaseClassSpecifier (base_class_dctype->GetClangType(), accessibility, is_virtual, is_base_of_class)); assert(base_classes.back()); } } @@ -1217,6 +1216,124 @@ SymbolFileDWARF::ResolveTypeUID (lldb::user_id_t type_uid) return NULL; } +lldb::clang_type_t +SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type) +{ + // We have a struct/union/class/enum that needs to be fully resolved. + const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (clang_type); + assert (die); + if (die == NULL) + return NULL; + + DWARFCompileUnit *cu = DebugInfo()->GetCompileUnitContainingDIE (die->GetOffset()).get(); + Type *type = m_die_to_type.lookup (die); + + const dw_tag_t tag = die->Tag(); + + assert (clang_type); + DWARFDebugInfoEntry::Attributes attributes; + + TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); + + switch (tag) + { + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_class_type: + type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); + if (die->HasChildren()) + { + LanguageType class_language = eLanguageTypeUnknown; + if (ClangASTContext::IsObjCClassType (clang_type)) + class_language = eLanguageTypeObjC; + + int tag_decl_kind = -1; + AccessType default_accessibility = eAccessNone; + if (tag == DW_TAG_structure_type) + { + tag_decl_kind = clang::TTK_Struct; + default_accessibility = eAccessPublic; + } + else if (tag == DW_TAG_union_type) + { + tag_decl_kind = clang::TTK_Union; + default_accessibility = eAccessPublic; + } + else if (tag == DW_TAG_class_type) + { + tag_decl_kind = clang::TTK_Class; + default_accessibility = eAccessPrivate; + } + + SymbolContext sc(GetCompUnitForDWARFCompUnit(cu)); + std::vector<clang::CXXBaseSpecifier *> base_classes; + std::vector<int> member_accessibilities; + bool is_a_class = false; + ParseChildMembers (sc, + cu, + die, + clang_type, + class_language, + base_classes, + member_accessibilities, + default_accessibility, + is_a_class); + + // If we have a DW_TAG_structure_type instead of a DW_TAG_class_type we + // need to tell the clang type it is actually a class. + if (class_language != eLanguageTypeObjC) + { + if (is_a_class && tag_decl_kind != clang::TTK_Class) + type_list->GetClangASTContext().SetTagTypeKind (clang_type, clang::TTK_Class); + } + + // Since DW_TAG_structure_type gets used for both classes + // and structures, we may need to set any DW_TAG_member + // fields to have a "private" access if none was specified. + // When we parsed the child members we tracked that actual + // accessibility value for each DW_TAG_member in the + // "member_accessibilities" array. If the value for the + // member is zero, then it was set to the "default_accessibility" + // which for structs was "public". Below we correct this + // by setting any fields to "private" that weren't correctly + // set. + if (is_a_class && !member_accessibilities.empty()) + { + // This is a class and all members that didn't have + // their access specified are private. + type_list->GetClangASTContext().SetDefaultAccessForRecordFields (clang_type, eAccessPrivate, &member_accessibilities.front(), member_accessibilities.size()); + } + + if (!base_classes.empty()) + { + type_list->GetClangASTContext().SetBaseClassesForClassType (clang_type, &base_classes.front(), base_classes.size()); + + // Clang will copy each CXXBaseSpecifier in "base_classes" + // so we have to free them all. + ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(), base_classes.size()); + } + + } + type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); + return clang_type; + + case DW_TAG_enumeration_type: + type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); + if (die->HasChildren()) + { + SymbolContext sc(GetCompUnitForDWARFCompUnit(cu)); + ParseChildEnumerators(sc, clang_type, type->GetByteSize(), cu, die); + } + type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); + return clang_type; + + default: + assert(false && "not a forward clang type decl!"); + break; + } + return NULL; +} + Type* SymbolFileDWARF::ResolveType (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* type_die) { @@ -1224,10 +1341,7 @@ SymbolFileDWARF::ResolveType (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* t { Type *type = m_die_to_type.lookup (type_die); if (type == NULL) - { - TypeSP owning_type_sp; - type = GetTypeForDIE(cu, type_die, owning_type_sp, 0, 0).get(); - } + type = GetTypeForDIE (cu, type_die).get(); assert (type != DIE_IS_BEING_PARSED); return type; } @@ -1889,7 +2003,7 @@ SymbolFileDWARF::ParseChildParameters const DWARFDebugInfoEntry *parent_die, bool skip_artificial, TypeList* type_list, - std::vector<void *>& function_param_types, + std::vector<clang_type_t>& function_param_types, std::vector<clang::ParmVarDecl*>& function_param_decls ) { @@ -1983,9 +2097,9 @@ SymbolFileDWARF::ParseChildParameters Type *type = ResolveTypeUID(param_type_die_offset); if (type) { - function_param_types.push_back (type->GetOpaqueClangQualType()); + function_param_types.push_back (type->GetClangType(true)); - clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, type->GetOpaqueClangQualType(), storage); + clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, type->GetClangType(), storage); assert(param_var_decl); function_param_decls.push_back(param_var_decl); } @@ -2005,8 +2119,7 @@ size_t SymbolFileDWARF::ParseChildEnumerators ( const SymbolContext& sc, - TypeSP& type_sp, - void * enumerator_qual_type, + clang_type_t enumerator_clang_type, uint32_t enumerator_byte_size, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die @@ -2065,7 +2178,12 @@ SymbolFileDWARF::ParseChildEnumerators if (name && name[0] && got_value) { TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); - type_list->GetClangASTContext().AddEnumerationValueToEnumerationType (type_sp->GetOpaqueClangQualType(), enumerator_qual_type, decl, name, enum_value, enumerator_byte_size * 8); + type_list->GetClangASTContext().AddEnumerationValueToEnumerationType (enumerator_clang_type, + enumerator_clang_type, + decl, + name, + enum_value, + enumerator_byte_size * 8); ++enumerators_added; } } @@ -2194,8 +2312,6 @@ SymbolFileDWARF::ParseChildArrayInfo break; default: - //printf("0x%8.8x: %-30s skipping attribute at 0x%8.8x: %s\n", die->GetOffset(), DW_TAG_value_to_name(tag), attributes.die_offsets[i], DW_AT_value_to_name(attr)); // remove this, debug only - case DW_AT_abstract_origin: case DW_AT_accessibility: case DW_AT_allocated: @@ -2225,14 +2341,7 @@ SymbolFileDWARF::ParseChildArrayInfo } TypeSP -SymbolFileDWARF::GetTypeForDIE -( - DWARFCompileUnit *cu, - const DWARFDebugInfoEntry* die, - TypeSP& owning_type_sp, - int32_t child_type, - uint32_t idx -) +SymbolFileDWARF::GetTypeForDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry* die) { TypeSP type_sp; if (die != NULL) @@ -2242,10 +2351,7 @@ SymbolFileDWARF::GetTypeForDIE if (type_ptr == NULL) { SymbolContext sc(GetCompUnitForDWARFCompUnit(cu)); - bool type_is_new = false; - type_sp = ParseType(sc, cu, die, type_is_new); - if (owning_type_sp.get() == NULL) - owning_type_sp = type_sp; + type_sp = ParseType(sc, cu, die, NULL); } else if (type_ptr != DIE_IS_BEING_PARSED) { @@ -2316,17 +2422,21 @@ SymbolFileDWARF::GetClangDeclContextForDIE (DWARFCompileUnit *cu, const DWARFDeb } TypeSP -SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool &type_is_new) +SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new_ptr) { TypeSP type_sp; + if (type_is_new_ptr) + *type_is_new_ptr = false; + AccessType accessibility = eAccessNone; if (die != NULL) { Type *type_ptr = m_die_to_type.lookup (die); if (type_ptr == NULL) { - type_is_new = true; + if (type_is_new_ptr) + *type_is_new_ptr = true; const dw_tag_t tag = die->Tag(); @@ -2335,7 +2445,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const char *type_name_cstr = NULL; ConstString type_name_dbstr; Type::EncodingUIDType encoding_uid_type = Type::eIsTypeWithUID; - void *clang_type = NULL; + clang_type_t clang_type = NULL; TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); dw_attr_t attr; @@ -2350,7 +2460,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, case DW_TAG_restrict_type: case DW_TAG_volatile_type: { - //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); // Set a bit that lets us know that we are currently parsing this m_die_to_type[die] = DIE_IS_BEING_PARSED; @@ -2398,37 +2507,37 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, case DW_TAG_pointer_type: // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetOpaqueClangQualType() + // Type object and will be looked up when the Type::GetClangType() encoding_uid_type = Type::ePointerToTypeWithUID; break; case DW_TAG_reference_type: // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetOpaqueClangQualType() + // Type object and will be looked up when the Type::GetClangType() encoding_uid_type = Type::eLValueReferenceToTypeWithUID; break; case DW_TAG_typedef: // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetOpaqueClangQualType() + // Type object and will be looked up when the Type::GetClangType() encoding_uid_type = Type::eTypedefToTypeWithUID; break; case DW_TAG_const_type: // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetOpaqueClangQualType() + // Type object and will be looked up when the Type::GetClangType() encoding_uid_type = Type::eIsConstTypeWithUID; //ClangASTContext::AddConstModifier (clang_type); break; case DW_TAG_restrict_type: // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetOpaqueClangQualType() + // Type object and will be looked up when the Type::GetClangType() encoding_uid_type = Type::eIsRestrictTypeWithUID; //ClangASTContext::AddRestrictModifier (clang_type); break; case DW_TAG_volatile_type: // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetOpaqueClangQualType() + // Type object and will be looked up when the Type::GetClangType() encoding_uid_type = Type::eIsVolatileTypeWithUID; //ClangASTContext::AddVolatileModifier (clang_type); break; } @@ -2473,7 +2582,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, case DW_TAG_union_type: case DW_TAG_class_type: { - //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); // Set a bit that lets us know that we are currently parsing this m_die_to_type[die] = DIE_IS_BEING_PARSED; @@ -2559,21 +2667,34 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } assert (tag_decl_kind != -1); - clang_type = type_list->GetClangASTContext().CreateRecordType (type_name_cstr, tag_decl_kind, GetClangDeclContextForDIE (dwarf_cu, die), class_language); + bool clang_type_was_created = false; + clang_type = m_forward_decl_die_to_clang_type.lookup (die); + if (clang_type == NULL) + { + clang_type_was_created = true; + clang_type = type_list->GetClangASTContext().CreateRecordType (type_name_cstr, tag_decl_kind, GetClangDeclContextForDIE (dwarf_cu, die), class_language); + } // Store a forward declaration to this class type in case any // parameters in any class methods need it for the clang // types for function prototypes. - m_die_to_clang_type[die] = clang_type; m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type)); m_die_to_type[die] = type_sp.get(); -// assert(type_sp.get()); -// if (accessibility) -// type_sp->SetAccess(accessibility); -// + // Leave this as a forward declaration until we need + // to know the details of the type. lldb_private::Type + // will automatically call the SymbolFile virtual function + // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)" + // When the definition needs to be defined. + if (clang_type_was_created) + { + m_forward_decl_die_to_clang_type[die] = clang_type; + m_forward_decl_clang_type_to_die[clang_type] = die; + } + +#if 0 type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); if (die->HasChildren()) { @@ -2581,7 +2702,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, std::vector<int> member_accessibilities; bool is_a_class = false; ParseChildMembers (sc, - type_sp, dwarf_cu, die, clang_type, @@ -2627,12 +2747,12 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); +#endif // #if 0 } break; case DW_TAG_enumeration_type: { - //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); // Set a bit that lets us know that we are currently parsing this m_die_to_type[die] = DIE_IS_BEING_PARSED; @@ -2679,21 +2799,41 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } } } - - void *enumerator_qual_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, DW_ATE_signed, byte_size * 8); - clang_type = type_list->GetClangASTContext().CreateEnumerationType(decl, type_name_cstr, enumerator_qual_type); + clang_type_t enumerator_clang_type = NULL; + clang_type = m_forward_decl_die_to_clang_type.lookup (die); + if (clang_type == NULL) + { + enumerator_clang_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, DW_ATE_signed, byte_size * 8); + clang_type = type_list->GetClangASTContext().CreateEnumerationType(decl, type_name_cstr, enumerator_clang_type); + } + else + { + enumerator_clang_type = ClangASTContext::GetEnumerationIntegerType (clang_type); + assert (enumerator_clang_type != NULL); + } + m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, encoding_uid, Type::eIsTypeWithUID, &decl, clang_type)); m_die_to_type[die] = type_sp.get(); + // Leave this as a forward declaration until we need + // to know the details of the type. lldb_private::Type + // will automatically call the SymbolFile virtual function + // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)" + // When the definition needs to be defined. + m_forward_decl_die_to_clang_type[die] = clang_type; + m_forward_decl_clang_type_to_die[clang_type] = die; + +#if 0 if (die->HasChildren()) { type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); - ParseChildEnumerators(sc, type_sp, enumerator_qual_type, byte_size, dwarf_cu, die); + ParseChildEnumerators(sc, enumerator_clang_type, byte_size, dwarf_cu, die); type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); } +#endif // #if 0 } } break; @@ -2702,7 +2842,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, case DW_TAG_subprogram: case DW_TAG_subroutine_type: { - //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); // Set a bit that lets us know that we are currently parsing this m_die_to_type[die] = DIE_IS_BEING_PARSED; @@ -2787,14 +2926,14 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } } - void *return_clang_type = NULL; + clang_type_t return_clang_type = NULL; Type *func_type = ResolveTypeUID(type_die_offset); if (func_type) - return_clang_type = func_type->GetOpaqueClangQualType(); + return_clang_type = func_type->GetClangType(true); else return_clang_type = type_list->GetClangASTContext().GetBuiltInType_void(); - std::vector<void *> function_param_types; + std::vector<clang_type_t> function_param_types; std::vector<clang::ParmVarDecl*> function_param_decls; // Parse the function children for the parameters @@ -2817,7 +2956,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const char *class_name_start = type_name_cstr + 2; const char *class_name_end = ::strchr (class_name_start, ' '); SymbolContext empty_sc; - void *class_opaque_type = NULL; + clang_type_t class_opaque_type = NULL; if (class_name_start < class_name_end) { ConstString class_name (class_name_start, class_name_end - class_name_start); @@ -2828,9 +2967,9 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, for (uint32_t i=0; i<match_count; ++i) { Type *type = types.GetTypeAtIndex (i).get(); - if (ClangASTContext::IsObjCClassType (type->GetOpaqueClangQualType())) + if (ClangASTContext::IsObjCClassType (type->GetClangType())) { - class_opaque_type = type->GetOpaqueClangQualType(); + class_opaque_type = type->GetClangType(); break; } } @@ -2856,7 +2995,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, Type *class_type = ResolveType (dwarf_cu, parent_die); if (class_type) { - void *class_opaque_type = class_type->GetOpaqueClangQualType (); + clang_type_t class_opaque_type = class_type->GetClangType (true); if (ClangASTContext::IsCXXClassType (class_opaque_type)) { clang::CXXMethodDecl *cxx_method_decl; @@ -2895,7 +3034,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, case DW_TAG_array_type: { - //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); // Set a bit that lets us know that we are currently parsing this m_die_to_type[die] = DIE_IS_BEING_PARSED; @@ -2958,7 +3096,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, element_orders.push_back (1); if (byte_stride == 0 && bit_stride == 0) byte_stride = element_type->GetByteSize(); - void *array_element_type = element_type->GetOpaqueClangQualType(); + clang_type_t array_element_type = element_type->GetClangType(); uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride; uint64_t num_elements = 0; std::vector<uint64_t>::const_reverse_iterator pos; @@ -3006,8 +3144,8 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, Type *pointee_type = ResolveTypeUID(type_die_offset); Type *class_type = ResolveTypeUID(containing_type_die_offset); - void *pointee_clang_type = pointee_type->GetOpaqueClangQualType(); - void *class_clang_type = class_type->GetOpaqueClangQualType(); + clang_type_t pointee_clang_type = pointee_type->GetClangType(); + clang_type_t class_clang_type = class_type->GetClangType(); clang_type = type_list->GetClangASTContext().CreateMemberPointerType(pointee_clang_type, class_clang_type); @@ -3071,13 +3209,20 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } size_t -SymbolFileDWARF::ParseTypes (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children) +SymbolFileDWARF::ParseTypes +( + const SymbolContext& sc, + DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry *die, + bool parse_siblings, + bool parse_children +) { size_t types_added = 0; while (die != NULL) { bool type_is_new = false; - if (ParseType(sc, dwarf_cu, die, type_is_new).get()) + if (ParseType(sc, dwarf_cu, die, &type_is_new).get()) { if (type_is_new) ++types_added; @@ -3400,7 +3545,7 @@ SymbolFileDWARF::ParseVariables Block *block = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset()); assert (block != NULL); - variables = block->GetVariableList(false, true); + variables = block->GetVariableList(false, false); if (variables.get() == NULL) { variables.reset(new VariableList()); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 3988113223e..e1542c0c483 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -94,6 +94,8 @@ public: virtual size_t ParseVariablesForContext (const lldb_private::SymbolContext& sc); virtual lldb_private::Type* ResolveTypeUID(lldb::user_id_t type_uid); + virtual lldb::clang_type_t ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_opaque_type); + virtual lldb_private::Type* ResolveType (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* type_die); virtual clang::DeclContext* GetClangDeclContextForTypeUID (lldb::user_id_t type_uid); @@ -214,7 +216,7 @@ protected: bool parse_siblings, bool parse_children); size_t ParseTypes (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children); - lldb::TypeSP ParseType (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool &type_is_new); + lldb::TypeSP ParseType (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new); lldb::VariableSP ParseVariableDIE( const lldb_private::SymbolContext& sc, @@ -233,10 +235,9 @@ protected: size_t ParseChildMembers( const lldb_private::SymbolContext& sc, - lldb::TypeSP& type_sp, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, - void *class_clang_type, + lldb::clang_type_t class_clang_type, const lldb::LanguageType class_language, std::vector<clang::CXXBaseSpecifier *>& base_classes, std::vector<int>& member_accessibilities, @@ -250,13 +251,12 @@ protected: const DWARFDebugInfoEntry *parent_die, bool skip_artificial, lldb_private::TypeList* type_list, - std::vector<void *>& function_args, + std::vector<lldb::clang_type_t>& function_args, std::vector<clang::ParmVarDecl*>& function_param_decls); size_t ParseChildEnumerators( const lldb_private::SymbolContext& sc, - lldb::TypeSP& type_sp, - void *enumerator_qual_type, + lldb::clang_type_t enumerator_qual_type, uint32_t enumerator_byte_size, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *enum_die); @@ -281,10 +281,7 @@ protected: lldb_private::SymbolContextList& sc_list); lldb::TypeSP GetTypeForDIE (DWARFCompileUnit *cu, - const DWARFDebugInfoEntry* die, - lldb::TypeSP& owning_type_sp, - int32_t child_type, - uint32_t idx); + const DWARFDebugInfoEntry* die); uint32_t FindTypes(std::vector<dw_offset_t> die_offsets, uint32_t max_matches, lldb_private::TypeList& types); @@ -319,12 +316,13 @@ protected: typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap; typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *> DIEToTypePtr; typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP> DIEToVariableSP; - typedef llvm::DenseMap<const DWARFDebugInfoEntry *, void *> DIEToClangType; + typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::clang_type_t> DIEToClangType; + typedef llvm::DenseMap<lldb::clang_type_t, const DWARFDebugInfoEntry *> ClangTypeToDIE; DIEToDeclContextMap m_die_to_decl_ctx; DIEToTypePtr m_die_to_type; DIEToVariableSP m_die_to_variable_sp; - DIEToClangType m_die_to_clang_type; - + DIEToClangType m_forward_decl_die_to_clang_type; + ClangTypeToDIE m_forward_decl_clang_type_to_die; }; #endif // liblldb_SymbolFileDWARF_h_ diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index d216ef538c5..7a851233b02 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -592,6 +592,12 @@ SymbolFileDWARFDebugMap::ResolveTypeUID(lldb::user_id_t type_uid) return NULL; } +lldb::clang_type_t +SymbolFileDWARFDebugMap::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Type) +{ + // We have a struct/union/class/enum that needs to be fully resolved. + return NULL; +} uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext (const Address& exe_so_addr, uint32_t resolve_scope, SymbolContext& sc) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index adb0ec5136d..430000d71c3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -59,7 +59,8 @@ public: virtual size_t ParseTypes (const lldb_private::SymbolContext& sc); virtual size_t ParseVariablesForContext (const lldb_private::SymbolContext& sc); - virtual lldb_private::Type* ResolveTypeUID (lldb::user_id_t type_uid); + virtual lldb_private::Type* ResolveTypeUID (lldb::user_id_t type_uid); + virtual lldb::clang_type_t ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Type); virtual uint32_t ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc); virtual uint32_t ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list); virtual uint32_t FindGlobalVariables (const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::VariableList& variables); diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp index 91e4cd4ff0e..e42553f1552 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -271,6 +271,11 @@ SymbolFileSymtab::ResolveTypeUID(lldb::user_id_t type_uid) return NULL; } +lldb::clang_type_t +SymbolFileSymtab::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Type) +{ + return NULL; +} uint32_t diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h index da43985d31c..3d09cd4ee3c 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h @@ -74,6 +74,9 @@ public: virtual lldb_private::Type* ResolveTypeUID(lldb::user_id_t type_uid); + virtual lldb::clang_type_t + ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Type); + virtual uint32_t ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc); diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index cf223b4cfb0..a0f483bc24b 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -398,7 +398,7 @@ QualTypeMatchesBitSize(const uint64_t bit_size, ASTContext *ast_context, QualTyp return false; } -void * +clang_type_t ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (Encoding encoding, uint32_t bit_size) { ASTContext *ast_context = getASTContext(); @@ -408,8 +408,8 @@ ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (Encoding encoding, uint32_ return GetBuiltinTypeForEncodingAndBitSize (ast_context, encoding, bit_size); } -void * -ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (clang::ASTContext *ast_context, Encoding encoding, uint32_t bit_size) +clang_type_t +ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (ASTContext *ast_context, Encoding encoding, uint32_t bit_size) { if (!ast_context) return NULL; @@ -468,7 +468,7 @@ ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (clang::ASTContext *ast_con return NULL; } -void * +clang_type_t ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name, uint32_t dw_ate, uint32_t bit_size) { ASTContext *ast_context = getASTContext(); @@ -657,31 +657,31 @@ ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name return NULL; } -void * -ClangASTContext::GetBuiltInType_void(clang::ASTContext *ast_context) +clang_type_t +ClangASTContext::GetBuiltInType_void(ASTContext *ast_context) { return ast_context->VoidTy.getAsOpaquePtr(); } -void * +clang_type_t ClangASTContext::GetBuiltInType_objc_id() { return getASTContext()->getObjCIdType().getAsOpaquePtr(); } -void * +clang_type_t ClangASTContext::GetBuiltInType_objc_Class() { return getASTContext()->getObjCClassType().getAsOpaquePtr(); } -void * +clang_type_t ClangASTContext::GetBuiltInType_objc_selector() { return getASTContext()->getObjCSelType().getAsOpaquePtr(); } -void * +clang_type_t ClangASTContext::GetCStringType (bool is_const) { QualType char_type(getASTContext()->CharTy); @@ -692,14 +692,14 @@ ClangASTContext::GetCStringType (bool is_const) return getASTContext()->getPointerType(char_type).getAsOpaquePtr(); } -void * +clang_type_t ClangASTContext::GetVoidPtrType (bool is_const) { return GetVoidPtrType(getASTContext(), is_const); } -void * -ClangASTContext::GetVoidPtrType (clang::ASTContext *ast_context, bool is_const) +clang_type_t +ClangASTContext::GetVoidPtrType (ASTContext *ast_context, bool is_const) { QualType void_ptr_type(ast_context->VoidPtrTy); @@ -709,10 +709,10 @@ ClangASTContext::GetVoidPtrType (clang::ASTContext *ast_context, bool is_const) return void_ptr_type.getAsOpaquePtr(); } -void * -ClangASTContext::CopyType(clang::ASTContext *dest_context, - clang::ASTContext *source_context, - void *clang_type) +clang_type_t +ClangASTContext::CopyType (ASTContext *dest_context, + ASTContext *source_context, + clang_type_t clang_type) { Diagnostic diagnostics; FileManager file_manager; @@ -724,9 +724,9 @@ ClangASTContext::CopyType(clang::ASTContext *dest_context, } bool -ClangASTContext::AreTypesSame(clang::ASTContext *ast_context, - void *type1, - void *type2) +ClangASTContext::AreTypesSame(ASTContext *ast_context, + clang_type_t type1, + clang_type_t type2) { return ast_context->hasSameType(QualType::getFromOpaquePtr(type1), QualType::getFromOpaquePtr(type2)); @@ -734,8 +734,8 @@ ClangASTContext::AreTypesSame(clang::ASTContext *ast_context, #pragma mark CVR modifiers -void * -ClangASTContext::AddConstModifier (void *clang_type) +clang_type_t +ClangASTContext::AddConstModifier (clang_type_t clang_type) { if (clang_type) { @@ -746,8 +746,8 @@ ClangASTContext::AddConstModifier (void *clang_type) return NULL; } -void * -ClangASTContext::AddRestrictModifier (void *clang_type) +clang_type_t +ClangASTContext::AddRestrictModifier (clang_type_t clang_type) { if (clang_type) { @@ -758,8 +758,8 @@ ClangASTContext::AddRestrictModifier (void *clang_type) return NULL; } -void * -ClangASTContext::AddVolatileModifier (void *clang_type) +clang_type_t +ClangASTContext::AddVolatileModifier (clang_type_t clang_type) { if (clang_type) { @@ -772,7 +772,7 @@ ClangASTContext::AddVolatileModifier (void *clang_type) #pragma mark Structure, Unions, Classes -void * +clang_type_t ClangASTContext::CreateRecordType (const char *name, int kind, DeclContext *decl_ctx, LanguageType language) { ASTContext *ast_context = getASTContext(); @@ -806,10 +806,10 @@ ClangASTContext::CreateRecordType (const char *name, int kind, DeclContext *decl CXXMethodDecl * ClangASTContext::AddMethodToCXXRecordType ( - clang::ASTContext *ast_context, - void *record_opaque_type, + ASTContext *ast_context, + clang_type_t record_opaque_type, const char *name, - void *method_opaque_type, + clang_type_t method_opaque_type, lldb::AccessType access, bool is_virtual, bool is_static, @@ -859,7 +859,7 @@ ClangASTContext::AddMethodToCXXRecordType is_inline); - clang::AccessSpecifier access_specifier = ConvertAccessTypeToAccessSpecifier (access); + AccessSpecifier access_specifier = ConvertAccessTypeToAccessSpecifier (access); cxx_method_decl->setAccess (access_specifier); cxx_method_decl->setVirtualAsWritten (is_virtual); @@ -904,10 +904,10 @@ ClangASTContext::AddMethodToCXXRecordType bool ClangASTContext::AddFieldToRecordType ( - clang::ASTContext *ast_context, - void *record_clang_type, + ASTContext *ast_context, + clang_type_t record_clang_type, const char *name, - void *field_type, + clang_type_t field_type, AccessType access, uint32_t bitfield_bit_size ) @@ -1069,7 +1069,7 @@ ClangASTContext::RecordHasFields (const RecordDecl *record_decl) } void -ClangASTContext::SetDefaultAccessForRecordFields (void *clang_qual_type, int default_accessibility, int *assigned_accessibilities, size_t num_assigned_accessibilities) +ClangASTContext::SetDefaultAccessForRecordFields (clang_type_t clang_qual_type, int default_accessibility, int *assigned_accessibilities, size_t num_assigned_accessibilities) { if (clang_qual_type) { @@ -1102,7 +1102,7 @@ ClangASTContext::SetDefaultAccessForRecordFields (void *clang_qual_type, int def #pragma mark C++ Base Classes CXXBaseSpecifier * -ClangASTContext::CreateBaseClassSpecifier (void *base_class_type, AccessType access, bool is_virtual, bool base_of_class) +ClangASTContext::CreateBaseClassSpecifier (clang_type_t base_class_type, AccessType access, bool is_virtual, bool base_of_class) { if (base_class_type) return new CXXBaseSpecifier (SourceRange(), @@ -1124,7 +1124,7 @@ ClangASTContext::DeleteBaseClassSpecifiers (CXXBaseSpecifier **base_classes, uns } bool -ClangASTContext::SetBaseClassesForClassType (void *class_clang_type, CXXBaseSpecifier const * const *base_classes, unsigned num_base_classes) +ClangASTContext::SetBaseClassesForClassType (clang_type_t class_clang_type, CXXBaseSpecifier const * const *base_classes, unsigned num_base_classes) { if (class_clang_type) { @@ -1188,7 +1188,7 @@ ClangASTContext::SetBaseClassesForClassType (void *class_clang_type, CXXBaseSpec } #pragma mark Objective C Classes -void * +clang_type_t ClangASTContext::CreateObjCClass ( const char *name, @@ -1220,7 +1220,7 @@ ClangASTContext::CreateObjCClass } bool -ClangASTContext::SetObjCSuperClass (void *class_opaque_type, void *super_opaque_type) +ClangASTContext::SetObjCSuperClass (clang_type_t class_opaque_type, clang_type_t super_opaque_type) { if (class_opaque_type && super_opaque_type) { @@ -1251,10 +1251,10 @@ ClangASTContext::SetObjCSuperClass (void *class_opaque_type, void *super_opaque_ bool ClangASTContext::AddObjCClassIVar ( - clang::ASTContext *ast_context, - void *class_opaque_type, + ASTContext *ast_context, + clang_type_t class_opaque_type, const char *name, - void *ivar_opaque_type, + clang_type_t ivar_opaque_type, AccessType access, uint32_t bitfield_bit_size, bool is_synthesized @@ -1311,7 +1311,7 @@ ClangASTContext::AddObjCClassIVar bool -ClangASTContext::ObjCTypeHasIVars (void *class_opaque_type, bool check_superclass) +ClangASTContext::ObjCTypeHasIVars (clang_type_t class_opaque_type, bool check_superclass) { QualType class_qual_type(QualType::getFromOpaquePtr(class_opaque_type)); @@ -1342,13 +1342,13 @@ ClangASTContext::ObjCDeclHasIVars (ObjCInterfaceDecl *class_interface_decl, bool return false; } -clang::ObjCMethodDecl * +ObjCMethodDecl * ClangASTContext::AddMethodToObjCObjectType ( - clang::ASTContext *ast_context, - void *class_opaque_type, + ASTContext *ast_context, + clang_type_t class_opaque_type, const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]") - void *method_opaque_type, + clang_type_t method_opaque_type, lldb::AccessType access ) { @@ -1471,7 +1471,7 @@ ClangASTContext::AddMethodToObjCObjectType #pragma mark Aggregate Types bool -ClangASTContext::IsAggregateType (void *clang_type) +ClangASTContext::IsAggregateType (clang_type_t clang_type) { if (clang_type == NULL) return false; @@ -1505,7 +1505,7 @@ ClangASTContext::IsAggregateType (void *clang_type) } uint32_t -ClangASTContext::GetNumChildren (void *clang_qual_type, bool omit_empty_base_classes) +ClangASTContext::GetNumChildren (clang_type_t clang_qual_type, bool omit_empty_base_classes) { if (clang_qual_type == NULL) return 0; @@ -1642,11 +1642,11 @@ ClangASTContext::GetNumChildren (void *clang_qual_type, bool omit_empty_base_cla } -void * +clang_type_t ClangASTContext::GetChildClangTypeAtIndex ( const char *parent_name, - void *parent_clang_type, + clang_type_t parent_clang_type, uint32_t idx, bool transparent_pointers, bool omit_empty_base_classes, @@ -1673,12 +1673,12 @@ ClangASTContext::GetChildClangTypeAtIndex return NULL; } -void * +clang_type_t ClangASTContext::GetChildClangTypeAtIndex ( ASTContext *ast_context, const char *parent_name, - void *parent_clang_type, + clang_type_t parent_clang_type, uint32_t idx, bool transparent_pointers, bool omit_empty_base_classes, @@ -2186,7 +2186,7 @@ size_t ClangASTContext::GetIndexOfChildMemberWithName ( ASTContext *ast_context, - void *clang_type, + clang_type_t clang_type, const char *name, bool omit_empty_base_classes, std::vector<uint32_t>& child_indexes @@ -2464,7 +2464,7 @@ uint32_t ClangASTContext::GetIndexOfChildWithName ( ASTContext *ast_context, - void *clang_type, + clang_type_t clang_type, const char *name, bool omit_empty_base_classes ) @@ -2668,7 +2668,7 @@ ClangASTContext::GetIndexOfChildWithName #pragma mark TagType bool -ClangASTContext::SetTagTypeKind (void *tag_clang_type, int kind) +ClangASTContext::SetTagTypeKind (clang_type_t tag_clang_type, int kind) { if (tag_clang_type) { @@ -2695,7 +2695,7 @@ ClangASTContext::SetTagTypeKind (void *tag_clang_type, int kind) #pragma mark DeclContext Functions DeclContext * -ClangASTContext::GetDeclContextForType (void *clang_type) +ClangASTContext::GetDeclContextForType (clang_type_t clang_type) { if (clang_type == NULL) return NULL; @@ -2756,7 +2756,7 @@ ClangASTContext::GetUniqueNamespaceDeclaration (const char *name, const Declarat #pragma mark Function Types FunctionDecl * -ClangASTContext::CreateFunctionDeclaration (const char *name, void *function_clang_type, int storage, bool is_inline) +ClangASTContext::CreateFunctionDeclaration (const char *name, clang_type_t function_clang_type, int storage, bool is_inline) { if (name) { @@ -2791,10 +2791,10 @@ ClangASTContext::CreateFunctionDeclaration (const char *name, void *function_cla return NULL; } -void * -ClangASTContext::CreateFunctionType (clang::ASTContext *ast_context, - void *result_type, - void **args, +clang_type_t +ClangASTContext::CreateFunctionType (ASTContext *ast_context, + clang_type_t result_type, + clang_type_t *args, unsigned num_args, bool is_variadic, unsigned type_quals) @@ -2818,7 +2818,7 @@ ClangASTContext::CreateFunctionType (clang::ASTContext *ast_context, } ParmVarDecl * -ClangASTContext::CreateParameterDeclaration (const char *name, void *param_type, int storage) +ClangASTContext::CreateParameterDeclaration (const char *name, clang_type_t param_type, int storage) { ASTContext *ast_context = getASTContext(); assert (ast_context != NULL); @@ -2843,8 +2843,8 @@ ClangASTContext::SetFunctionParameters (FunctionDecl *function_decl, ParmVarDecl #pragma mark Array Types -void * -ClangASTContext::CreateArrayType (void *element_type, size_t element_count, uint32_t bit_stride) +clang_type_t +ClangASTContext::CreateArrayType (clang_type_t element_type, size_t element_count, uint32_t bit_stride) { if (element_type) { @@ -2863,7 +2863,7 @@ ClangASTContext::CreateArrayType (void *element_type, size_t element_count, uint #pragma mark TagDecl bool -ClangASTContext::StartTagDeclarationDefinition (void *clang_type) +ClangASTContext::StartTagDeclarationDefinition (clang_type_t clang_type) { if (clang_type) { @@ -2887,7 +2887,7 @@ ClangASTContext::StartTagDeclarationDefinition (void *clang_type) } bool -ClangASTContext::CompleteTagDeclarationDefinition (void *clang_type) +ClangASTContext::CompleteTagDeclarationDefinition (clang_type_t clang_type) { if (clang_type) { @@ -2913,8 +2913,8 @@ ClangASTContext::CompleteTagDeclarationDefinition (void *clang_type) #pragma mark Enumeration Types -void * -ClangASTContext::CreateEnumerationType (const Declaration &decl, const char *name, void *integer_qual_type) +clang_type_t +ClangASTContext::CreateEnumerationType (const Declaration &decl, const char *name, clang_type_t integer_qual_type) { // TODO: Do something intelligent with the Declaration object passed in // like maybe filling in the SourceLocation with it... @@ -2935,11 +2935,29 @@ ClangASTContext::CreateEnumerationType (const Declaration &decl, const char *nam return NULL; } +clang_type_t +ClangASTContext::GetEnumerationIntegerType (clang_type_t enum_clang_type) +{ + QualType enum_qual_type (QualType::getFromOpaquePtr(enum_clang_type)); + + clang::Type *clang_type = enum_qual_type.getTypePtr(); + if (clang_type) + { + const EnumType *enum_type = dyn_cast<EnumType>(clang_type); + if (enum_type) + { + EnumDecl *enum_decl = enum_type->getDecl(); + if (enum_decl) + return enum_decl->getIntegerType().getAsOpaquePtr(); + } + } + return NULL; +} bool ClangASTContext::AddEnumerationValueToEnumerationType ( - void *enum_clang_type, - void *enumerator_clang_type, + clang_type_t enum_clang_type, + clang_type_t enumerator_clang_type, const Declaration &decl, const char *name, int64_t enum_value, @@ -2988,8 +3006,8 @@ ClangASTContext::AddEnumerationValueToEnumerationType #pragma mark Pointers & References -void * -ClangASTContext::CreatePointerType (void *clang_type) +clang_type_t +ClangASTContext::CreatePointerType (clang_type_t clang_type) { if (clang_type) { @@ -3009,24 +3027,24 @@ ClangASTContext::CreatePointerType (void *clang_type) return NULL; } -void * -ClangASTContext::CreateLValueReferenceType (void *clang_type) +clang_type_t +ClangASTContext::CreateLValueReferenceType (clang_type_t clang_type) { if (clang_type) return getASTContext()->getLValueReferenceType (QualType::getFromOpaquePtr(clang_type)).getAsOpaquePtr(); return NULL; } -void * -ClangASTContext::CreateRValueReferenceType (void *clang_type) +clang_type_t +ClangASTContext::CreateRValueReferenceType (clang_type_t clang_type) { if (clang_type) return getASTContext()->getRValueReferenceType (QualType::getFromOpaquePtr(clang_type)).getAsOpaquePtr(); return NULL; } -void * -ClangASTContext::CreateMemberPointerType (void *clang_pointee_type, void *clang_class_type) +clang_type_t +ClangASTContext::CreateMemberPointerType (clang_type_t clang_pointee_type, clang_type_t clang_class_type) { if (clang_pointee_type && clang_pointee_type) return getASTContext()->getMemberPointerType(QualType::getFromOpaquePtr(clang_pointee_type), @@ -3042,7 +3060,7 @@ ClangASTContext::GetPointerBitSize () } bool -ClangASTContext::IsPointerOrReferenceType (void *clang_type, void **target_type) +ClangASTContext::IsPointerOrReferenceType (clang_type_t clang_type, clang_type_t*target_type) { if (clang_type == NULL) return false; @@ -3084,7 +3102,7 @@ ClangASTContext::IsPointerOrReferenceType (void *clang_type, void **target_type) } bool -ClangASTContext::IsIntegerType (void *clang_type, bool &is_signed) +ClangASTContext::IsIntegerType (clang_type_t clang_type, bool &is_signed) { if (!clang_type) return false; @@ -3104,7 +3122,7 @@ ClangASTContext::IsIntegerType (void *clang_type, bool &is_signed) } bool -ClangASTContext::IsPointerType (void *clang_type, void **target_type) +ClangASTContext::IsPointerType (clang_type_t clang_type, clang_type_t*target_type) { if (clang_type) { @@ -3138,7 +3156,7 @@ ClangASTContext::IsPointerType (void *clang_type, void **target_type) } bool -ClangASTContext::IsFloatingPointType (void *clang_type, uint32_t &count, bool &is_complex) +ClangASTContext::IsFloatingPointType (clang_type_t clang_type, uint32_t &count, bool &is_complex) { if (clang_type) { @@ -3177,7 +3195,7 @@ ClangASTContext::IsFloatingPointType (void *clang_type, uint32_t &count, bool &i } bool -ClangASTContext::IsCXXClassType (void *clang_type) +ClangASTContext::IsCXXClassType (clang_type_t clang_type) { if (clang_type) { @@ -3189,7 +3207,7 @@ ClangASTContext::IsCXXClassType (void *clang_type) } bool -ClangASTContext::IsObjCClassType (void *clang_type) +ClangASTContext::IsObjCClassType (clang_type_t clang_type) { if (clang_type) { @@ -3204,7 +3222,7 @@ ClangASTContext::IsObjCClassType (void *clang_type) bool -ClangASTContext::IsCStringType (void *clang_type, uint32_t &length) +ClangASTContext::IsCStringType (clang_type_t clang_type, uint32_t &length) { if (clang_type) { @@ -3268,7 +3286,7 @@ ClangASTContext::IsCStringType (void *clang_type, uint32_t &length) } bool -ClangASTContext::IsFunctionPointerType (void *clang_type) +ClangASTContext::IsFunctionPointerType (clang_type_t clang_type) { if (clang_type) { @@ -3300,7 +3318,7 @@ ClangASTContext::IsFunctionPointerType (void *clang_type) bool -ClangASTContext::IsArrayType (void *clang_type, void **member_type, uint64_t *size) +ClangASTContext::IsArrayType (clang_type_t clang_type, clang_type_t*member_type, uint64_t *size) { if (!clang_type) return false; @@ -3340,8 +3358,8 @@ ClangASTContext::IsArrayType (void *clang_type, void **member_type, uint64_t *si #pragma mark Typedefs -void * -ClangASTContext::CreateTypedefType (const char *name, void *clang_type, DeclContext *decl_ctx) +clang_type_t +ClangASTContext::CreateTypedefType (const char *name, clang_type_t clang_type, DeclContext *decl_ctx) { if (clang_type) { @@ -3366,16 +3384,16 @@ ClangASTContext::CreateTypedefType (const char *name, void *clang_type, DeclCont std::string -ClangASTContext::GetTypeName (void *opaque_qual_type) +ClangASTContext::GetTypeName (clang_type_t opaque_qual_type) { std::string return_name; - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_qual_type)); + QualType qual_type(QualType::getFromOpaquePtr(opaque_qual_type)); - const clang::TypedefType *typedef_type = qual_type->getAs<clang::TypedefType>(); + const TypedefType *typedef_type = qual_type->getAs<TypedefType>(); if (typedef_type) { - const clang::TypedefDecl *typedef_decl = typedef_type->getDecl(); + const TypedefDecl *typedef_decl = typedef_type->getDecl(); return_name = typedef_decl->getQualifiedNameAsString(); } else @@ -3393,7 +3411,7 @@ ClangASTContext::GetTypeName (void *opaque_qual_type) // so we can support remote targets. The code below also requires a patch to // llvm::APInt. //bool -//ClangASTContext::ConvertFloatValueToString (ASTContext *ast_context, void *clang_type, const uint8_t* bytes, size_t byte_size, int apint_byte_order, std::string &float_str) +//ClangASTContext::ConvertFloatValueToString (ASTContext *ast_context, clang_type_t clang_type, const uint8_t* bytes, size_t byte_size, int apint_byte_order, std::string &float_str) //{ // uint32_t count = 0; // bool is_complex = false; @@ -3428,7 +3446,7 @@ ClangASTContext::GetTypeName (void *opaque_qual_type) //} size_t -ClangASTContext::ConvertStringToFloatValue (ASTContext *ast_context, void *clang_type, const char *s, uint8_t *dst, size_t dst_size) +ClangASTContext::ConvertStringToFloatValue (ASTContext *ast_context, clang_type_t clang_type, const char *s, uint8_t *dst, size_t dst_size) { if (clang_type) { @@ -3467,7 +3485,7 @@ ClangASTContext::ConvertStringToFloatValue (ASTContext *ast_context, void *clang } unsigned -ClangASTContext::GetTypeQualifiers(void *clang_type) +ClangASTContext::GetTypeQualifiers(clang_type_t clang_type) { assert (clang_type); diff --git a/lldb/source/Symbol/ClangASTType.cpp b/lldb/source/Symbol/ClangASTType.cpp index 64e1c71cbec..cccec2a8c5e 100644 --- a/lldb/source/Symbol/ClangASTType.cpp +++ b/lldb/source/Symbol/ClangASTType.cpp @@ -804,6 +804,29 @@ ClangASTType::GetTypeBitAlign (clang::ASTContext *ast_context, void *opaque_clan return 0; } + +bool +ClangASTType::IsDefined() +{ + return ClangASTType::IsDefined (m_type); +} + + +bool +ClangASTType::IsDefined (void *opaque_clang_qual_type) +{ + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + clang::TagType *tag_type = dyn_cast<clang::TagType>(qual_type.getTypePtr()); + if (tag_type) + { + clang::TagDecl *tag_decl = tag_type->getDecl(); + if (tag_decl) + return tag_decl->getDefinition() != NULL; + return false; + } + return true; +} + void ClangASTType::DumpTypeDescription (Stream *s) { diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp index 3c108d7e2b4..41a708c27d4 100644 --- a/lldb/source/Symbol/Function.cpp +++ b/lldb/source/Symbol/Function.cpp @@ -402,7 +402,7 @@ Function::GetType() const Type Function::GetReturnType () { - clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetOpaqueClangQualType())); + clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangType())); assert (clang_type->isFunctionType()); clang::FunctionType *function_type = dyn_cast<clang::FunctionType> (clang_type); clang::QualType fun_return_qualtype = function_type->getResultType(); @@ -421,7 +421,7 @@ Function::GetReturnType () int Function::GetArgumentCount () { - clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetOpaqueClangQualType())); + clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangType())); assert (clang_type->isFunctionType()); if (!clang_type->isFunctionProtoType()) return -1; @@ -436,7 +436,7 @@ Function::GetArgumentCount () const Type Function::GetArgumentTypeAtIndex (size_t idx) { - clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetOpaqueClangQualType())); + clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangType())); assert (clang_type->isFunctionType()); if (!clang_type->isFunctionProtoType()) return Type(); @@ -465,7 +465,7 @@ Function::GetArgumentTypeAtIndex (size_t idx) const char * Function::GetArgumentNameAtIndex (size_t idx) { - clang::Type *clang_type = static_cast<clang::QualType *>(GetType()->GetOpaqueClangQualType())->getTypePtr(); + clang::Type *clang_type = static_cast<clang::QualType *>(GetType()->GetClangType())->getTypePtr(); assert (clang_type->isFunctionType()); if (!clang_type->isFunctionProtoType()) return NULL; @@ -475,7 +475,7 @@ Function::GetArgumentNameAtIndex (size_t idx) bool Function::IsVariadic () { - const clang::Type *clang_type = static_cast<clang::QualType *>(GetType()->GetOpaqueClangQualType())->getTypePtr(); + const clang::Type *clang_type = static_cast<clang::QualType *>(GetType()->GetClangType())->getTypePtr(); assert (clang_type->isFunctionType()); if (!clang_type->isFunctionProtoType()) return false; diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp index 4a5e4e1eba9..a4f0410e883 100644 --- a/lldb/source/Symbol/Type.cpp +++ b/lldb/source/Symbol/Type.cpp @@ -26,6 +26,8 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" +using namespace lldb; + lldb_private::Type::Type ( lldb::user_id_t uid, @@ -36,7 +38,7 @@ lldb_private::Type::Type lldb::user_id_t encoding_uid, EncodingUIDType encoding_uid_type, const Declaration& decl, - void *clang_type + clang_type_t clang_type ) : UserID (uid), m_name (name), @@ -176,7 +178,7 @@ lldb_private::Type::GetName() { if (!(m_name)) { - if (ResolveClangType()) + if (ResolveClangType(true)) { std::string type_name = ClangASTContext::GetTypeName (m_clang_qual_type); if (!type_name.empty()) @@ -206,7 +208,7 @@ lldb_private::Type::DumpValue lldb::Format format ) { - if (ResolveClangType()) + if (ResolveClangType(true)) { if (show_types) { @@ -254,7 +256,7 @@ lldb_private::Type::GetByteSize() } if (m_byte_size == 0) { - uint64_t bit_width = ClangASTType::GetClangTypeBitWidth (GetClangAST(), GetOpaqueClangQualType()); + uint64_t bit_width = ClangASTType::GetClangTypeBitWidth (GetClangAST(), GetClangType()); m_byte_size = (bit_width + 7 ) / 8; } break; @@ -396,7 +398,7 @@ lldb_private::Type::GetDeclaration () const } bool -lldb_private::Type::ResolveClangType() +lldb_private::Type::ResolveClangType (bool forward_decl_is_ok) { if (m_clang_qual_type == NULL) { @@ -410,38 +412,38 @@ lldb_private::Type::ResolveClangType() switch (m_encoding_uid_type) { case eIsTypeWithUID: - m_clang_qual_type = encoding_type->GetOpaqueClangQualType(); + m_clang_qual_type = encoding_type->GetClangType(); break; case eIsConstTypeWithUID: - m_clang_qual_type = ClangASTContext::AddConstModifier (encoding_type->GetOpaqueClangQualType()); + m_clang_qual_type = ClangASTContext::AddConstModifier (encoding_type->GetClangType(forward_decl_is_ok)); break; case eIsRestrictTypeWithUID: - m_clang_qual_type = ClangASTContext::AddRestrictModifier (encoding_type->GetOpaqueClangQualType()); + m_clang_qual_type = ClangASTContext::AddRestrictModifier (encoding_type->GetClangType(forward_decl_is_ok)); break; case eIsVolatileTypeWithUID: - m_clang_qual_type = ClangASTContext::AddVolatileModifier (encoding_type->GetOpaqueClangQualType()); + m_clang_qual_type = ClangASTContext::AddVolatileModifier (encoding_type->GetClangType(forward_decl_is_ok)); break; case eTypedefToTypeWithUID: - m_clang_qual_type = type_list->CreateClangTypedefType (this, encoding_type); + m_clang_qual_type = type_list->CreateClangTypedefType (this, encoding_type, forward_decl_is_ok); // Clear the name so it can get fully qualified in case the // typedef is in a namespace. m_name.Clear(); break; case ePointerToTypeWithUID: - m_clang_qual_type = type_list->CreateClangPointerType (encoding_type); + m_clang_qual_type = type_list->CreateClangPointerType (encoding_type, forward_decl_is_ok); break; case eLValueReferenceToTypeWithUID: - m_clang_qual_type = type_list->CreateClangLValueReferenceType (encoding_type); + m_clang_qual_type = type_list->CreateClangLValueReferenceType (encoding_type, forward_decl_is_ok); break; case eRValueReferenceToTypeWithUID: - m_clang_qual_type = type_list->CreateClangRValueReferenceType (encoding_type); + m_clang_qual_type = type_list->CreateClangRValueReferenceType (encoding_type, forward_decl_is_ok); break; default: @@ -449,11 +451,14 @@ lldb_private::Type::ResolveClangType() break; } } + // Return here since we won't need to check if this is a forward + // declaration below since we already obeyed this above. + return m_clang_qual_type != NULL; } else { // We have no encoding type, return void? - void *void_clang_type = type_list->GetClangASTContext().GetBuiltInType_void(); + clang_type_t void_clang_type = type_list->GetClangASTContext().GetBuiltInType_void(); switch (m_encoding_uid_type) { case eIsTypeWithUID: @@ -494,10 +499,18 @@ lldb_private::Type::ResolveClangType() } } } + + // Check if we have a forward reference to a class/struct/union/enum? + if (!forward_decl_is_ok && !ClangASTType::IsDefined (m_clang_qual_type)) + { + // We have a forward declaration, we need to resolve it to a complete + // definition. + m_symbol_file->ResolveClangOpaqueTypeDefinition (m_clang_qual_type); + } return m_clang_qual_type != NULL; } -void * +clang_type_t lldb_private::Type::GetChildClangTypeAtIndex ( const char *parent_name, @@ -515,7 +528,7 @@ lldb_private::Type::GetChildClangTypeAtIndex return NULL; std::string name_str; - void *child_qual_type = GetClangASTContext().GetChildClangTypeAtIndex ( + clang_type_t child_qual_type = GetClangASTContext().GetChildClangTypeAtIndex ( parent_name, m_clang_qual_type, idx, @@ -539,10 +552,10 @@ lldb_private::Type::GetChildClangTypeAtIndex -void * -lldb_private::Type::GetOpaqueClangQualType () +clang_type_t +lldb_private::Type::GetClangType (bool forward_decl_is_ok) { - ResolveClangType(); + ResolveClangType(forward_decl_is_ok); return m_clang_qual_type; } diff --git a/lldb/source/Symbol/TypeList.cpp b/lldb/source/Symbol/TypeList.cpp index 4595a9fa633..f4bcfdf1e21 100644 --- a/lldb/source/Symbol/TypeList.cpp +++ b/lldb/source/Symbol/TypeList.cpp @@ -208,31 +208,31 @@ TypeList::GetClangASTContext () } void * -TypeList::CreateClangPointerType (Type *type) +TypeList::CreateClangPointerType (Type *type, bool forward_decl_is_ok) { assert(type); - return m_ast.CreatePointerType(type->GetOpaqueClangQualType()); + return m_ast.CreatePointerType(type->GetClangType(forward_decl_is_ok)); } void * -TypeList::CreateClangTypedefType (Type *typedef_type, Type *base_type) +TypeList::CreateClangTypedefType (Type *typedef_type, Type *base_type, bool forward_decl_is_ok) { assert(typedef_type && base_type); - return m_ast.CreateTypedefType(typedef_type->GetName().AsCString(), base_type->GetOpaqueClangQualType(), typedef_type->GetSymbolFile()->GetClangDeclContextForTypeUID(typedef_type->GetID())); + return m_ast.CreateTypedefType(typedef_type->GetName().AsCString(), base_type->GetClangType(forward_decl_is_ok), typedef_type->GetSymbolFile()->GetClangDeclContextForTypeUID(typedef_type->GetID())); } void * -TypeList::CreateClangLValueReferenceType (Type *type) +TypeList::CreateClangLValueReferenceType (Type *type, bool forward_decl_is_ok) { assert(type); - return m_ast.CreateLValueReferenceType(type->GetOpaqueClangQualType()); + return m_ast.CreateLValueReferenceType(type->GetClangType(forward_decl_is_ok)); } void * -TypeList::CreateClangRValueReferenceType (Type *type) +TypeList::CreateClangRValueReferenceType (Type *type, bool forward_decl_is_ok) { assert(type); - return m_ast.CreateRValueReferenceType (type->GetOpaqueClangQualType()); + return m_ast.CreateRValueReferenceType (type->GetClangType(forward_decl_is_ok)); } diff --git a/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj b/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj index b49a1c76c23..e3c8d0be14d 100644 --- a/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj +++ b/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj @@ -369,7 +369,6 @@ isa = PBXProject; buildConfigurationList = 1DEB914E08733D8E0010E9CD /* Build configuration list for PBXProject "debugserver" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, |