swift
736b11a6 - [cxx-interop] Add a new mode that no longer renames unsafe functions

Commit
102 days ago
[cxx-interop] Add a new mode that no longer renames unsafe functions With the introduction of @unsafe(always) we have a new tool to handle functions that are very hard to use correctly. This PR introduces an experimental language feature. When this feature is on we will no longer rename methods to be __methodUnsafe but import them as @unsafe(always). This PR does not change any of the heuristics for renaming/adding @unsafe(always) just yet. This PR will import the functions over both spellings and add an unavailable note to the renamed one to guide users to use the original name. Only the original name is @unsafe(always); the renamed spelling is merely @unsafe, since the unsafety is already in its name. This also helps migration, as existing code calling the renamed spelling keeps compiling. There are a couple of caveats/corner cases: * The renamed declarations might still be referenced from the overlays. For this reason those declarations are not marked unavaliable/deprecated. * We did not clone the unsafe attributes for inherited functions. * Added some lookup and cloning logic to properly handle alternate declarations. * If a C++ function is already deprecated, the deprecation message from C++ wins. * Had to avoid some duplicate work for default arguments in alternate declarations. * An 'unsafe(always)' spelled in C++ is explicit, so it still wins over the downgrade to @unsafe on the renamed spelling.
Author
Gabor Horvath
Committer
Gabor Horvath
Parents
Loading