-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Import typedef
-ed template instantiations #32950
#33451
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
typedef
-ed template instantiations #32950
@swift-ci please test |
CC @meg-gupta |
@swift-ci please test |
1 similar comment
@swift-ci please test |
Build failed |
@swift-ci please test |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci Please test Windows platform |
@swift-ci please test |
@swift-ci Please test Windows platform |
Build failed |
Build failed |
@swift-ci Please test Windows platform |
@hlopko This is causing an error in https://ci.swift.org/job/oss-swift_tools-R_stdlib-RD_test-simulator/ Failing test: From the log: |
Most likely a minor filecheck mismatch. I created #33507 to disable the test |
This is a roll-forward of #32950, with explicit c++17 version removed from tests. This is not needed since C++17 is the default anyway.
--
In this PR we teach
ClangImporter
to import typedef statements with template instantiation as its underlying type.will be made available in Swift as if
WrappedMagicNumber
is a regular struct.In C++, multiple distinct typedeffed instantiations resolve to the same canonical type. We implement this by creating a hidden intermediate struct that typedef aliasses.
The struct is named as
__CxxTemplateInst
plus Itanium mangled type of the instantiation. For the example above the name of the hidden struct is__CxxTemplateInst12MagicWrapperI11MagicNumberE
. Double underscore (denoting a reserved C++ identifier) is used to discourage direct usage. We chose Itanium mangling scheme because it produces valid Swift identifiers and covers all C++ edge cases.Imported module interface of the example above:
We modified the
SwiftLookupTable
logic to show hidden structs inswift_ide_test
for convenience.Resolves https://bugs.swift.org/browse/SR-12591.