================
@@ -291,10 +292,41 @@ lldb::ChildCacheState
BytecodeSyntheticChildren::FrontEnd::Update() {
return ChildCacheState::eRefetch;
}
+ // If the top of the stack is a 0 or 1, that value is popped of the stack and
+ // treated as a return value of eRefetch or eReuse respectively. If the top
of
+ // the stack is any other value, it stays on the stack and becomes part of
+ // `self`.
+ //
+ // This dynamic logic can lead to errors for synthetic formatter authors.
+ // Consider the case where an `update` implementation places the number of
+ // children last on the stack. LLDB will _sometimes_ (but not always) consume
+ // that value as a ChildCacheState value. This would cause downstream
problems
+ // in `num_children`, because the count won't be on the stack.
+ //
+ // Bytecode authors are encouraged to explicitly push a ChildCacheState value
+ // on to the stack.
----------------
Michael137 wrote:
Would it be possible to make it a requirement? If the byte code will mostly be
compiler-generated, we can enforce it there. And make the interpreter expect
it? I guess that would be a formatter byte-code ABI break?
https://github.com/llvm/llvm-project/pull/181199
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits