https://github.com/labath updated https://github.com/llvm/llvm-project/pull/207743
>From 9b9d265b055246a6d4d6e6a63786d557f86c674b Mon Sep 17 00:00:00 2001 From: Pavel Labath <[email protected]> Date: Wed, 8 Jul 2026 10:12:52 +0200 Subject: [PATCH 1/2] [lldb] Make SBType::FindDirectNestedType work with dynamic types This makes it possible to find the nested type just by knowing the dynamic type of the value. To get the previous behavior, get the type from a static view of the value (SBValue::GetStaticValue). --- lldb/source/Symbol/Type.cpp | 2 +- lldb/test/API/python_api/type/TestTypeList.py | 24 +++++++++++++++++++ lldb/test/API/python_api/type/main.cpp | 11 +++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp index 7681d7065a522..9b62018bbd3d8 100644 --- a/lldb/source/Symbol/Type.cpp +++ b/lldb/source/Symbol/Type.cpp @@ -1215,7 +1215,7 @@ bool TypeImpl::GetDescription(lldb_private::Stream &strm, CompilerType TypeImpl::FindDirectNestedType(llvm::StringRef name) { if (name.empty()) return CompilerType(); - return GetCompilerType(/*prefer_dynamic=*/false) + return GetCompilerType(/*prefer_dynamic=*/true) .GetDirectNestedTypeWithName(name); } diff --git a/lldb/test/API/python_api/type/TestTypeList.py b/lldb/test/API/python_api/type/TestTypeList.py index e4dc810169089..2c7abfe680ad2 100644 --- a/lldb/test/API/python_api/type/TestTypeList.py +++ b/lldb/test/API/python_api/type/TestTypeList.py @@ -300,6 +300,30 @@ def test_nested_typedef(self): self.assertTrue(the_typedef) self.assertEqual(the_typedef.GetTypedefedType().GetName(), "int") + @expectedFailureWindows # Dynamic type resolution not implemented + def test_dynamic_values(self): + """Test FindDirectNestedType on dynamic values""" + + self.build() + lldbutil.run_to_line_breakpoint(self, lldb.SBFileSpec(self.source), self.line) + polymorphic = ( + self.frame() + .FindVariable("polymorphic") + .GetDynamicValue(lldb.eDynamicDontRunTarget) + ) + self.DebugSBValue(polymorphic) + polymorphic_type = polymorphic.GetType().GetPointeeType() + self.DebugSBType(polymorphic_type) + nested = polymorphic_type.FindDirectNestedType("Nested") + self.DebugSBType(nested) + self.assertEqual(nested.GetName(), "PolymorphicDerived::Nested") + + static = polymorphic.GetStaticValue() + self.DebugSBValue(static) + static_type = static.GetType().GetPointeeType() + self.DebugSBType(static_type) + self.assertFalse(static_type.FindDirectNestedType("Nested")) + def test_GetByteAlign(self): """Exercise SBType::GetByteAlign""" self.build() diff --git a/lldb/test/API/python_api/type/main.cpp b/lldb/test/API/python_api/type/main.cpp index 449f77db0d75e..3d31790be05ee 100644 --- a/lldb/test/API/python_api/type/main.cpp +++ b/lldb/test/API/python_api/type/main.cpp @@ -63,6 +63,15 @@ struct WithNestedTypedef { }; WithNestedTypedef::TheTypedef typedefed_value; +struct PolymorphicBase { + virtual void foo() {} +}; + +struct PolymorphicDerived : PolymorphicBase { + struct Nested {}; + Nested get() { return {}; } +}; + int main (int argc, char const *argv[]) { Task *task_head = new Task(-1, NULL); @@ -100,5 +109,7 @@ int main (int argc, char const *argv[]) PointerInfo<3>::Masks1 mask1 = PointerInfo<3>::Masks1::pointer_mask; PointerInfo<3>::Masks2 mask2 = PointerInfo<3>::Masks2::pointer_mask; + PolymorphicBase *polymorphic = new PolymorphicDerived(); + return 0; // Break at this line } >From ea6099db5c8bd6de2678e302199c7f23a53c82c9 Mon Sep 17 00:00:00 2001 From: Pavel Labath <[email protected]> Date: Wed, 8 Jul 2026 12:12:58 +0200 Subject: [PATCH 2/2] beef up the test --- lldb/test/API/python_api/type/TestTypeList.py | 6 +++++- lldb/test/API/python_api/type/main.cpp | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/python_api/type/TestTypeList.py b/lldb/test/API/python_api/type/TestTypeList.py index 2c7abfe680ad2..ff9690794d1b3 100644 --- a/lldb/test/API/python_api/type/TestTypeList.py +++ b/lldb/test/API/python_api/type/TestTypeList.py @@ -317,12 +317,16 @@ def test_dynamic_values(self): nested = polymorphic_type.FindDirectNestedType("Nested") self.DebugSBType(nested) self.assertEqual(nested.GetName(), "PolymorphicDerived::Nested") + self.assertEqual(nested.GetTypedefedType().GetName(), "float") static = polymorphic.GetStaticValue() self.DebugSBValue(static) static_type = static.GetType().GetPointeeType() self.DebugSBType(static_type) - self.assertFalse(static_type.FindDirectNestedType("Nested")) + nested = static_type.FindDirectNestedType("Nested") + self.DebugSBType(nested) + self.assertEqual(nested.GetName(), "PolymorphicBase::Nested") + self.assertEqual(nested.GetTypedefedType().GetName(), "int") def test_GetByteAlign(self): """Exercise SBType::GetByteAlign""" diff --git a/lldb/test/API/python_api/type/main.cpp b/lldb/test/API/python_api/type/main.cpp index 3d31790be05ee..9de1988ec7efc 100644 --- a/lldb/test/API/python_api/type/main.cpp +++ b/lldb/test/API/python_api/type/main.cpp @@ -64,11 +64,13 @@ struct WithNestedTypedef { WithNestedTypedef::TheTypedef typedefed_value; struct PolymorphicBase { + using Nested = int; + Nested get() { return {}; } virtual void foo() {} }; struct PolymorphicDerived : PolymorphicBase { - struct Nested {}; + using Nested = float; Nested get() { return {}; } }; _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
