[lldb] Make SBType::FindDirectNestedType work with expression ASTs (#89183)
The types we get out of expressions will not have an associated symbol file, so the current method of looking up the type will fail. Instead, I plumb the query through the TypeSystem class. This correctly finds the type in both cases (importing it into the expression AST if needed). I haven't measured, but it should also be more efficient than doing a type lookup (at least, after the type has already been found once).
This commit is contained in:
@@ -18,6 +18,21 @@ class TypeAndTypeListTestCase(TestBase):
|
||||
self.source = "main.cpp"
|
||||
self.line = line_number(self.source, "// Break at this line")
|
||||
|
||||
def _find_nested_type_in_Task_pointer(self, pointer_type):
|
||||
self.assertTrue(pointer_type)
|
||||
self.DebugSBType(pointer_type)
|
||||
pointer_info_type = pointer_type.template_args[1]
|
||||
self.assertTrue(pointer_info_type)
|
||||
self.DebugSBType(pointer_info_type)
|
||||
|
||||
pointer_masks1_type = pointer_info_type.FindDirectNestedType("Masks1")
|
||||
self.assertTrue(pointer_masks1_type)
|
||||
self.DebugSBType(pointer_masks1_type)
|
||||
|
||||
pointer_masks2_type = pointer_info_type.FindDirectNestedType("Masks2")
|
||||
self.assertTrue(pointer_masks2_type)
|
||||
self.DebugSBType(pointer_masks2_type)
|
||||
|
||||
@skipIf(compiler="clang", compiler_version=["<", "17.0"])
|
||||
def test(self):
|
||||
"""Exercise SBType and SBTypeList API."""
|
||||
@@ -151,22 +166,12 @@ class TypeAndTypeListTestCase(TestBase):
|
||||
invalid_type = task_type.FindDirectNestedType(None)
|
||||
self.assertFalse(invalid_type)
|
||||
|
||||
# Check that FindDirectNestedType works with types from AST
|
||||
pointer = frame0.FindVariable("pointer")
|
||||
pointer_type = pointer.GetType()
|
||||
self.assertTrue(pointer_type)
|
||||
self.DebugSBType(pointer_type)
|
||||
pointer_info_type = pointer_type.template_args[1]
|
||||
self.assertTrue(pointer_info_type)
|
||||
self.DebugSBType(pointer_info_type)
|
||||
|
||||
pointer_masks1_type = pointer_info_type.FindDirectNestedType("Masks1")
|
||||
self.assertTrue(pointer_masks1_type)
|
||||
self.DebugSBType(pointer_masks1_type)
|
||||
|
||||
pointer_masks2_type = pointer_info_type.FindDirectNestedType("Masks2")
|
||||
self.assertTrue(pointer_masks2_type)
|
||||
self.DebugSBType(pointer_masks2_type)
|
||||
# Check that FindDirectNestedType works with types from module and
|
||||
# expression ASTs.
|
||||
self._find_nested_type_in_Task_pointer(frame0.FindVariable("pointer").GetType())
|
||||
self._find_nested_type_in_Task_pointer(
|
||||
frame0.EvaluateExpression("pointer").GetType()
|
||||
)
|
||||
|
||||
# We'll now get the child member 'id' from 'task_head'.
|
||||
id = task_head.GetChildMemberWithName("id")
|
||||
|
||||
Reference in New Issue
Block a user