xref: /llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-cpp/main.cpp (revision 554f79e050cb240d00e239ee4ca8d6aefdfa737d)
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         virtual void virt_member_func() {}
63 };
64 
65 int main (int argc, const char * argv[])
66 {
67 
68     int iAmInt = 1;
69     const float& IAmFloat = float(2.45);
70 
71     RealNumber RNILookChar = 3.14;
72     Temperature TMILookFloat = 4.97;
73     Speed SPILookHex = 5.55;
74 
75     Counter CTILookInt = 6;
76     BitField BFILookHex = 7;
77     SignalMask SMILookHex = 8;
78     Modifiers MFILookHex = 9;
79 
80     Accumulator* ACILookInt = new Accumulator(10);
81 
82     const Type1& T1ILookChar = 11;
83     Type2 T2ILookHex = 12;
84     Type3 T3ILookChar = 13;
85     Type4 T4ILookChar = 14;
86 
87     AnotherChildType AHILookInt = 15;
88 
89     Speed* SPPtrILookHex = new Speed(16);
90 
91     TestPoint iAmSomewhere(4,6);
92 
93 	i_am_cool *cool_pointer = (i_am_cool*)malloc(sizeof(i_am_cool)*3);
94 	cool_pointer[0] = i_am_cool(3,-3.141592,'E');
95 	cool_pointer[1] = i_am_cool(0,-3.141592,'E');
96 	cool_pointer[2] = i_am_cool(0,-3.141592,'E');
97 
98     i_am_cool cool_array[5];
99 
100     cool_array[3].floating = 5.25;
101     cool_array[4].integer = 6;
102     cool_array[2].character = 'Q';
103 
104     int int_array[] = {1,2,3,4,5};
105 
106     IUseCharStar iEncapsulateCharStar;
107 
108     char  strarr[32] = "Hello world!";
109     char* strptr     = "Hello world!";
110 
111     i_am_cooler the_coolest_guy(1,2,3.14,6.28,'E','G');
112 
113     const char *IUseCharStar::*member_ptr = &IUseCharStar::pointer;
114     const char *(IUseCharStar::*member_func_ptr)(int) =
115         &IUseCharStar::member_func;
116     auto &ref_to_member_func_ptr = member_func_ptr;
117 
118     void (IUseCharStar::*virt_member_func_ptr)() =
119         &IUseCharStar::virt_member_func;
120 
121     return 0; // Set break point at this line.
122 }
123 
124