-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Make @objcImpl work with @_cdecl #69468
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
93006cc
to
042af8e
Compare
@swift-ci please test |
@swift-ci please test |
1 similar comment
@swift-ci please test |
@swift-ci please test windows platform |
Note that I got a pass on Windows yesterday with the exact same code: https://ci-external.swift.org/job/swift-PR-windows/19506/ |
@swift-ci please test windows platform |
@swift-ci please test |
@@ -1,4 +1,4 @@ | |||
// RUN: %target-run-simple-swift(-import-objc-header %S/Inputs/objc_implementation.h -D TOP_LEVEL_CODE -swift-version 5) %s | %FileCheck %s | |||
// RUN: %target-run-simple-swift(-import-objc-header %S/Inputs/objc_implementation.h -D TOP_LEVEL_CODE -swift-version 5) %s -save-temps | %FileCheck %s |
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.
Is leaving -save-temps
intentional here?
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.
Nope—I've now removed it. Thanks!
6883bce
to
97c9dbc
Compare
No real diagnostics yet, but we’re emitting mostly correct code.
…at least for declarations in the current module. We continue to pretend that inaccessible declarations in other modules do not exist.
It also reads the C name out of imported C functions, which will be convenient for @cdecl @implementation.
This commit diagnoses cdecl implementations with no matching imported declaration, and also runs them through the ObjCImplementationChecker. Actually testing that the ObjCImplementationChecker diagnoses various failure conditions correctly will be added in a subsequent commit.
We eventually want to be able to implement functions imported as globals or members in Swift, but we’re not there yet. Add some basic tests to make sure we get reasonable diagnostics for them.
97c9dbc
to
5aa932f
Compare
@swift-ci please test and merge |
1 similar comment
@swift-ci please test and merge |
@swift-ci please smoke test and merge |
@swift-ci please smoke test |
return cdeclAttr->Name; | ||
} | ||
|
||
return ""; |
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.
There's also @extern(c, "name")
, IIRC
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.
It looks like @_extern
requires the function to not have a body, so it wouldn't make sense to use it with @implementation
(which provides a body). Is that changing?
Swift can now emit C functions which match a global function declaration in a C header. That is, you can apply
@_objcImplementation
to a@_cdecl
function and it will match it to a global C function in a header.This doesn't yet have all the functionality I'd like—I'm hoping to cover computed properties and at least some import-as-member functions too. But it already has enough functionality to be useful.
Fixes rdar://103845088.