@@ -1914,6 +1914,7 @@ static int diagnoseModuleChange(SDKContext &Ctx, SDKNodeRoot *LeftModule,
19141914 llvm::StringSet<> ProtocolReqAllowlist,
19151915 bool DisableFailOnError,
19161916 bool CompilerStyleDiags,
1917+ bool ExplicitErrOnABIBreakage,
19171918 StringRef SerializedDiagPath,
19181919 StringRef BreakageAllowlistPath,
19191920 bool DebugMapping) {
@@ -1936,11 +1937,16 @@ static int diagnoseModuleChange(SDKContext &Ctx, SDKNodeRoot *LeftModule,
19361937 Ctx.getDiags ().diagnose (SourceLoc (), diag::cannot_read_allowlist,
19371938 BreakageAllowlistPath);
19381939 }
1940+ auto shouldDowngrade = false ;
1941+ // If explicitly specified, avoid downgrading ABI breakage errors to warnings.
1942+ if (ExplicitErrOnABIBreakage) {
1943+ shouldDowngrade = false ;
1944+ }
19391945 auto pConsumer = std::make_unique<FilteringDiagnosticConsumer>(
19401946 createDiagConsumer (*OS, FailOnError, DisableFailOnError, CompilerStyleDiags,
19411947 SerializedDiagPath),
19421948 std::move (allowedBreakages),
1943- /* DowngradeToWarning*/ false );
1949+ /* DowngradeToWarning*/ shouldDowngrade );
19441950 SWIFT_DEFER { pConsumer->finishProcessing (); };
19451951 Ctx.addDiagConsumer (*pConsumer);
19461952 Ctx.setCommonVersion (std::min (LeftModule->getJsonFormatVersion (),
@@ -1962,6 +1968,7 @@ static int diagnoseModuleChange(StringRef LeftPath, StringRef RightPath,
19621968 llvm::StringSet<> ProtocolReqAllowlist,
19631969 bool DisableFailOnError,
19641970 bool CompilerStyleDiags,
1971+ bool ExplicitErrOnABIBreakage,
19651972 StringRef SerializedDiagPath,
19661973 StringRef BreakageAllowlistPath,
19671974 bool DebugMapping) {
@@ -1980,7 +1987,8 @@ static int diagnoseModuleChange(StringRef LeftPath, StringRef RightPath,
19801987 RightCollector.deSerialize (RightPath);
19811988 return diagnoseModuleChange (
19821989 Ctx, LeftCollector.getSDKRoot (), RightCollector.getSDKRoot (), OutputPath,
1983- std::move (ProtocolReqAllowlist), DisableFailOnError, CompilerStyleDiags, SerializedDiagPath,
1990+ std::move (ProtocolReqAllowlist), DisableFailOnError,
1991+ ExplicitErrOnABIBreakage, CompilerStyleDiags, SerializedDiagPath,
19841992 BreakageAllowlistPath, DebugMapping);
19851993}
19861994
@@ -2240,6 +2248,7 @@ class SwiftAPIDigesterInvocation {
22402248 std::string OutputFile;
22412249 std::string OutputDir;
22422250 bool CompilerStyleDiags;
2251+ bool ExplicitErrOnABIBreakage;
22432252 std::string SerializedDiagPath;
22442253 std::string BaselineFilePath;
22452254 std::string BaselineDirPath;
@@ -2339,6 +2348,7 @@ class SwiftAPIDigesterInvocation {
23392348 OutputFile = ParsedArgs.getLastArgValue (OPT_o).str ();
23402349 OutputDir = ParsedArgs.getLastArgValue (OPT_output_dir).str ();
23412350 CompilerStyleDiags = ParsedArgs.hasArg (OPT_compiler_style_diags);
2351+ ExplicitErrOnABIBreakage = ParsedArgs.hasArg (OPT_error_on_abi_breakage);
23422352 SerializedDiagPath =
23432353 ParsedArgs.getLastArgValue (OPT_serialize_diagnostics_path).str ();
23442354 BaselineFilePath = ParsedArgs.getLastArgValue (OPT_baseline_path).str ();
@@ -2578,21 +2588,24 @@ class SwiftAPIDigesterInvocation {
25782588 return diagnoseModuleChange (
25792589 SDKJsonPaths[0 ], SDKJsonPaths[1 ], OutputFile, CheckerOpts,
25802590 std::move (protocolAllowlist), DisableFailOnError, CompilerStyleDiags,
2581- SerializedDiagPath, BreakageAllowlistPath, DebugMapping);
2591+ ExplicitErrOnABIBreakage, SerializedDiagPath,
2592+ BreakageAllowlistPath, DebugMapping);
25822593 }
25832594 case ComparisonInputMode::BaselineJson: {
25842595 SDKContext Ctx (CheckerOpts);
25852596 return diagnoseModuleChange (
25862597 Ctx, getBaselineFromJson (Ctx), getSDKRoot (Ctx, false ), OutputFile,
25872598 std::move (protocolAllowlist), DisableFailOnError, CompilerStyleDiags,
2588- SerializedDiagPath, BreakageAllowlistPath, DebugMapping);
2599+ ExplicitErrOnABIBreakage, SerializedDiagPath, BreakageAllowlistPath,
2600+ DebugMapping);
25892601 }
25902602 case ComparisonInputMode::BothLoad: {
25912603 SDKContext Ctx (CheckerOpts);
25922604 return diagnoseModuleChange (
25932605 Ctx, getSDKRoot (Ctx, true ), getSDKRoot (Ctx, false ), OutputFile,
25942606 std::move (protocolAllowlist), DisableFailOnError, CompilerStyleDiags,
2595- SerializedDiagPath, BreakageAllowlistPath, DebugMapping);
2607+ ExplicitErrOnABIBreakage, SerializedDiagPath, BreakageAllowlistPath,
2608+ DebugMapping);
25962609 }
25972610 }
25982611 }
0 commit comments