199451b44SJordan Rupprecht"""
299451b44SJordan RupprechtTest that the expression evaluator can access members of nested classes even if
399451b44SJordan Rupprechtthe parents of the nested classes were imported from another compilation unit.
499451b44SJordan Rupprecht"""
599451b44SJordan Rupprechtimport lldb
699451b44SJordan Rupprechtfrom lldbsuite.test.decorators import *
799451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import *
899451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil
999451b44SJordan Rupprecht
1099451b44SJordan Rupprecht
1199451b44SJordan Rupprechtclass TestNestedClassWithParentInAnotherCU(TestBase):
1299451b44SJordan Rupprecht    def test_nested_class_with_parent_in_another_cu(self):
1399451b44SJordan Rupprecht        self.main_source_file = lldb.SBFileSpec("main.cpp")
1499451b44SJordan Rupprecht        self.build()
15*2238dcc3SJonas Devlieghere        (_, _, thread, _) = lldbutil.run_to_source_breakpoint(
16*2238dcc3SJonas Devlieghere            self, "// break here", self.main_source_file
17*2238dcc3SJonas Devlieghere        )
1899451b44SJordan Rupprecht        frame = thread.GetSelectedFrame()
1999451b44SJordan Rupprecht        # Parse the DIEs of the parent classes and the nested classes from
2099451b44SJordan Rupprecht        # other.cpp's CU.
2199451b44SJordan Rupprecht        warmup_result = frame.EvaluateExpression("b")
2299451b44SJordan Rupprecht        self.assertTrue(warmup_result.IsValid())
2399451b44SJordan Rupprecht        # Inspect fields of the nested classes. This will reuse the types that
2499451b44SJordan Rupprecht        # were parsed during the evaluation above. By accessing a chain of
2599451b44SJordan Rupprecht        # fields, we try to verify that all the DIEs, reused types and
2699451b44SJordan Rupprecht        # declaration contexts were wired properly into lldb's parser's state.
2799451b44SJordan Rupprecht        expr_result = frame.EvaluateExpression("a.y.oY_inner.oX_inner")
2899451b44SJordan Rupprecht        self.assertTrue(expr_result.IsValid())
2999451b44SJordan Rupprecht        self.assertEqual(expr_result.GetValue(), "42")
30