swift-api-digester: add a flag to disable OS related diagnostics

For frameworks not shipping with OSs, the users should specify this flag
to avoid diagnosing some changes, such as the missing of OS availability
attributes.
This commit is contained in:
Xi Ge
2019-05-28 17:01:08 -07:00
parent f55d3ad029
commit 31b46ee709
2 changed files with 10 additions and 1 deletions

View File

@@ -127,6 +127,12 @@ SwiftOnly("swift-only",
llvm::cl::init(false),
llvm::cl::cat(Category));
static llvm::cl::opt<bool>
DisableOSChecks("disable-os-checks",
llvm::cl::desc("Skip OS related diagnostics"),
llvm::cl::init(false),
llvm::cl::cat(Category));
static llvm::cl::opt<bool>
PrintModule("print-module", llvm::cl::desc("Print module names in diagnostics"),
llvm::cl::cat(Category));
@@ -1006,7 +1012,8 @@ public:
// Diagnose the missing of @available attributes.
// Decls with @_alwaysEmitIntoClient aren't required to have an
// @available attribute.
if (!D->getIntroducingVersion().hasOSAvailability() &&
if (!Ctx.getOpts().SkipOSCheck &&
!D->getIntroducingVersion().hasOSAvailability() &&
!D->hasDeclAttribute(DeclAttrKind::DAK_AlwaysEmitIntoClient)) {
D->emitDiag(diag::new_decl_without_intro);
}
@@ -2377,6 +2384,7 @@ static CheckerOptions getCheckOpts() {
Opts.LocationFilter = options::LocationFilter;
Opts.PrintModule = options::PrintModule;
Opts.SwiftOnly = options::SwiftOnly;
Opts.SkipOSCheck = options::DisableOSChecks;
return Opts;
}