================
@@ -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.
----------------
kastiglione wrote:

Upon further thought (and discussion with @adrian-prantl), I'm thinking of 
changing `BytecodeSyntheticChildren` to always return `eReuse` after its 
update. The reason is, I'm not currently aware of cases where bytecode needs to 
be re-evaluated.

https://github.com/llvm/llvm-project/pull/181199
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to