-
Notifications
You must be signed in to change notification settings - Fork 14.3k
The _code field in an NSError is signed, not unsigned. #119764
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
Conversation
@llvm/pr-subscribers-lldb Author: None (jimingham) ChangesThe NSError summary provider was fetching and printing the Full diff: https://github.com/llvm/llvm-project/pull/119764.diff 3 Files Affected:
diff --git a/lldb/source/Plugins/Language/ObjC/NSError.cpp b/lldb/source/Plugins/Language/ObjC/NSError.cpp
index 2356bc4ef4babd..389ff5a7edb1bf 100644
--- a/lldb/source/Plugins/Language/ObjC/NSError.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSError.cpp
@@ -66,7 +66,7 @@ bool lldb_private::formatters::NSError_SummaryProvider(
lldb::addr_t domain_location = ptr_value + 3 * ptr_size;
Status error;
- uint64_t code = process_sp->ReadUnsignedIntegerFromMemory(code_location,
+ int64_t code = process_sp->ReadSignedIntegerFromMemory(code_location,
ptr_size, 0, error);
if (error.Fail())
return false;
@@ -77,7 +77,7 @@ bool lldb_private::formatters::NSError_SummaryProvider(
return false;
if (!domain_str_value) {
- stream.Printf("domain: nil - code: %" PRIu64, code);
+ stream.Printf("domain: nil - code: %" PRIi64, code);
return true;
}
@@ -98,11 +98,11 @@ bool lldb_private::formatters::NSError_SummaryProvider(
StreamString domain_str_summary;
if (NSStringSummaryProvider(*domain_str_sp, domain_str_summary, options) &&
!domain_str_summary.Empty()) {
- stream.Printf("domain: %s - code: %" PRIu64, domain_str_summary.GetData(),
+ stream.Printf("domain: %s - code: %" PRIi64, domain_str_summary.GetData(),
code);
return true;
} else {
- stream.Printf("domain: nil - code: %" PRIu64, code);
+ stream.Printf("domain: nil - code: %" PRIi64, code);
return true;
}
}
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py
index 8a052cf84ef0ee..8709386bfbd384 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py
@@ -23,10 +23,10 @@ def test_nserror_with_run_command_no_const(self):
self.appkit_tester_impl(self.nserror_data_formatter_commands, False)
def nserror_data_formatter_commands(self):
- self.expect("frame variable nserror", substrs=['domain: @"Foobar" - code: 12'])
+ self.expect("frame variable nserror", substrs=['domain: @"Foobar" - code: -1234'])
self.expect(
- "frame variable nserrorptr", substrs=['domain: @"Foobar" - code: 12']
+ "frame variable nserrorptr", substrs=['domain: @"Foobar" - code: -1234']
)
self.expect("frame variable nserror->_userInfo", substrs=["2 key/value pairs"])
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
index 0ca5cf98bd3a53..314bada49303d3 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
@@ -618,7 +618,7 @@ int main(int argc, const char *argv[]) {
NSDictionary *error_userInfo = @{@"a" : @1, @"b" : @2};
NSError *nserror = [[NSError alloc] initWithDomain:@"Foobar"
- code:12
+ code:-1234
userInfo:error_userInfo];
NSError **nserrorptr = &nserror;
|
✅ With the latest revision this PR passed the Python code formatter. |
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo formatting.
The NSError summary provider was fetching and printing the `_code` field as an unsigned integer, but it's defined to be an NSInteger, which is signed.
The NSError summary provider was fetching and printing the `_code` field as an unsigned integer, but it's defined to be an NSInteger, which is signed. (cherry picked from commit 7c165f7)
…7c165f7fccfd [🍒 swift/release/6.1] The _code field in an NSError is signed, not unsigned. (llvm#119764)
The NSError summary provider was fetching and printing the
_code
field as an unsigned integer, but it's defined to be an NSInteger, which is signed.