An SBValue whose underlying ValueObject has no valid value, but does

hold an error should:

(a) return false for IsValid, since that's the current behavior and is
    a convenient way to check "should I get the value for this".
(b) preserve the error when an SBValue is made from it, and print the
    error in the ValueObjectPrinter.

Make that happen.

Differential Revision: https://reviews.llvm.org/D144664
This commit is contained in:
Jim Ingham
2023-02-28 16:38:50 -08:00
parent c2d6cc9ac4
commit e8a2fd5e7b
3 changed files with 33 additions and 1 deletions

View File

@@ -71,6 +71,18 @@ void ValueObjectPrinter::Init(
}
bool ValueObjectPrinter::PrintValueObject() {
if (!m_orig_valobj)
return false;
// If the incoming ValueObject is in an error state, the best we're going to
// get out of it is its type. But if we don't even have that, just print
// the error and exit early.
if (m_orig_valobj->GetError().Fail()
&& !m_orig_valobj->GetCompilerType().IsValid()) {
m_stream->Printf("Error: '%s'", m_orig_valobj->GetError().AsCString());
return true;
}
if (!GetMostSpecializedValue() || m_valobj == nullptr)
return false;