xref: /llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp (revision fdea9a4ec9b0d9585b8fe8a612686d9f44f40ddc)
1 #include <atomic>
2 
3 // Define a Parent and Child struct that can point to each other.
4 class Parent;
5 struct Child {
6   // This should point to the parent which in turn owns this
7   // child instance. This cycle should not cause LLDB to infinite loop
8   // during printing.
9   std::atomic<Parent*> parent{nullptr};
10 };
11 struct Parent {
12   Child child;
13 };
14 
15 struct S {
16     int x = 1;
17     int y = 2;
18 };
19 
main()20 int main ()
21 {
22     std::atomic<S> s;
23     s.store(S());
24     std::atomic<int> i;
25     i.store(5);
26 
27     Parent p;
28     // Let the child node know what its parent is.
29     p.child.parent = &p;
30 
31     return 0; // Set break point at this line.
32 }
33 
34