This patch introduces an a C++ class annotation, SWIFT_PRIVATE_FILEID,
which will specify where Swift extensions of that class will be allowed
to access its non-public members, e.g.:
class SWIFT_PRIVATE_FILEID("MyModule/MyFile.swift") Foo { ... };
The goal of this feature is to help C++ developers incrementally migrate
the implementation of their C++ classes to Swift, without breaking
encapsulation and indiscriminately exposing those classes' private and
protected fields.
As an implementation detail of this feature, this patch introduces an
abstraction for file ID strings, FileIDStr, which represent a parsed pair
of module name/file name.
rdar://137764620
This PR adds a variadic macro that builds a SwiftAttr string containing
the names of the template type parameters that need to be escapable for
the type to be considered escapable. It also adds logic to interpret
this annotation.
rdar://139065437
In this mode all C++ types are imported as unsafe by default. Users
explicitly marking types are escapable or not escapable can make them
imported as safe. In the future, we also want to import unannotated
functions as unsafe and add more logic to infer types that are actually
safe, like agregates of escapable types.
This makes it easier to experiment with noescapable types in interop.
Moreover, we always wanted to have this annotation for completeness,
similar to SWIFT_NONCOPYABLE.
The `bridging` header for C++ interop was calculating an include
directory using `CMAKE_BINARY_DIR` and `CMAKE_CFG_INTDIR` while the rest
of the headers consistently use `CMAKE_CURRENT_BINARY_DIR` and no
`CMAKE_CFG_INTDIR`.
In some configurations of CMake (for example when using Swift as an
external project of LLVM and building an unified toolchain), this means
that the `brigding` header will end up in a different directory than the
rest of the headers, which complicates testing.
The changes in this commit reuses `SWIFT_INCLUDE_DIR` to keep
consistency with the rest of the headers. Any build started by
`build-script` should not notice the difference.