summaryrefslogtreecommitdiff
path: root/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/MyOptional.cpp
blob: abba34439d88f44982fe8616083915e382d8fd58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// A bare-bones llvm::Optional reimplementation.

template <typename T> struct MyOptionalStorage {
  MyOptionalStorage(T val) : value(val), hasVal(true) {}
  MyOptionalStorage() {}
  T value;
  bool hasVal = false;
};

template <typename T> struct MyOptional {
  MyOptionalStorage<T> Storage;
  MyOptional(T val) : Storage(val) {}
  MyOptional() {}
  T &operator*() { return Storage.value; }
};

void stop() {}

int main(int argc, char **argv) {
  MyOptional<int> x, y = 42;
  stop(); // break here
  return *y;
}