-
Notifications
You must be signed in to change notification settings - Fork 10.5k
IRGen: Differentiate between Swift.Bool and ObjCBool (3.0) #4171
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
IRGen: Differentiate between Swift.Bool and ObjCBool (3.0) #4171
Conversation
@swift-ci Please test |
@jrose-apple Can you please review? |
@jckarter Also if you could take a look it would be great! |
9eb7469
to
bc20577
Compare
@swift-ci Please test |
@implementation TestingBool | ||
|
||
- (void) shouldBeTrueObjCBool: (BOOL)value { | ||
assert(value); |
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.
I think you should make the tests even stronger: the memory representation of value
should be 1
. These tests would pass today with the -1 issue.
static_assert(sizeof(BOOL) == sizeof(char), "unknown architecture");
char expected = 1;
assert(0 == memcmp(&value, &value, 1));
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.
The IRGen tests do verify that the representation is correct, so if you don't mind I'll fix up the tests in a separate patch on master.
This looks solid; I'm much less worried now that I see what changed. My one concern was the weak testing, but that shouldn't block merging this. Thanks, Slava! |
@swift-ci smoke test os x |
1 similar comment
@swift-ci smoke test os x |
bc20577
to
4f493db
Compare
@swift-ci Please smoke test os x |
@swift-ci smoke test os x |
@swift-ci Please test os x |
1 similar comment
@swift-ci Please test os x |
4f493db
to
50ac52a
Compare
@swift-ci Please test OS X |
1 similar comment
@swift-ci Please test OS X |
SIL already does this where necessary, except with foreign throwing functions; this patch changes Sema and the ClangImporter to give them an ObjCBool foreign error result type explicitly. This fixes a problem where calls to functions taking and returning the C99 _Bool type were miscompiled on Mac OS X x86-64, because IRGen was conflating the Objective-C BOOL type (which is a signed char on some platforms) and C99 _Bool (which lowers as the LLVM i1 type). Fixes <rdar://problem/26506458> and <rdar://problem/27365520>.
50ac52a
to
cd3f2f7
Compare
@swift-ci Please test OS X |
@gribozavr Any ideas what this failure means? https://ci.swift.org/job/swift-PR-osx/3139/#showFailuresLink |
Mishal's in the middle of updating the CI. |
@tkremenek do you mind merging this? Last few runs have only had different unrelated failures |
Uh oh!
There was an error while loading. Please reload this page.