diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 37fb16d4e0351..fc340da8eba07 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2150,14 +2150,14 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, std::vector> bases; // Parse members and base classes first - std::vector member_function_dies; + std::vector member_function_and_type_dies; DelayedPropertyList delayed_properties; - ParseChildMembers(die, clang_type, bases, member_function_dies, + ParseChildMembers(die, clang_type, bases, member_function_and_type_dies, delayed_properties, default_accessibility, layout_info); - // Now parse any methods if there were any... - for (const DWARFDIE &die : member_function_dies) + // Now parse any methods or nested types if there were any... + for (const DWARFDIE &die : member_function_and_type_dies) dwarf->ResolveType(die); if (type_is_objc_object_or_interface) { @@ -3153,7 +3153,7 @@ void DWARFASTParserClang::ParseSingleMember( bool DWARFASTParserClang::ParseChildMembers( const DWARFDIE &parent_die, CompilerType &class_clang_type, std::vector> &base_classes, - std::vector &member_function_dies, + std::vector &member_function_and_type_dies, DelayedPropertyList &delayed_properties, const AccessType default_accessibility, ClangASTImporter::LayoutInfo &layout_info) { @@ -3189,8 +3189,11 @@ bool DWARFASTParserClang::ParseChildMembers( break; case DW_TAG_subprogram: + case DW_TAG_enumeration_type: + case DW_TAG_structure_type: + case DW_TAG_union_type: // Let the type parsing code handle this one for us. - member_function_dies.push_back(die); + member_function_and_type_dies.push_back(die); break; case DW_TAG_inheritance: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h index 88bfc490e8907..d4218959e61a8 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h @@ -157,7 +157,7 @@ class DWARFASTParserClang : public DWARFASTParser { bool ParseChildMembers( const DWARFDIE &die, lldb_private::CompilerType &class_compiler_type, std::vector> &base_classes, - std::vector &member_function_dies, + std::vector &member_function_and_type_dies, DelayedPropertyList &delayed_properties, const lldb::AccessType default_accessibility, lldb_private::ClangASTImporter::LayoutInfo &layout_info); diff --git a/lldb/test/API/lang/cpp/nested-type/Makefile b/lldb/test/API/lang/cpp/nested-type/Makefile new file mode 100644 index 0000000000000..99998b20bcb05 --- /dev/null +++ b/lldb/test/API/lang/cpp/nested-type/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/nested-type/TestNestedType.py b/lldb/test/API/lang/cpp/nested-type/TestNestedType.py new file mode 100644 index 0000000000000..7aafda001a4eb --- /dev/null +++ b/lldb/test/API/lang/cpp/nested-type/TestNestedType.py @@ -0,0 +1,33 @@ +""" +Test that nested types are parsed +""" +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + + +class CPPNestedTypeTestCase(TestBase): + def test_with_run_command(self): + """Test that nested types work in the expression evaluator""" + self.build() + lldbutil.run_to_source_breakpoint( + self, "// breakpoint 1", lldb.SBFileSpec("main.cpp") + ) + + self.expect_expr( + "(int)PointerIntPairInfo::MaskAndShiftConstants::PointerBitMask", + result_type="int", + result_value="42", + ) + + self.expect_expr( + "sizeof(PointerIntPairInfo::B)", + result_type="unsigned long", + result_value="1", + ) + + self.expect_expr( + "sizeof(PointerIntPairInfo::C)", + result_type="unsigned long", + result_value="1", + ) diff --git a/lldb/test/API/lang/cpp/nested-type/main.cpp b/lldb/test/API/lang/cpp/nested-type/main.cpp new file mode 100644 index 0000000000000..8ee06aac05454 --- /dev/null +++ b/lldb/test/API/lang/cpp/nested-type/main.cpp @@ -0,0 +1,23 @@ +struct PointerIntPairInfo { + enum MaskAndShiftConstants : unsigned long { + PointerBitMask = 42, + }; + + union B {}; + B b; + + struct C {}; + C c; + + int a{}; +}; + +static unsigned long foo() { + return PointerIntPairInfo::PointerBitMask; +} + +int main() +{ + PointerIntPairInfo p; + return p.a + foo(); // breakpoint 1 +} \ No newline at end of file