mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-29 11:56:07 +00:00

Follow up to "Suppress persistent result when running po" (D144044). This change delays removal of the persistent result until after `Dump` has been called. In doing so, the persistent result is available for the purpose of getting its object description. In the original change, the persistent result removal happens indirectly, by setting `EvaluateExpressionOptions::SetSuppressPersistentResult`. In practice this has worked, however this exposed a latent bug in swift-lldb. The subtlety, and the bug, depend on when the persisteted result variable is removed. When the result is removed via `SetSuppressPersistentResult`, it happens within the call to `Target::EvaluateExpression`. That is, by the time the call returns, the persistent result is already removed. The issue occurs shortly thereafter, when `ValueObject::Dump` is called, it cannot make use of the persistent result variable (instead it uses the `ValueObjectConstResult`). In swift-lldb, this causes an additional expression evaluation to happen. It first tries an expression that reference `$R0` etc, but that always fails because `$R0` is removed. The fallback to this failure does work most of the time, but there's at least one bug involving imported Clang types. Differential Revision: https://reviews.llvm.org/D150619