[Lldb-commits] [lldb] [lldb] Fix a regression in Status::GetErrorType() (PR #117095)
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 20 17:48:11 PST 2024
https://github.com/adrian-prantl created https://github.com/llvm/llvm-project/pull/117095
The refactored code did not correctly determine the type of expression errors.
rdar://139699028
>From 27308496b00d90e798d4c73940602d3e3cf1684b Mon Sep 17 00:00:00 2001
From: Adrian Prantl <aprantl at apple.com>
Date: Wed, 20 Nov 2024 17:45:54 -0800
Subject: [PATCH] [lldb] Fix a regression in Status::GetErrorType()
The refactored code did not correctly determine the type of expression
errors.
rdar://139699028
---
lldb/source/Utility/Status.cpp | 6 +++++-
.../expression/diagnostics/TestExprDiagnostics.py | 12 ++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/lldb/source/Utility/Status.cpp b/lldb/source/Utility/Status.cpp
index 1d171c6b6c3746..5757935fb86228 100644
--- a/lldb/source/Utility/Status.cpp
+++ b/lldb/source/Utility/Status.cpp
@@ -258,7 +258,11 @@ ErrorType Status::GetType() const {
// Return the first only.
if (result != eErrorTypeInvalid)
return;
- result = ErrorCodeToErrorType(error.convertToErrorCode());
+ if (error.isA<CloneableError>())
+ result = static_cast<const CloneableError &>(error).GetErrorType();
+ else
+ result = ErrorCodeToErrorType(error.convertToErrorCode());
+
});
return result;
}
diff --git a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
index fac562edf9ece0..c411d632d7a71f 100644
--- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
+++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py
@@ -184,6 +184,18 @@ def test_source_locations_from_objc_modules(self):
# the first argument are probably stable enough that this test can check for them.
self.assertIn("void NSLog(NSString *format", value.GetError().GetCString())
+ def test_error_type(self):
+ """Test the error reporting in the API"""
+ self.build()
+
+ (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+ self, "// Break here", self.main_source_spec
+ )
+ frame = thread.GetFrameAtIndex(0)
+ value = frame.EvaluateExpression('#error("I am error.")')
+ error = value.GetError()
+ self.assertEqual(error.GetType(), lldb.eErrorTypeExpression);
+
def test_command_expr_sbdata(self):
"""Test the structured diagnostics data"""
self.build()
More information about the lldb-commits
mailing list