================ @@ -1992,71 +1999,67 @@ void ValueObject::GetExpressionPath(Stream &s, } ValueObjectSP ValueObject::GetValueForExpressionPath( - llvm::StringRef expression, ExpressionPathScanEndReason *reason_to_stop, - ExpressionPathEndResultType *final_value_type, + llvm::StringRef expression, ExpressionPathScanEndReason *reason_to_stop_ptr, + ExpressionPathEndResultType *final_value_type_ptr, const GetValueForExpressionPathOptions &options, - ExpressionPathAftermath *final_task_on_target) { - - ExpressionPathScanEndReason dummy_reason_to_stop = - ValueObject::eExpressionPathScanEndReasonUnknown; - ExpressionPathEndResultType dummy_final_value_type = - ValueObject::eExpressionPathEndResultTypeInvalid; - ExpressionPathAftermath dummy_final_task_on_target = - ValueObject::eExpressionPathAftermathNothing; - - ValueObjectSP ret_val = GetValueForExpressionPath_Impl( - expression, reason_to_stop ? reason_to_stop : &dummy_reason_to_stop, - final_value_type ? final_value_type : &dummy_final_value_type, options, - final_task_on_target ? final_task_on_target - : &dummy_final_task_on_target); - - if (!final_task_on_target || - *final_task_on_target == ValueObject::eExpressionPathAftermathNothing) - return ret_val; - - if (ret_val.get() && - ((final_value_type ? *final_value_type : dummy_final_value_type) == - eExpressionPathEndResultTypePlain)) // I can only deref and takeaddress - // of plain objects - { - if ((final_task_on_target ? *final_task_on_target - : dummy_final_task_on_target) == - ValueObject::eExpressionPathAftermathDereference) { - Status error; - ValueObjectSP final_value = ret_val->Dereference(error); - if (error.Fail() || !final_value.get()) { - if (reason_to_stop) - *reason_to_stop = - ValueObject::eExpressionPathScanEndReasonDereferencingFailed; - if (final_value_type) - *final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid; - return ValueObjectSP(); - } else { - if (final_task_on_target) - *final_task_on_target = ValueObject::eExpressionPathAftermathNothing; - return final_value; - } - } - if (*final_task_on_target == - ValueObject::eExpressionPathAftermathTakeAddress) { - Status error; - ValueObjectSP final_value = ret_val->AddressOf(error); - if (error.Fail() || !final_value.get()) { - if (reason_to_stop) - *reason_to_stop = - ValueObject::eExpressionPathScanEndReasonTakingAddressFailed; - if (final_value_type) - *final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid; - return ValueObjectSP(); - } else { - if (final_task_on_target) - *final_task_on_target = ValueObject::eExpressionPathAftermathNothing; - return final_value; - } - } + ExpressionPathAftermath *final_task_on_target_ptr) { + + auto stop_reason_unknown = eExpressionPathScanEndReasonUnknown; + auto value_type_invalid = eExpressionPathEndResultTypeInvalid; + auto final_task_nothing = eExpressionPathAftermathNothing; + + auto ret_value = GetValueForExpressionPath_Impl( + expression, + reason_to_stop_ptr ? reason_to_stop_ptr : &stop_reason_unknown, + final_value_type_ptr ? final_value_type_ptr : &value_type_invalid, + options, + final_task_on_target_ptr ? final_task_on_target_ptr + : &final_task_nothing); + + // The caller knows nothing happened if `final_task_on_target` doesn't change. + if (!ret_value) + return ValueObjectSP(); + + if (!final_value_type_ptr) + return ret_value; + + if ((*final_value_type_ptr) != eExpressionPathEndResultTypePlain) + return ret_value; + + if (!final_task_on_target_ptr) + return ret_value; ---------------- PortalPete wrote:
I also did that for readability because that original combo-`if`-statement was a bit much for my head to parse out. However, I appreciate your point, @bulbazord , because it helped me realize that my changes alter the behavior of the method by not checking the effective return value from `GetValueForExpressionPath_Impl(...)` if the method passes `dummy_final_task_on_target` instead of the `final_task_on_target` parameter (when it's is `null`). I rewrote all of that with several ...`_proxy` local variables to keep the behavior consistent but in a more readable form (at least to me). I just pushed up the changes, so please double-check my work. https://github.com/llvm/llvm-project/pull/75865 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits