[Sema] Report public imports of private modules

Intro the concept of library access or distribution level to identify
layers of libraries and report public imports of private libraries from
public ones.

rdar://62934005
This commit is contained in:
Alexis Laferrière
2021-03-12 09:32:03 -08:00
parent 58f03e8490
commit cf58bb7eb4
19 changed files with 207 additions and 0 deletions

View File

@@ -538,6 +538,27 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Args.hasFlag(OPT_enable_swift3_objc_inference,
OPT_disable_swift3_objc_inference, false);
if (const Arg *A = Args.getLastArg(OPT_library_level)) {
StringRef contents = A->getValue();
if (contents == "api") {
Opts.LibraryLevel = LibraryLevel::API;
} else if (contents == "spi") {
Opts.LibraryLevel = LibraryLevel::SPI;
} 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);
}
}
}
if (Opts.EnableSwift3ObjCInference) {
if (const Arg *A = Args.getLastArg(
OPT_warn_swift3_objc_inference_minimal,