Index: include/lldb/Utility/JSON.h =================================================================== --- include/lldb/Utility/JSON.h +++ include/lldb/Utility/JSON.h @@ -142,14 +142,14 @@ void Write(Stream& s) override; - uint64_t - GetAsUnsigned() const; + bool + GetAsUnsigned(uint64_t &value) const; - uint64_t - GetAsSigned() const; + bool + GetAsSigned(int64_t &value) const; - double - GetAsDouble() const; + bool + GetAsDouble(double &value) const; static bool classof(const JSONValue *V) { Index: source/Utility/JSON.cpp =================================================================== --- source/Utility/JSON.cpp +++ source/Utility/JSON.cpp @@ -60,46 +60,64 @@ s.Printf("\"%s\"", json_string_quote_metachars(m_data).c_str()); } -uint64_t -JSONNumber::GetAsUnsigned() const +bool +JSONNumber::GetAsUnsigned(uint64_t &value) const { switch (m_data_type) { - case DataType::Unsigned: - return m_data.m_unsigned; case DataType::Signed: - return (uint64_t)m_data.m_signed; + value = (uint64_t)m_data.m_signed; + break; case DataType::Double: - return (uint64_t)m_data.m_double; + value = (uint64_t)m_data.m_double; + break; + case DataType::Unsigned: + value = m_data.m_unsigned; + break; + default: + return false; } + return true; } -uint64_t -JSONNumber::GetAsSigned() const +bool +JSONNumber::GetAsSigned(int64_t &value) const { switch (m_data_type) { case DataType::Unsigned: - return (int64_t)m_data.m_unsigned; - case DataType::Signed: - return m_data.m_signed; + value = (int64_t)m_data.m_unsigned; + break; case DataType::Double: - return (int64_t)m_data.m_double; + value = (int64_t)m_data.m_double; + break; + case DataType::Signed: + value = m_data.m_signed; + break; + default: + return false; } + return true; } -double -JSONNumber::GetAsDouble() const +bool +JSONNumber::GetAsDouble(double &value) const { switch (m_data_type) { case DataType::Unsigned: - return (double)m_data.m_unsigned; + value = (double)m_data.m_unsigned; + break; case DataType::Signed: - return (double)m_data.m_signed; + value = (double)m_data.m_signed; + break; case DataType::Double: - return m_data.m_double; + value = m_data.m_double; + break; + default: + return false; } + return true; } void