Skip to content

[ClangImporter] Handle NS_TYPED_ENUMs of NSUIntegers in non-system headers #24316

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 2 commits into from
Apr 27, 2019

Conversation

jrose-apple
Copy link
Contributor

The special rule for NSUInteger in system headers was colliding with the behavior of NS_TYPED_ENUM (swift_newtype/swift_wrapper). Let NS_TYPED_ENUM take precedence here.

(I also future-proofed this for BOOL and Boolean, but those don't NS_TYPED_ENUM correctly right now for another reason: Bool is bridged to Objective-C via NSNumber, but ObjCBool is not, even though it could be.)

rdar://problem/50076612

The special rule for NSUInteger in system headers was colliding with
the behavior of NS_TYPED_ENUM (swift_newtype/swift_wrapper). Let
NS_TYPED_ENUM take precedence here.

(I also future-proofed this for BOOL and Boolean, but those don't
NS_TYPED_ENUM correctly right now for another reason: Bool is bridged
to Objective-C via NSNumber, but ObjCBool is not, even though it could
be.)

rdar://problem/50076612
At least as far as ImportHint was concerned, these two mapped types
were being treated the same.

No functionality change.
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

@jrose-apple jrose-apple changed the title [ClangImporter] Handle NS_TYPED_ENUMs of NSUIntegers in system headers [ClangImporter] Handle NS_TYPED_ENUMs of NSUIntegers in non-system headers Apr 26, 2019
Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

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

Seems reasonable.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 3498ca8

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test Linux

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 3498ca8

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test Linux

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me as well. The cleanup is nice.

@jrose-apple jrose-apple merged commit 6060557 into swiftlang:master Apr 27, 2019
@jrose-apple jrose-apple deleted the its-like-a-burrito branch April 27, 2019 22:19
jrose-apple added a commit to jrose-apple/swift that referenced this pull request Apr 27, 2019
[ClangImporter] Handle NS_TYPED_ENUMs of NSUIntegers in non-system headers

(cherry picked from commit 6060557)
@davezarzycki
Copy link
Contributor

Hi @jrose-apple – How was this tested on Linux? I'm seeing lots of crashes in the test suite in free() (using jemalloc).

@jrose-apple
Copy link
Contributor Author

Hm. I wouldn't expect it to affect Linux at all—it's supposed to be a no-functionality-change change for everything except NSUInteger. How'd you pinpoint this PR as the cause?

@davezarzycki
Copy link
Contributor

davezarzycki commented Apr 29, 2019

I have a script that runs every 12h that does a clean [unified] build. If that succeeds, then a local “branch” is updated to the mark the last known good commits. This makes bisecting fairly painless when something doesn’t work. In this case, and because of the weekend, only two pull requests existed between the “last good” commit and the “first known bad” commit (this pull request). I did a clean build / test of the PR merge before this PR and that succeeded, therefore this PR is to “blame”.

@davezarzycki
Copy link
Contributor

@jrose-apple – For reference: http://znu.io/4jordan.txt

@davezarzycki
Copy link
Contributor

FWIW – This appears to only happen with optimized builds. Maybe garbage is being passed to free() that is coincidentally a nullptr in a debug build?

@davezarzycki
Copy link
Contributor

Hi @jrose-apple – My sincerest apologies. The problem commit is on the clang side: apple/swift-clang#304

@jrose-apple
Copy link
Contributor Author

Whew! I was set to do a lot of headscratching debugging here, since I can certainly believe that a seemingly-NFC change would cause problems. I reverted the Clang commit, since it's a change that matches the backtrace.

@davezarzycki
Copy link
Contributor

Ya, sorry, the swift-llvm/swift-clang stable branches tend to be um, stable, and updated infrequently, so I didn’t even think about the fact that my script would reset swift-clang back to a known good state too.

jrose-apple added a commit that referenced this pull request Apr 29, 2019
[ClangImporter] Handle NS_TYPED_ENUMs of NSUIntegers in non-system headers

rdar://problem/50076612

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

Successfully merging this pull request may close these issues.

5 participants