Skip to content

Sema: Intro experimental @cdecl and basic C compatibility check #80744

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Apr 10, 2025

Introduce a new experimental @cdecl attribute gated behind the CDecl feature flag. This is part of the initial work to make @_cdecl an official attribute with some improvements mostly for C compatibility.

For the time being I'm planning on using the new @cdecl for C compatibility and preserving the existing behavior of @_cdecl for Objective-C compatibilty until we settle on a final syntax. Considering the syntax and exact behavior is likely to change this PR introduces a few abstracted services to make future changes hopefully easier.

This PR implements basic checks on the validity of the @cdecl attribute and ensures the parameters and result types are representable in C. More work is required for this attribute to be usable in practice. More diagnostics will need to be updated to verify full representability in C, proper C compatible enums would need work, and printing for C clients in the compatibility header still needs to be implemented.

@xymus
Copy link
Contributor Author

xymus commented Apr 10, 2025

@swift-ci Please smoke test

@nkcsgexi
Copy link
Contributor

🥳

xymus added 5 commits April 11, 2025 11:34
This implements basic checks on the validity of the @cdecl attribute and
ensures the parameters and result types are representable in C. Many
more diagnostics will need to be updated to verify full representability
in C.
@xymus xymus force-pushed the cdecl-global-function-checking branch from 498055c to c6b2821 Compare April 11, 2025 18:36
@xymus
Copy link
Contributor Author

xymus commented Apr 11, 2025

@swift-ci Please smoke test

@xymus xymus requested review from beccadax, artemcm and tshortli April 11, 2025 20:57
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.

2 participants