ABI checker: add a mechansim for specifying allowd ABI breakages

When the checker found a breakage listed in the user-specified list,
the breage should be consumed internally without failing the check.

rdar://68086477
This commit is contained in:
Xi Ge
2020-08-31 09:54:05 -07:00
parent 73f427369f
commit 55e77785df
7 changed files with 174 additions and 28 deletions

View File

@@ -78,7 +78,7 @@ static StringRef getCategoryName(uint32_t ID) {
case LocalDiagID::not_inheriting_convenience_inits:
return "/* Class Inheritance Change */";
default:
return StringRef();
return "/* Others */";
}
}
}
@@ -122,3 +122,28 @@ swift::ide::api::ModuleDifferDiagsConsumer::~ModuleDifferDiagsConsumer() {
}
}
}
bool swift::ide::api::
FilteringDiagnosticConsumer::shouldProceed(const DiagnosticInfo &Info) {
if (allowedBreakages->empty()) {
return true;
}
llvm::SmallString<256> Text;
{
llvm::raw_svector_ostream Out(Text);
DiagnosticEngine::formatDiagnosticText(Out, Info.FormatString,
Info.FormatArgs);
}
return allowedBreakages->count(Text.str()) == 0;
}
void swift::ide::api::
FilteringDiagnosticConsumer::handleDiagnostic(SourceManager &SM,
const DiagnosticInfo &Info) {
if (shouldProceed(Info)) {
if (Info.Kind == DiagnosticKind::Error) {
HasError = true;
}
subConsumer->handleDiagnostic(SM, Info);
}
}