[NFC] Organize ModuleInterfaceSupport.cpp better

This commit is contained in:
Becca Royal-Gordon
2021-02-10 18:55:02 -08:00
parent 51bdfa1919
commit cfa2983d7d

View File

@@ -36,24 +36,9 @@
using namespace swift;
version::Version swift::InterfaceFormatVersion({1, 0});
// MARK: Module interface header comments
/// Diagnose any scoped imports in \p imports, i.e. those with a non-empty
/// access path. These are not yet supported by module interfaces, since the
/// information about the declaration kind is not preserved through the binary
/// serialization that happens as an intermediate step in non-whole-module
/// builds.
///
/// These come from declarations like `import class FooKit.MainFooController`.
static void diagnoseScopedImports(DiagnosticEngine &diags,
ArrayRef<ImportedModule> imports){
for (const ImportedModule &importPair : imports) {
if (importPair.accessPath.empty())
continue;
diags.diagnose(importPair.accessPath.front().Loc,
diag::module_interface_scoped_import_unsupported);
}
}
version::Version swift::InterfaceFormatVersion({1, 0});
/// Prints to \p out a comment containing a format version number, tool version
/// string as well as any relevant command-line flags in \p Opts used to
@@ -93,6 +78,25 @@ llvm::Regex swift::getSwiftInterfaceCompilerVersionRegex() {
": (.+)$", llvm::Regex::Newline);
}
// MARK: Import statements
/// Diagnose any scoped imports in \p imports, i.e. those with a non-empty
/// access path. These are not yet supported by module interfaces, since the
/// information about the declaration kind is not preserved through the binary
/// serialization that happens as an intermediate step in non-whole-module
/// builds.
///
/// These come from declarations like `import class FooKit.MainFooController`.
static void diagnoseScopedImports(DiagnosticEngine &diags,
ArrayRef<ImportedModule> imports){
for (const ImportedModule &importPair : imports) {
if (importPair.accessPath.empty())
continue;
diags.diagnose(importPair.accessPath.front().Loc,
diag::module_interface_scoped_import_unsupported);
}
}
/// Prints the imported modules in \p M to \p out in the form of \c import
/// source declarations.
static void printImports(raw_ostream &out,
@@ -174,6 +178,8 @@ static void printImports(raw_ostream &out,
}
}
// MARK: Dummy protocol conformances
// FIXME: Copied from ASTPrinter.cpp...
static bool isPublicOrUsableFromInline(const ValueDecl *VD) {
AccessScope scope =
@@ -561,6 +567,8 @@ const StringLiteral InheritedProtocolCollector::DummyProtocolName =
"_ConstraintThatIsNotPartOfTheAPIOfThisLibrary";
} // end anonymous namespace
// MARK: Interface emission
bool swift::emitSwiftInterface(raw_ostream &out,
ModuleInterfaceOptions const &Opts,
ModuleDecl *M) {