Skip to content

Commit a3e2f0a

Browse files
[lldb] Fix a regression in Status::GetErrorType() (llvm#117095)
The refactored code did not correctly determine the type of expression errors. rdar://139699028
1 parent 8663b87 commit a3e2f0a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lldb/source/Utility/Status.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,11 @@ ErrorType Status::GetType() const {
258258
// Return the first only.
259259
if (result != eErrorTypeInvalid)
260260
return;
261-
result = ErrorCodeToErrorType(error.convertToErrorCode());
261+
if (error.isA<CloneableError>())
262+
result = static_cast<const CloneableError &>(error).GetErrorType();
263+
else
264+
result = ErrorCodeToErrorType(error.convertToErrorCode());
265+
262266
});
263267
return result;
264268
}

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

+12
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,18 @@ def test_source_locations_from_objc_modules(self):
184184
# the first argument are probably stable enough that this test can check for them.
185185
self.assertIn("void NSLog(NSString *format", value.GetError().GetCString())
186186

187+
def test_error_type(self):
188+
"""Test the error reporting in the API"""
189+
self.build()
190+
191+
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
192+
self, "// Break here", self.main_source_spec
193+
)
194+
frame = thread.GetFrameAtIndex(0)
195+
value = frame.EvaluateExpression('#error("I am error.")')
196+
error = value.GetError()
197+
self.assertEqual(error.GetType(), lldb.eErrorTypeExpression)
198+
187199
def test_command_expr_sbdata(self):
188200
"""Test the structured diagnostics data"""
189201
self.build()

0 commit comments

Comments
 (0)