Skip to content

Commit 31b46ee

Browse files
committed
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.
1 parent f55d3ad commit 31b46ee

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

tools/swift-api-digester/ModuleAnalyzerNodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ struct CheckerOptions {
145145
bool AbortOnModuleLoadFailure;
146146
bool PrintModule;
147147
bool SwiftOnly;
148+
bool SkipOSCheck;
148149
StringRef LocationFilter;
149150
};
150151

tools/swift-api-digester/swift-api-digester.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ SwiftOnly("swift-only",
127127
llvm::cl::init(false),
128128
llvm::cl::cat(Category));
129129

130+
static llvm::cl::opt<bool>
131+
DisableOSChecks("disable-os-checks",
132+
llvm::cl::desc("Skip OS related diagnostics"),
133+
llvm::cl::init(false),
134+
llvm::cl::cat(Category));
135+
130136
static llvm::cl::opt<bool>
131137
PrintModule("print-module", llvm::cl::desc("Print module names in diagnostics"),
132138
llvm::cl::cat(Category));
@@ -1006,7 +1012,8 @@ class PrunePass : public MatchedNodeListener, public SDKTreeDiffPass {
10061012
// Diagnose the missing of @available attributes.
10071013
// Decls with @_alwaysEmitIntoClient aren't required to have an
10081014
// @available attribute.
1009-
if (!D->getIntroducingVersion().hasOSAvailability() &&
1015+
if (!Ctx.getOpts().SkipOSCheck &&
1016+
!D->getIntroducingVersion().hasOSAvailability() &&
10101017
!D->hasDeclAttribute(DeclAttrKind::DAK_AlwaysEmitIntoClient)) {
10111018
D->emitDiag(diag::new_decl_without_intro);
10121019
}
@@ -2377,6 +2384,7 @@ static CheckerOptions getCheckOpts() {
23772384
Opts.LocationFilter = options::LocationFilter;
23782385
Opts.PrintModule = options::PrintModule;
23792386
Opts.SwiftOnly = options::SwiftOnly;
2387+
Opts.SkipOSCheck = options::DisableOSChecks;
23802388
return Opts;
23812389
}
23822390

0 commit comments

Comments
 (0)