xref: /llvm-project/lldb/test/API/commands/expression/context-object/main.cpp (revision 6a85b9d16387ddd7c356336c8a77ba6b88f9a610)
1 namespace cpp_namespace {
2   struct CppStruct {
3     int field = 1111;
4 
functioncpp_namespace::CppStruct5     int function() {
6       return 2222;
7     }
8   };
9 
10   union CppUnion {
11     char field_char;
12     short field_short;
13     int field_int;
14   };
15 
GetCppStruct()16   CppStruct GetCppStruct() {
17     return CppStruct();
18   }
19 
20   CppStruct global;
21 
GetCppStructPtr()22   CppStruct *GetCppStructPtr() {
23     return &global;
24   }
25 }
26 
27 int global = 3333;
28 
main()29 int main()
30 {
31   cpp_namespace::CppStruct cpp_struct = cpp_namespace::GetCppStruct();
32   cpp_struct.function();
33 
34   cpp_namespace::CppStruct &cpp_struct_ref = cpp_struct;
35   cpp_struct_ref.function();
36 
37   int field = 4444;
38 
39   cpp_namespace::CppUnion cpp_union;
40   cpp_union.field_int = 5555;
41 
42   int cpp_scalar = 6666;
43 
44   cpp_namespace::CppStruct cpp_array[16];
45 
46   cpp_namespace::CppStruct *cpp_pointer = cpp_namespace::GetCppStructPtr();
47 
48   return 0; // Break here
49 }
50