[Sema] Accept and store the IPI library-level

Prepare to accept the `ipi` argument to the `-library-level` flag. IPI
stands for Internal Programming Interface and would describe a module
that's not to be distributed outside of its project.

In the future, the compiler could use that information to report when a
distributed module (api or spi) imports publicly a module that's not
distributed.

rdar://102435183
This commit is contained in:
Alexis Laferrière
2022-11-16 14:01:08 -08:00
parent f184504d62
commit a926b0555b
4 changed files with 14 additions and 9 deletions

View File

@@ -704,17 +704,15 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.LibraryLevel = LibraryLevel::API;
} else if (contents == "spi") {
Opts.LibraryLevel = LibraryLevel::SPI;
} else if (contents == "ipi") {
Opts.LibraryLevel = LibraryLevel::IPI;
} else {
Opts.LibraryLevel = LibraryLevel::Other;
if (contents != "other") {
// Error on unknown library levels.
auto inFlight = Diags.diagnose(SourceLoc(),
diag::error_unknown_library_level,
contents);
// Only warn for "ipi" as we may use it in the future.
if (contents == "ipi")
inFlight.limitBehavior(DiagnosticBehavior::Warning);
Diags.diagnose(SourceLoc(),
diag::error_unknown_library_level,
contents);
}
}
}