[APINotes] Add support for handling Clang modules carrying all versions of APINotes

Controlled from Swift with '-version-independent-apinotes', which, for the underlying Clang invocation enables '-fswift-version-independent-apinotes', results in PCMs which aggregate all versioned APINotes wrapped in a 'SwiftVersionedAttr', with the intent to have the client pick and apply only those that match its current Swift version, discarding the rest.

This change introduces the configuration flags for this mode as well as the corresponding logic at the beginning of `importDeclImpl` to canonicalize versioned attributes, i.e. select the appropriate attributes for the current target and discard the rest.
This commit is contained in:
Artem Chikin
2024-08-14 12:35:23 -07:00
parent 328dd1f753
commit b60bc39ee5
8 changed files with 345 additions and 0 deletions

View File

@@ -2013,6 +2013,12 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
GenericArgs.push_back(blocklist);
}
// Inherit APINotes processing method
if (clangImporterOpts.LoadVersionIndependentAPINotes) {
GenericArgs.push_back("-version-independent-apinotes");
genericSubInvocation.getClangImporterOptions().LoadVersionIndependentAPINotes = true;
}
// Inherit the C++ interoperability mode.
if (langOpts.EnableCXXInterop) {
// Modelled after a reverse of validateCxxInteropCompatibilityMode