summaryrefslogtreecommitdiff
path: root/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/main.cpp
blob: ee77a880a0c5da806a092174a891d1b890252e21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <atomic>

// Define a Parent and Child struct that can point to each other.
class Parent;
struct Child {
  // This should point to the parent which in turn owns this
  // child instance. This cycle should not cause LLDB to infinite loop
  // during printing.
  std::atomic<Parent *> parent{nullptr};
};
struct Parent {
  Child child;
};

struct S {
  int x = 1;
  int y = 2;
};

int main() {
  std::atomic<S> s;
  s.store(S());
  std::atomic<int> i;
  i.store(5);

  Parent p;
  // Let the child node know what its parent is.
  p.child.parent = &p;

  return 0; // Set break point at this line.
}