xref: /llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-cpp/main.cpp (revision b642fd5ee250247ccefb38099169b4ee8ac4112b)
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdint.h>
4 
5 typedef float RealNumber; // should show as char
6 typedef RealNumber Temperature; // should show as float
7 typedef RealNumber Speed; // should show as hex
8 
9 typedef int Counter; // should show as int
10 typedef int BitField; // should show as hex
11 
12 typedef BitField SignalMask; // should show as hex
13 typedef BitField Modifiers; // should show as hex
14 
15 typedef Counter Accumulator; // should show as int
16 
17 typedef int Type1; // should show as char
18 typedef Type1 Type2; // should show as hex
19 typedef Type2 Type3; // should show as char
20 typedef Type3 Type4; // should show as char
21 
22 typedef int ChildType; // should show as int
23 typedef int AnotherChildType; // should show as int
24 
25 struct TestPoint {
26     int x;
27     int y;
28     TestPoint(int X = 3, int Y = 2) : x(X), y(Y) {}
29 };
30 
31 typedef float ShowMyGuts;
32 
33 struct i_am_cool
34 {
35 	int integer;
36 	ShowMyGuts floating;
37 	char character;
38 	i_am_cool(int I, ShowMyGuts F, char C) :
39     integer(I), floating(F), character(C) {}
40 	i_am_cool() : integer(1), floating(2), character('3') {}
41 
42 };
43 
44 struct i_am_cooler
45 {
46 	i_am_cool first_cool;
47 	i_am_cool second_cool;
48 	ShowMyGuts floating;
49 
50 	i_am_cooler(int I1, int I2, float F1, float F2, char C1, char C2) :
51     first_cool(I1,F1,C1),
52     second_cool(I2,F2,C2),
53     floating((F1 + F2)/2) {}
54 };
55 
56 struct IUseCharStar
57 {
58 	const char* pointer;
59 	IUseCharStar() : pointer("Hello world") {}
60 
61         char const *member_func(int) { return ""; }
62 };
63 
64 int main (int argc, const char * argv[])
65 {
66 
67     int iAmInt = 1;
68     const float& IAmFloat = float(2.45);
69 
70     RealNumber RNILookChar = 3.14;
71     Temperature TMILookFloat = 4.97;
72     Speed SPILookHex = 5.55;
73 
74     Counter CTILookInt = 6;
75     BitField BFILookHex = 7;
76     SignalMask SMILookHex = 8;
77     Modifiers MFILookHex = 9;
78 
79     Accumulator* ACILookInt = new Accumulator(10);
80 
81     const Type1& T1ILookChar = 11;
82     Type2 T2ILookHex = 12;
83     Type3 T3ILookChar = 13;
84     Type4 T4ILookChar = 14;
85 
86     AnotherChildType AHILookInt = 15;
87 
88     Speed* SPPtrILookHex = new Speed(16);
89 
90     TestPoint iAmSomewhere(4,6);
91 
92 	i_am_cool *cool_pointer = (i_am_cool*)malloc(sizeof(i_am_cool)*3);
93 	cool_pointer[0] = i_am_cool(3,-3.141592,'E');
94 	cool_pointer[1] = i_am_cool(0,-3.141592,'E');
95 	cool_pointer[2] = i_am_cool(0,-3.141592,'E');
96 
97     i_am_cool cool_array[5];
98 
99     cool_array[3].floating = 5.25;
100     cool_array[4].integer = 6;
101     cool_array[2].character = 'Q';
102 
103     int int_array[] = {1,2,3,4,5};
104 
105     IUseCharStar iEncapsulateCharStar;
106 
107     char  strarr[32] = "Hello world!";
108     char* strptr     = "Hello world!";
109 
110     i_am_cooler the_coolest_guy(1,2,3.14,6.28,'E','G');
111 
112     const char *IUseCharStar::*member_ptr = &IUseCharStar::pointer;
113     const char *(IUseCharStar::*member_func_ptr)(int) =
114         &IUseCharStar::member_func;
115     auto &ref_to_member_func_ptr = member_func_ptr;
116 
117     return 0; // Set break point at this line.
118 }
119 
120