@@ -1914,6 +1914,7 @@ static int diagnoseModuleChange(SDKContext &Ctx, SDKNodeRoot *LeftModule,
1914
1914
llvm::StringSet<> ProtocolReqAllowlist,
1915
1915
bool DisableFailOnError,
1916
1916
bool CompilerStyleDiags,
1917
+ bool ExplicitErrOnABIBreakage,
1917
1918
StringRef SerializedDiagPath,
1918
1919
StringRef BreakageAllowlistPath,
1919
1920
bool DebugMapping) {
@@ -1936,11 +1937,16 @@ static int diagnoseModuleChange(SDKContext &Ctx, SDKNodeRoot *LeftModule,
1936
1937
Ctx.getDiags ().diagnose (SourceLoc (), diag::cannot_read_allowlist,
1937
1938
BreakageAllowlistPath);
1938
1939
}
1940
+ auto shouldDowngrade = false ;
1941
+ // If explicitly specified, avoid downgrading ABI breakage errors to warnings.
1942
+ if (ExplicitErrOnABIBreakage) {
1943
+ shouldDowngrade = false ;
1944
+ }
1939
1945
auto pConsumer = std::make_unique<FilteringDiagnosticConsumer>(
1940
1946
createDiagConsumer (*OS, FailOnError, DisableFailOnError, CompilerStyleDiags,
1941
1947
SerializedDiagPath),
1942
1948
std::move (allowedBreakages),
1943
- /* DowngradeToWarning*/ false );
1949
+ /* DowngradeToWarning*/ shouldDowngrade );
1944
1950
SWIFT_DEFER { pConsumer->finishProcessing (); };
1945
1951
Ctx.addDiagConsumer (*pConsumer);
1946
1952
Ctx.setCommonVersion (std::min (LeftModule->getJsonFormatVersion (),
@@ -1962,6 +1968,7 @@ static int diagnoseModuleChange(StringRef LeftPath, StringRef RightPath,
1962
1968
llvm::StringSet<> ProtocolReqAllowlist,
1963
1969
bool DisableFailOnError,
1964
1970
bool CompilerStyleDiags,
1971
+ bool ExplicitErrOnABIBreakage,
1965
1972
StringRef SerializedDiagPath,
1966
1973
StringRef BreakageAllowlistPath,
1967
1974
bool DebugMapping) {
@@ -1980,7 +1987,8 @@ static int diagnoseModuleChange(StringRef LeftPath, StringRef RightPath,
1980
1987
RightCollector.deSerialize (RightPath);
1981
1988
return diagnoseModuleChange (
1982
1989
Ctx, LeftCollector.getSDKRoot (), RightCollector.getSDKRoot (), OutputPath,
1983
- std::move (ProtocolReqAllowlist), DisableFailOnError, CompilerStyleDiags, SerializedDiagPath,
1990
+ std::move (ProtocolReqAllowlist), DisableFailOnError,
1991
+ ExplicitErrOnABIBreakage, CompilerStyleDiags, SerializedDiagPath,
1984
1992
BreakageAllowlistPath, DebugMapping);
1985
1993
}
1986
1994
@@ -2240,6 +2248,7 @@ class SwiftAPIDigesterInvocation {
2240
2248
std::string OutputFile;
2241
2249
std::string OutputDir;
2242
2250
bool CompilerStyleDiags;
2251
+ bool ExplicitErrOnABIBreakage;
2243
2252
std::string SerializedDiagPath;
2244
2253
std::string BaselineFilePath;
2245
2254
std::string BaselineDirPath;
@@ -2339,6 +2348,7 @@ class SwiftAPIDigesterInvocation {
2339
2348
OutputFile = ParsedArgs.getLastArgValue (OPT_o).str ();
2340
2349
OutputDir = ParsedArgs.getLastArgValue (OPT_output_dir).str ();
2341
2350
CompilerStyleDiags = ParsedArgs.hasArg (OPT_compiler_style_diags);
2351
+ ExplicitErrOnABIBreakage = ParsedArgs.hasArg (OPT_error_on_abi_breakage);
2342
2352
SerializedDiagPath =
2343
2353
ParsedArgs.getLastArgValue (OPT_serialize_diagnostics_path).str ();
2344
2354
BaselineFilePath = ParsedArgs.getLastArgValue (OPT_baseline_path).str ();
@@ -2578,21 +2588,24 @@ class SwiftAPIDigesterInvocation {
2578
2588
return diagnoseModuleChange (
2579
2589
SDKJsonPaths[0 ], SDKJsonPaths[1 ], OutputFile, CheckerOpts,
2580
2590
std::move (protocolAllowlist), DisableFailOnError, CompilerStyleDiags,
2581
- SerializedDiagPath, BreakageAllowlistPath, DebugMapping);
2591
+ ExplicitErrOnABIBreakage, SerializedDiagPath,
2592
+ BreakageAllowlistPath, DebugMapping);
2582
2593
}
2583
2594
case ComparisonInputMode::BaselineJson: {
2584
2595
SDKContext Ctx (CheckerOpts);
2585
2596
return diagnoseModuleChange (
2586
2597
Ctx, getBaselineFromJson (Ctx), getSDKRoot (Ctx, false ), OutputFile,
2587
2598
std::move (protocolAllowlist), DisableFailOnError, CompilerStyleDiags,
2588
- SerializedDiagPath, BreakageAllowlistPath, DebugMapping);
2599
+ ExplicitErrOnABIBreakage, SerializedDiagPath, BreakageAllowlistPath,
2600
+ DebugMapping);
2589
2601
}
2590
2602
case ComparisonInputMode::BothLoad: {
2591
2603
SDKContext Ctx (CheckerOpts);
2592
2604
return diagnoseModuleChange (
2593
2605
Ctx, getSDKRoot (Ctx, true ), getSDKRoot (Ctx, false ), OutputFile,
2594
2606
std::move (protocolAllowlist), DisableFailOnError, CompilerStyleDiags,
2595
- SerializedDiagPath, BreakageAllowlistPath, DebugMapping);
2607
+ ExplicitErrOnABIBreakage, SerializedDiagPath, BreakageAllowlistPath,
2608
+ DebugMapping);
2596
2609
}
2597
2610
}
2598
2611
}
0 commit comments