diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 5e3f25559a28c..e5ff6b493f09e 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""" diff --git a/lldb/test/API/lang/swift/po/uninitialized/main.swift b/lldb/test/API/lang/swift/po/uninitialized/main.swift index dae351a05d002..f1a2972efc91d 100644 --- a/lldb/test/API/lang/swift/po/uninitialized/main.swift +++ b/lldb/test/API/lang/swift/po/uninitialized/main.swift @@ -15,7 +15,7 @@ class POClass { func main() { var object: POClass - object = POClass() //% self.assertTrue(self.frame().FindVariable('object').GetObjectDescription() == 'error: ', 'po correctly detects uninitialized instances') + object = POClass() //% self.assertEqual(self.frame().FindVariable('object').GetObjectDescription(), None, 'po correctly detects uninitialized instances'); self.expect("po object", substrs=[""]) print("yay I am done") //% self.assertTrue('POClass:' in self.frame().FindVariable('object').GetObjectDescription()) }