xref: /llvm-project/cross-project-tests/debuginfo-tests/llgdb-tests/sret.cpp (revision 5257efdc5b30212b62a9d68857dc8e66d0e1a863)
1 // RUN: %clangxx %target_itanium_abi_host_triple -O0 -g %s -c -o %t.o
2 // RUN: %clangxx %target_itanium_abi_host_triple %t.o -o %t.out
3 // RUN: %test_debuginfo %s %t.out
4 // XFAIL: !system-darwin && gdb-clang-incompatibility
5 // Radar 8775834
6 // DEBUGGER: break 63
7 // DEBUGGER: r
8 // DEBUGGER: p a
9 // CHECK: ${{[0-9]+}} =
10 // LLDB does not print artificial members.
11 // CHECK:  {{(_vptr\$A =)?.*}}m_int = 12
12 
13 class A
14 {
15 public:
16     A (int i=0);
17     A (const A& rhs);
18     const A&
19     operator= (const A& rhs);
~A()20     virtual ~A() {}
21 
22     int get_int();
23 
24 protected:
25     int m_int;
26 };
27 
A(int i)28 A::A (int i) :
29     m_int(i)
30 {
31 }
32 
A(const A & rhs)33 A::A (const A& rhs) :
34     m_int (rhs.m_int)
35 {
36 }
37 
38 const A &
operator =(const A & rhs)39 A::operator =(const A& rhs)
40 {
41     m_int = rhs.m_int;
42     return *this;
43 }
44 
get_int()45 int A::get_int()
46 {
47     return m_int;
48 }
49 
50 class B
51 {
52 public:
B()53     B () {}
54 
55     A AInstance();
56 };
57 
58 A
AInstance()59 B::AInstance()
60 {
61     A a(12);
62     return a;
63 }
64 
main(int argc,char const * argv[])65 int main (int argc, char const *argv[])
66 {
67     B b;
68     int return_val = b.AInstance().get_int();
69 
70     A a(b.AInstance());
71     return return_val;
72 }
73