Files
clang-p2996/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/MyOptional.cpp
Adrian Prantl fffe8c6684 [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to examples
This PR adds a proof-of-concept for a bytecode designed to ship and
run LLDB data formatters. More motivation and context can be found in
the formatter-bytecode.rst file and on discourse.

https://discourse.llvm.org/t/a-bytecode-for-lldb-data-formatters/82696

Relanding with a fix for a case-sensitive path.
2024-12-06 16:27:16 -08:00

24 lines
514 B
C++

// 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;
}