diff options
| author | Pavel Labath <pavel@labath.sk> | 2024-04-19 14:16:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-19 14:16:09 +0200 |
| commit | e7c042f12fd6f3bbbbe9aeb37854d499aada8457 (patch) | |
| tree | 9bd405f89d6c3669aaf6df775803c10588f44095 /lldb/test/API/python_api | |
| parent | 7e2c2981fbb9e609886cfbe6c95644ed58b03d08 (diff) | |
| download | llvm-e7c042f12fd6f3bbbbe9aeb37854d499aada8457.zip llvm-e7c042f12fd6f3bbbbe9aeb37854d499aada8457.tar.gz llvm-e7c042f12fd6f3bbbbe9aeb37854d499aada8457.tar.bz2 | |
[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).
Diffstat (limited to 'lldb/test/API/python_api')
| -rw-r--r-- | lldb/test/API/python_api/type/TestTypeList.py | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/lldb/test/API/python_api/type/TestTypeList.py b/lldb/test/API/python_api/type/TestTypeList.py index eba5e17..09c1dee 100644 --- a/lldb/test/API/python_api/type/TestTypeList.py +++ b/lldb/test/API/python_api/type/TestTypeList.py @@ -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") |
