1*cda1450fSRaphael Isemannimport lldb
2*cda1450fSRaphael Isemannfrom lldbsuite.test.decorators import *
3*cda1450fSRaphael Isemannfrom lldbsuite.test.lldbtest import *
4*cda1450fSRaphael Isemannfrom lldbsuite.test import lldbutil
5*cda1450fSRaphael Isemann
6*cda1450fSRaphael Isemannclass TestCase(TestBase):
7*cda1450fSRaphael Isemann
8*cda1450fSRaphael Isemann    @no_debug_info_test
9*cda1450fSRaphael Isemann    def test(self):
10*cda1450fSRaphael Isemann        self.build()
11*cda1450fSRaphael Isemann        lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
12*cda1450fSRaphael Isemann
13*cda1450fSRaphael Isemann        m_val = self.expect_expr("m", result_type="WithMember", result_children=[
14*cda1450fSRaphael Isemann            ValueCheck(name="i", value="1")
15*cda1450fSRaphael Isemann        ])
16*cda1450fSRaphael Isemann        # FIXME: The non-display name doesn't include the function, so users
17*cda1450fSRaphael Isemann        # can't actually match specific classes by their name. Either document
18*cda1450fSRaphael Isemann        # or fix this.
19*cda1450fSRaphael Isemann        self.assertEqual(m_val.GetType().GetName(), "WithMember")
20*cda1450fSRaphael Isemann        # Try accessing the type in the expression evaluator.
21*cda1450fSRaphael Isemann        self.expect_expr("m.i", result_type="int", result_value="1")
22*cda1450fSRaphael Isemann
23*cda1450fSRaphael Isemann        self.expect_expr("typedef_unnamed", result_type="TypedefUnnamed", result_children=[
24*cda1450fSRaphael Isemann            ValueCheck(name="a", value="2")
25*cda1450fSRaphael Isemann        ])
26*cda1450fSRaphael Isemann        self.expect_expr("typedef_unnamed2", result_type="TypedefUnnamed2", result_children=[
27*cda1450fSRaphael Isemann            ValueCheck(name="b", value="3")
28*cda1450fSRaphael Isemann        ])
29*cda1450fSRaphael Isemann        self.expect_expr("unnamed", result_type="(unnamed struct)", result_children=[
30*cda1450fSRaphael Isemann            ValueCheck(name="i", value="4")
31*cda1450fSRaphael Isemann        ])
32*cda1450fSRaphael Isemann        self.expect_expr("unnamed2", result_type="(unnamed struct)", result_children=[
33*cda1450fSRaphael Isemann            ValueCheck(name="j", value="5")
34*cda1450fSRaphael Isemann        ])
35*cda1450fSRaphael Isemann
36*cda1450fSRaphael Isemann        # Try a class that is only forward declared.
37*cda1450fSRaphael Isemann        self.expect_expr("fwd", result_type="Forward *")
38*cda1450fSRaphael Isemann        self.expect("expression -- fwd->i", error=True, substrs=[
39*cda1450fSRaphael Isemann            "member access into incomplete type 'Forward'"
40*cda1450fSRaphael Isemann        ])
41*cda1450fSRaphael Isemann        self.expect("expression -- *fwd", error=True, substrs=[
42*cda1450fSRaphael Isemann            "incomplete type 'Forward' where a complete type is required"
43*cda1450fSRaphael Isemann        ])
44*cda1450fSRaphael Isemann
45*cda1450fSRaphael Isemann        # Try a class that has a name that matches a class in the global scope.
46*cda1450fSRaphael Isemann        self.expect_expr("fwd_conflict", result_type="ForwardConflict *")
47*cda1450fSRaphael Isemann        # FIXME: This pulls in the unrelated type with the same name from the
48*cda1450fSRaphael Isemann        # global scope.
49*cda1450fSRaphael Isemann        self.expect("expression -- fwd_conflict->i", error=True, substrs=[
50*cda1450fSRaphael Isemann            # This should point out that ForwardConflict is incomplete.
51*cda1450fSRaphael Isemann            "no member named 'i' in 'ForwardConflict'"
52*cda1450fSRaphael Isemann        ])
53*cda1450fSRaphael Isemann        self.expect("expression -- *fwd_conflict", error=True, substrs=[
54*cda1450fSRaphael Isemann            # This should fail to parse instead.
55*cda1450fSRaphael Isemann            "couldn't read its memory"
56*cda1450fSRaphael Isemann        ])
57