Skip to content

Commit cfa2983

Browse files
committed
[NFC] Organize ModuleInterfaceSupport.cpp better
1 parent 51bdfa1 commit cfa2983

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

lib/Frontend/ModuleInterfaceSupport.cpp

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,9 @@
3636

3737
using namespace swift;
3838

39-
version::Version swift::InterfaceFormatVersion({1, 0});
39+
// MARK: Module interface header comments
4040

41-
/// Diagnose any scoped imports in \p imports, i.e. those with a non-empty
42-
/// access path. These are not yet supported by module interfaces, since the
43-
/// information about the declaration kind is not preserved through the binary
44-
/// serialization that happens as an intermediate step in non-whole-module
45-
/// builds.
46-
///
47-
/// These come from declarations like `import class FooKit.MainFooController`.
48-
static void diagnoseScopedImports(DiagnosticEngine &diags,
49-
ArrayRef<ImportedModule> imports){
50-
for (const ImportedModule &importPair : imports) {
51-
if (importPair.accessPath.empty())
52-
continue;
53-
diags.diagnose(importPair.accessPath.front().Loc,
54-
diag::module_interface_scoped_import_unsupported);
55-
}
56-
}
41+
version::Version swift::InterfaceFormatVersion({1, 0});
5742

5843
/// Prints to \p out a comment containing a format version number, tool version
5944
/// string as well as any relevant command-line flags in \p Opts used to
@@ -93,6 +78,25 @@ llvm::Regex swift::getSwiftInterfaceCompilerVersionRegex() {
9378
": (.+)$", llvm::Regex::Newline);
9479
}
9580

81+
// MARK: Import statements
82+
83+
/// Diagnose any scoped imports in \p imports, i.e. those with a non-empty
84+
/// access path. These are not yet supported by module interfaces, since the
85+
/// information about the declaration kind is not preserved through the binary
86+
/// serialization that happens as an intermediate step in non-whole-module
87+
/// builds.
88+
///
89+
/// These come from declarations like `import class FooKit.MainFooController`.
90+
static void diagnoseScopedImports(DiagnosticEngine &diags,
91+
ArrayRef<ImportedModule> imports){
92+
for (const ImportedModule &importPair : imports) {
93+
if (importPair.accessPath.empty())
94+
continue;
95+
diags.diagnose(importPair.accessPath.front().Loc,
96+
diag::module_interface_scoped_import_unsupported);
97+
}
98+
}
99+
96100
/// Prints the imported modules in \p M to \p out in the form of \c import
97101
/// source declarations.
98102
static void printImports(raw_ostream &out,
@@ -174,6 +178,8 @@ static void printImports(raw_ostream &out,
174178
}
175179
}
176180

181+
// MARK: Dummy protocol conformances
182+
177183
// FIXME: Copied from ASTPrinter.cpp...
178184
static bool isPublicOrUsableFromInline(const ValueDecl *VD) {
179185
AccessScope scope =
@@ -561,6 +567,8 @@ const StringLiteral InheritedProtocolCollector::DummyProtocolName =
561567
"_ConstraintThatIsNotPartOfTheAPIOfThisLibrary";
562568
} // end anonymous namespace
563569

570+
// MARK: Interface emission
571+
564572
bool swift::emitSwiftInterface(raw_ostream &out,
565573
ModuleInterfaceOptions const &Opts,
566574
ModuleDecl *M) {

0 commit comments

Comments
 (0)