diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -2616,9 +2616,27 @@ case DW_TAG_structure_type: case DW_TAG_union_type: case DW_TAG_class_type: - case DW_TAG_lexical_block: case DW_TAG_subprogram: return die; + case DW_TAG_lexical_block: { + if (orig_die.Tag() != DW_TAG_structure_type && + orig_die.Tag() != DW_TAG_union_type && + orig_die.Tag() != DW_TAG_class_type && + orig_die.Tag() != DW_TAG_enumeration_type && + orig_die.Tag() != DW_TAG_typedef) + return die; + // Make local type's context to be a subprogram. + // FIXME: DWARFASTParserClang doesn't properly support type-like + // entities scoped within a lexical block. This workaround makes + // it possible to correctly display variables that have such a type, + // but lldb still isn't able to handle properly handle more than one + // local type with the same name. + while (true) { + die = die.GetParent(); + if (die.Tag() == DW_TAG_subprogram) + return die; + } + } case DW_TAG_inlined_subroutine: { DWARFDIE abs_die = die.GetReferencedDIE(DW_AT_abstract_origin); if (abs_die) {