1struct Empty {};
2class EmptyClass {};
3class alignas(4) EmptyClassAligned {};
4class ClassEmptyMember {
5 int i[0];
6};
7
8struct SingleMember {
9 int i;
10};
11class SingleMemberClass {
12 int i;
13};
14
15struct PaddingMember {
16 int i;
17 char c;
18};
19class PaddingMemberClass {
20 int i;
21 char c;
22};
23
24const unsigned sizeof_empty = sizeof(Empty);
25const unsigned sizeof_empty_class = sizeof(EmptyClass);
26const unsigned sizeof_empty_class_aligned = sizeof(EmptyClassAligned);
27const unsigned sizeof_class_empty_member = sizeof(ClassEmptyMember);
28const unsigned sizeof_single = sizeof(SingleMember);
29const unsigned sizeof_single_class = sizeof(SingleMemberClass);
30const unsigned sizeof_padding = sizeof(PaddingMember);
31const unsigned sizeof_padding_class = sizeof(PaddingMemberClass);
32
33int main() {
34 Empty empty;
35 EmptyClass empty_class;
36 EmptyClassAligned empty_class_aligned;
37 ClassEmptyMember class_empty_member;
38 SingleMember single;
39 SingleMemberClass single_class;
40 PaddingMember padding;
41 PaddingMemberClass padding_class;
42 // Make sure globals are used.
43 return sizeof_empty + sizeof_empty_class + sizeof_class_empty_member +
44 sizeof_single + +sizeof_empty_class_aligned + sizeof_single_class +
45 sizeof_padding + sizeof_padding_class;
46}
47

source code of lldb/test/API/lang/cpp/sizeof/main.cpp