[ModuleInterfaces] Warn emitting an interface in -swift-version 4[.2]

If the project ever drops Swift 4 mode or Swift 4.2 mode, that would
break modules using those modes in their interface, so put an
unsilenceable warning in for using those modes to nudge interface
emitters to Swift 5.

rdar://problem/47792595
This commit is contained in:
Jordan Rose
2019-05-01 17:26:41 -07:00
parent 830eebb9a4
commit 73b7185a3d
4 changed files with 35 additions and 5 deletions

View File

@@ -358,12 +358,22 @@ static bool printAsObjCIfNeeded(StringRef outputPath, ModuleDecl *M,
/// \returns true if there were any errors
///
/// \see swift::emitParseableInterface
static bool printParseableInterfaceIfNeeded(StringRef outputPath,
ParseableInterfaceOptions const &Opts,
ModuleDecl *M) {
static bool
printParseableInterfaceIfNeeded(StringRef outputPath,
ParseableInterfaceOptions const &Opts,
LangOptions const &LangOpts,
ModuleDecl *M) {
if (outputPath.empty())
return false;
return withOutputFile(M->getDiags(), outputPath,
DiagnosticEngine &diags = M->getDiags();
if (!LangOpts.isSwiftVersionAtLeast(5)) {
assert(LangOpts.isSwiftVersionAtLeast(4));
diags.diagnose(SourceLoc(),
diag::warn_unsupported_module_interface_swift_version,
LangOpts.isSwiftVersionAtLeast(4, 2) ? "4.2" : "4");
}
return withOutputFile(diags, outputPath,
[M, Opts](raw_ostream &out) -> bool {
return swift::emitParseableInterface(out, Opts, M);
});
@@ -921,6 +931,7 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
hadAnyError |= printParseableInterfaceIfNeeded(
Invocation.getParseableInterfaceOutputPathForWholeModule(),
Invocation.getParseableInterfaceOptions(),
Invocation.getLangOptions(),
Instance.getMainModule());
}