Skip to content

Commit 7553fb1

Browse files
[lldb] Fix a regression in SBValue::GetObjectDescription() (#117242)
The old behavior was to return a null string in the error case,when refactoring the error handling I thought it would be a good idea to print the error in the description, but that breaks clients that try to print a description first and then do something else in the error case. The API is not great but it's clear that in-band errors are also not a good idea. rdar://133956263
1 parent 6a8a4d5 commit 7553fb1

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lldb/source/API/SBValue.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,10 @@ const char *SBValue::GetObjectDescription() {
380380
return nullptr;
381381

382382
llvm::Expected<std::string> str = value_sp->GetObjectDescription();
383-
if (!str)
384-
return ConstString("error: " + toString(str.takeError())).AsCString();
383+
if (!str) {
384+
llvm::consumeError(str.takeError());
385+
return nullptr;
386+
}
385387
return ConstString(*str).AsCString();
386388
}
387389

lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ def test_error_type(self):
195195
value = frame.EvaluateExpression('#error("I am error.")')
196196
error = value.GetError()
197197
self.assertEqual(error.GetType(), lldb.eErrorTypeExpression)
198+
value = frame.FindVariable("f")
199+
self.assertTrue(value.IsValid())
200+
desc = value.GetObjectDescription()
201+
self.assertEqual(desc, None)
198202

199203
def test_command_expr_sbdata(self):
200204
"""Test the structured diagnostics data"""

0 commit comments

Comments
 (0)