API checker: only diagnose adding enum cases to exhaustive enums

Adding new cases to a non-exhaustive enum type isn't source-breaking
since it only triggers a warning.

rdar://63464929
This commit is contained in:
Xi Ge
2020-05-23 15:43:07 -07:00
parent bcdebc6426
commit c5730beb42
9 changed files with 26 additions and 3 deletions

View File

@@ -1216,7 +1216,9 @@ public:
if (!Ctx.checkingABI()) {
if (auto *Var = dyn_cast<SDKNodeDeclVar>(Right)) {
if (Var->getDeclKind() == DeclKind::EnumElement) {
Var->emitDiag(Var->getLoc(), diag::enum_case_added);
if (Var->getParent()->getAs<SDKNodeDeclType>()->isEnumExhaustive()) {
Var->emitDiag(Var->getLoc(), diag::enum_case_added);
}
}
}
}