xref: /llvm-project/lldb/test/API/lang/cpp/offsetof/main.cpp (revision 99451b4453688a94c6014cac233d371ab4cc342d)
1 #include <cstdint>
2 
3 class Base {
4   int32_t a;
5 };
6 class Class1 : Base {
7 public:
8   int32_t b;
9 };
10 
11 class EmptyBase {
12 };
13 class Class2 : EmptyBase {
14 public:
15   int32_t b;
16 };
17 
main(int argc,char ** argv)18 int main(int argc, char **argv) {
19   Class1 c1;
20   Class2 c2;
21   //% self.expect("expr offsetof(Base, a)", substrs=["= 0"])
22   //% self.expect("expr offsetof(Class1, b)", substrs=["= 4"])
23   //% self.expect("expr offsetof(Class2, b)", substrs=["= 0"])
24   return c1.b + c2.b;
25 }
26