Skip to content

[Cherry-pick into stable/20230725] Simplify ValueObject::GetQualifiedRepresentationIfAvailable(). (#71559) #7766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 16 additions & 20 deletions lldb/source/Core/ValueObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2716,34 +2716,30 @@ ValueObjectSP ValueObject::CreateConstantValue(ConstString name) {

ValueObjectSP ValueObject::GetQualifiedRepresentationIfAvailable(
lldb::DynamicValueType dynValue, bool synthValue) {
ValueObjectSP result_sp(GetSP());

ValueObjectSP result_sp;
switch (dynValue) {
case lldb::eDynamicCanRunTarget:
case lldb::eDynamicDontRunTarget: {
if (!result_sp->IsDynamic()) {
if (result_sp->GetDynamicValue(dynValue))
result_sp = result_sp->GetDynamicValue(dynValue);
}
if (!IsDynamic())
result_sp = GetDynamicValue(dynValue);
} break;
case lldb::eNoDynamicValues: {
if (result_sp->IsDynamic()) {
if (result_sp->GetStaticValue())
result_sp = result_sp->GetStaticValue();
}
if (IsDynamic())
result_sp = GetStaticValue();
} break;
}
if (!result_sp)
result_sp = GetSP();
assert(result_sp);

if (synthValue) {
if (!result_sp->IsSynthetic()) {
if (result_sp->GetSyntheticValue())
result_sp = result_sp->GetSyntheticValue();
}
} else {
if (result_sp->IsSynthetic()) {
if (result_sp->GetNonSyntheticValue())
result_sp = result_sp->GetNonSyntheticValue();
}
bool is_synthetic = result_sp->IsSynthetic();
if (synthValue && !is_synthetic) {
if (auto synth_sp = result_sp->GetSyntheticValue())
return synth_sp;
}
if (!synthValue && is_synthetic) {
if (auto non_synth_sp = result_sp->GetNonSyntheticValue())
return non_synth_sp;
}

return result_sp;
Expand Down