mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Frontend] Output the private module interface with the SPI info
This commit is contained in:
@@ -83,12 +83,15 @@ llvm::Regex swift::getSwiftInterfaceModuleFlagsRegex() {
|
||||
|
||||
/// Prints the imported modules in \p M to \p out in the form of \c import
|
||||
/// source declarations.
|
||||
static void printImports(raw_ostream &out, ModuleDecl *M) {
|
||||
static void printImports(raw_ostream &out,
|
||||
ModuleInterfaceOptions const &Opts,
|
||||
ModuleDecl *M) {
|
||||
// FIXME: This is very similar to what's in Serializer::writeInputBlock, but
|
||||
// it's not obvious what higher-level optimization would be factored out here.
|
||||
ModuleDecl::ImportFilter allImportFilter;
|
||||
allImportFilter |= ModuleDecl::ImportFilterKind::Public;
|
||||
allImportFilter |= ModuleDecl::ImportFilterKind::Private;
|
||||
allImportFilter |= ModuleDecl::ImportFilterKind::SPIAccessControl;
|
||||
|
||||
SmallVector<ModuleDecl::ImportedModule, 8> allImports;
|
||||
M->getImportedModules(allImports, allImportFilter);
|
||||
@@ -104,15 +107,25 @@ static void printImports(raw_ostream &out, ModuleDecl *M) {
|
||||
publicImportSet.insert(publicImports.begin(), publicImports.end());
|
||||
|
||||
for (auto import : allImports) {
|
||||
if (import.second->isOnoneSupportModule() ||
|
||||
import.second->isBuiltinModule()) {
|
||||
auto importedModule = import.second;
|
||||
if (importedModule->isOnoneSupportModule() ||
|
||||
importedModule->isBuiltinModule()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (publicImportSet.count(import))
|
||||
out << "@_exported ";
|
||||
|
||||
// SPI attribute on imports
|
||||
if (Opts.PrintSPIs) {
|
||||
SmallVector<Identifier, 4> spis;
|
||||
M->lookupImportedSPIs(importedModule, spis);
|
||||
for (auto spiName : spis)
|
||||
out << "@_spi(" << spiName << ") ";
|
||||
}
|
||||
|
||||
out << "import ";
|
||||
import.second->getReverseFullModuleName().printForward(out);
|
||||
importedModule->getReverseFullModuleName().printForward(out);
|
||||
|
||||
// Write the access path we should be honoring but aren't.
|
||||
// (See diagnoseScopedImports above.)
|
||||
@@ -437,10 +450,10 @@ bool swift::emitSwiftInterface(raw_ostream &out,
|
||||
assert(M);
|
||||
|
||||
printToolVersionAndFlagsComment(out, Opts, M);
|
||||
printImports(out, M);
|
||||
printImports(out, Opts, M);
|
||||
|
||||
const PrintOptions printOptions = PrintOptions::printSwiftInterfaceFile(
|
||||
Opts.PreserveTypesAsWritten, Opts.PrintFullConvention);
|
||||
Opts.PreserveTypesAsWritten, Opts.PrintFullConvention, Opts.PrintSPIs);
|
||||
InheritedProtocolCollector::PerTypeMap inheritedProtocolMap;
|
||||
|
||||
SmallVector<Decl *, 16> topLevelDecls;
|
||||
|
||||
Reference in New Issue
Block a user