From fffe8c668461e73055182f229765cb7de908e295 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 22 Oct 2024 16:29:50 -0700 Subject: [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. --- .../Python/Inputs/FormatterBytecode/MyOptional.cpp | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/MyOptional.cpp (limited to 'lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/MyOptional.cpp') 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 struct MyOptionalStorage { + MyOptionalStorage(T val) : value(val), hasVal(true) {} + MyOptionalStorage() {} + T value; + bool hasVal = false; +}; + +template struct MyOptional { + MyOptionalStorage Storage; + MyOptional(T val) : Storage(val) {} + MyOptional() {} + T &operator*() { return Storage.value; } +}; + +void stop() {} + +int main(int argc, char **argv) { + MyOptional x, y = 42; + stop(); // break here + return *y; +} -- cgit v1.2.3