diff options
| author | Adrian Prantl <aprantl@apple.com> | 2024-10-22 16:29:50 -0700 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2024-12-06 16:10:09 -0800 |
| commit | 60380cd27c6fa5ed6e39866c51b18a64bc4d566a (patch) | |
| tree | 2e48ac26ffbe471726649518d4a048ed6a437d33 /lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/MyOptional.cpp | |
| parent | 17a7f20685de2a275fc2e53a38c5818797fe8a44 (diff) | |
[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.
Diffstat (limited to 'lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/MyOptional.cpp')
| -rw-r--r-- | lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/MyOptional.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/MyOptional.cpp b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/MyOptional.cpp new file mode 100644 index 000000000000..abba34439d88 --- /dev/null +++ b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/MyOptional.cpp @@ -0,0 +1,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; +} |
