diff options
| author | Greg Clayton <gclayton@apple.com> | 2010-07-28 02:04:09 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2010-07-28 02:04:09 +0000 |
| commit | 9e40956aeab0558ade96e537997402e568fe530a (patch) | |
| tree | 30a21967a64d9b39e03f49e886e8fdfb64b7076f /lldb/source/Plugins/SymbolFile | |
| parent | e1270c64e36c2f2991e4b032b783e064afab55c1 (diff) | |
| download | bcm5719-llvm-9e40956aeab0558ade96e537997402e568fe530a.tar.gz bcm5719-llvm-9e40956aeab0558ade96e537997402e568fe530a.zip | |
Created lldb::LanguageType by moving an enumeration from the
lldb_private::Language class into the enumerations header so it can be freely
used by other interfaces.
Added correct objective C class support to the DWARF symbol parser. Prior to
this fix we were parsing objective C classes as C++ classes and now that the
expression parser is ready to call functions we need to make sure the objective
C classes have correct AST types.
llvm-svn: 109574
Diffstat (limited to 'lldb/source/Plugins/SymbolFile')
4 files changed, 67 insertions, 18 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index ad8bb2c677b..ebd0e508540 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -644,12 +644,12 @@ SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit* cu, CompUnitSP& compile_unit { const char * cu_die_name = cu_die->GetName(this, cu); const char * cu_comp_dir = cu_die->GetAttributeValueAsString(this, cu, DW_AT_comp_dir, NULL); - Language::Type language = (Language::Type)cu_die->GetAttributeValueAsUnsigned(this, cu, DW_AT_language, 0); + LanguageType class_language = (LanguageType)cu_die->GetAttributeValueAsUnsigned(this, cu, DW_AT_language, 0); if (cu_die_name) { if (cu_die_name[0] == '/' || cu_comp_dir == NULL && cu_comp_dir[0]) { - compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), cu, cu_die_name, cu->GetOffset(), language)); + compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), cu, cu_die_name, cu->GetOffset(), class_language)); } else { @@ -658,7 +658,7 @@ SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit* cu, CompUnitSP& compile_unit fullpath += '/'; fullpath += cu_die_name; - compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), cu, fullpath.c_str(), cu->GetOffset(), language)); + compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), cu, fullpath.c_str(), cu->GetOffset(), class_language)); } if (compile_unit_sp.get()) @@ -1211,6 +1211,8 @@ SymbolFileDWARF::ParseChildMembers TypeSP& type_sp, const DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die, + void *class_clang_type, + const LanguageType class_language, std::vector<clang::CXXBaseSpecifier *>& base_classes, std::vector<int>& member_accessibilities, ClangASTContext::AccessType& default_accessibility, @@ -1376,8 +1378,16 @@ SymbolFileDWARF::ParseChildMembers Type *base_class_dctype = ResolveTypeUID(encoding_uid); assert(base_class_dctype); - base_classes.push_back (type_list->GetClangASTContext().CreateBaseClassSpecifier (base_class_dctype->GetOpaqueClangQualType(), accessibility, is_virtual, is_base_of_class)); - assert(base_classes.back()); + + if (class_language == eLanguageTypeObjC) + { + type_list->GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_dctype->GetOpaqueClangQualType()); + } + else + { + base_classes.push_back (type_list->GetClangASTContext().CreateBaseClassSpecifier (base_class_dctype->GetOpaqueClangQualType(), accessibility, is_virtual, is_base_of_class)); + assert(base_classes.back()); + } } } break; @@ -2707,6 +2717,7 @@ SymbolFileDWARF::ParseType(const SymbolContext& sc, const DWARFCompileUnit* dwar const_cast<DWARFDebugInfoEntry*>(die)->SetUserData(DIE_IS_BEING_PARSED); size_t byte_size = 0; + LanguageType class_language = eLanguageTypeUnknown; //bool struct_is_class = false; Declaration decl; const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes); @@ -2721,16 +2732,39 @@ SymbolFileDWARF::ParseType(const SymbolContext& sc, const DWARFCompileUnit* dwar { switch (attr) { - case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; - case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; - case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; + case DW_AT_decl_file: + decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); + break; + + case DW_AT_decl_line: + decl.SetLine(form_value.Unsigned()); + break; + + case DW_AT_decl_column: + decl.SetColumn(form_value.Unsigned()); + break; + case DW_AT_name: type_name_cstr = form_value.AsCString(&get_debug_str_data()); type_name_dbstr.SetCString(type_name_cstr); break; - case DW_AT_byte_size: byte_size = form_value.Unsigned(); break; - case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; break; - case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break; + + case DW_AT_byte_size: + byte_size = form_value.Unsigned(); + break; + + case DW_AT_accessibility: + accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); + break; + + case DW_AT_declaration: + is_forward_declaration = form_value.Unsigned() != 0; + break; + + case DW_AT_APPLE_runtime_class: + class_language = (LanguageType)form_value.Signed(); + break; + case DW_AT_allocated: case DW_AT_associated: case DW_AT_data_location: @@ -2764,7 +2798,7 @@ SymbolFileDWARF::ParseType(const SymbolContext& sc, const DWARFCompileUnit* dwar } assert (tag_decl_kind != -1); - clang_type = type_list->GetClangASTContext().CreateRecordType (type_name_cstr, tag_decl_kind, GetClangDeclContextForDIE (dwarf_cu, die)); + clang_type = type_list->GetClangASTContext().CreateRecordType (type_name_cstr, tag_decl_kind, GetClangDeclContextForDIE (dwarf_cu, die), class_language); 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)); @@ -2781,11 +2815,24 @@ SymbolFileDWARF::ParseType(const SymbolContext& sc, const DWARFCompileUnit* dwar std::vector<clang::CXXBaseSpecifier *> base_classes; std::vector<int> member_accessibilities; bool is_a_class = false; - ParseChildMembers(sc, type_sp, dwarf_cu, die, base_classes, member_accessibilities, default_accessibility, is_a_class); + ParseChildMembers (sc, + type_sp, + dwarf_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 (is_a_class && tag_decl_kind != clang::TTK_Class) - type_list->GetClangASTContext().SetTagTypeKind (clang_type, clang::TTK_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 diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index a5acdd5dd40..7a9cd9cd42f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -249,6 +249,8 @@ protected: lldb::TypeSP& type_sp, const DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, + void *class_clang_type, + const lldb::LanguageType class_language, std::vector<clang::CXXBaseSpecifier *>& base_classes, std::vector<int>& member_accessibilities, lldb_private::ClangASTContext::AccessType &default_accessibility, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 9da672f948b..e760329034d 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -495,7 +495,7 @@ SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx) NULL, so_symbol->GetMangled().GetName().AsCString(), cu_idx, - Language::Unknown)); + eLanguageTypeUnknown)); } } } diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp index ff7b8bf742a..a6d58f60555 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -140,14 +140,14 @@ SymbolFileSymtab::ParseCompileUnitAtIndex(uint32_t idx) { const FileSpec &obj_file_spec = m_obj_file->GetFileSpec(); if (obj_file_spec) - cu_sp.reset(new CompileUnit(m_obj_file->GetModule(), NULL, obj_file_spec, 0, Language::Unknown)); + cu_sp.reset(new CompileUnit(m_obj_file->GetModule(), NULL, obj_file_spec, 0, eLanguageTypeUnknown)); } else if (idx < m_source_indexes.size()) { const Symbol *cu_symbol = m_obj_file->GetSymtab()->SymbolAtIndex(m_source_indexes[idx]); if (cu_symbol) - cu_sp.reset(new CompileUnit(m_obj_file->GetModule(), NULL, cu_symbol->GetMangled().GetName().AsCString(), 0, Language::Unknown)); + cu_sp.reset(new CompileUnit(m_obj_file->GetModule(), NULL, cu_symbol->GetMangled().GetName().AsCString(), 0, eLanguageTypeUnknown)); } return cu_sp; } |

