-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Teach importer to interpret lifetimebound annotations #76311
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
c349cab
to
00965c2
Compare
@swift-ci please smoke test |
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 only have a couple comments regarding tests, otherwise LGTM.
} | ||
|
||
//--- test.swift | ||
|
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.
Could you please add a module interface test that would check that the Swift lifetime attributes are printed in the generated interface for a C++ module?
See test/Interop/Cxx/class/access-specifiers-module-interface.swift
for example
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.
Unfortunately, the Swift lifetimes are not supported by the module printer yet as there is no official/final syntax for it. That being said, I added checks like that because it is still useful to see what parameters are imported as borrowing. Let me know if that looks good.
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.
@meg-gupta is planning to add @lifetime()
annotations to the module printer.
rdar://130342167 ([nonescapable] add .swiftinterface support for lifetime dependence)
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.
You can write an -emit-sil
test like test/SIL/lifetime_dependence_buffer_view_test.swift
to ensure that the SIL representation has _scope
/ _inherit
in the interim.
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.
A slightly unrelated comment: I might be missing something but lifetime_dependence_buffer_view_test.swift
does not seem to invoke FileCheck
? Is that intentional, or a bug?
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 updated the test to check the SIL.
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.
Thanks. I'll fix lifetime_dependence_buffer_view_test.swift
to include FileCheck!
00965c2
to
a810bea
Compare
@swift-ci please smoke test |
This all looks reasonable to me. |
5e317ec
to
beddb76
Compare
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, the tests that I was asking for can be added in a follow-up patch, once the module interface printer is aware of lifetime attributes.
The lifetimebound annotations are now imported as lifetime dependencies. This works for basic cases but there are still some parts missing: * Support lifeitmebound annotations on constructors * A way to represent immortal/static lifetimes on the C++ side
beddb76
to
16e012b
Compare
@swift-ci please smoke test |
The lifetimebound annotations are now imported as lifetime dependencies. This works for basic cases but there are still some parts missing:
rdar://135875896