diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index b35c82250d6ba..a707b9aa7589c 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -380,8 +380,10 @@ const char *SBValue::GetObjectDescription() { return nullptr; llvm::Expected str = value_sp->GetObjectDescription(); - if (!str) - return ConstString("error: " + toString(str.takeError())).AsCString(); + if (!str) { + llvm::consumeError(str.takeError()); + return nullptr; + } return ConstString(*str).AsCString(); } diff --git a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py index b9b5bffb87e81..0806776aa6eb0 100644 --- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py +++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py @@ -195,6 +195,10 @@ def test_error_type(self): value = frame.EvaluateExpression('#error("I am error.")') error = value.GetError() self.assertEqual(error.GetType(), lldb.eErrorTypeExpression) + value = frame.FindVariable("f") + self.assertTrue(value.IsValid()) + desc = value.GetObjectDescription() + self.assertEqual(desc, None) def test_command_expr_sbdata(self): """Test the structured diagnostics data"""