Skip to content

[lldb] Fix a regression in Status::GetErrorType() #117095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

adrian-prantl
Copy link
Collaborator

The refactored code did not correctly determine the type of expression errors.

rdar://139699028

@llvmbot
Copy link
Member

llvmbot commented Nov 21, 2024

@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)

Changes

The refactored code did not correctly determine the type of expression errors.

rdar://139699028


Full diff: https://github.com/llvm/llvm-project/pull/117095.diff

2 Files Affected:

  • (modified) lldb/source/Utility/Status.cpp (+5-1)
  • (modified) lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py (+12)
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()

Copy link

github-actions bot commented Nov 21, 2024

✅ With the latest revision this PR passed the Python code formatter.

The refactored code did not correctly determine the type of expression
errors.

rdar://139699028
Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@adrian-prantl adrian-prantl merged commit a3e2f0a into llvm:main Nov 21, 2024
7 checks passed
adrian-prantl added a commit to adrian-prantl/llvm-project that referenced this pull request Nov 21, 2024
The refactored code did not correctly determine the type of expression
errors.

rdar://139699028
(cherry picked from commit a3e2f0a)
adrian-prantl added a commit to swiftlang/llvm-project that referenced this pull request Nov 22, 2024
…-6.1-lldb-Fix-a-regression-in-Status-GetErrorType-117095

[Cherry-pick into swift/release/6.1] [lldb] Fix a regression in Status::GetErrorType()  (llvm#117095)
adrian-prantl added a commit to adrian-prantl/llvm-project that referenced this pull request Dec 5, 2024
The refactored code did not correctly determine the type of expression
errors.

rdar://139699028
(cherry picked from commit a3e2f0a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants