api-digester: diagnose adding conformances to existing protocols. rdar://48131686

This commit is contained in:
Xi Ge
2019-05-14 15:40:04 -07:00
parent f7881eed66
commit ae16a74af9
4 changed files with 16 additions and 0 deletions

View File

@@ -951,6 +951,8 @@ class PrunePass : public MatchedNodeListener, public SDKTreeDiffPass {
SDKContext &Ctx;
UpdatedNodesMap &UpdateMap;
llvm::StringSet<> ProtocolReqWhitelist;
SDKNodeRoot *LeftRoot;
SDKNodeRoot *RightRoot;
static void printSpaces(llvm::raw_ostream &OS, SDKNode *N) {
assert(N);
@@ -1028,6 +1030,12 @@ public:
auto *TD = Conf->getNominalTypeDecl();
if (TD->isProtocol()) {
TD->emitDiag(diag::conformance_added, Conf->getName());
} else {
// Adding conformance to an existing type can be ABI breaking.
if (Ctx.checkingABI() &&
!LeftRoot->getDescendantsByUsr(Conf->getUsr()).empty()) {
TD->emitDiag(diag::existing_conformance_added, Conf->getName());
}
}
}
@@ -1128,6 +1136,8 @@ public:
}
void pass(NodePtr Left, NodePtr Right) override {
LeftRoot = Left->getAs<SDKNodeRoot>();
RightRoot = Right->getAs<SDKNodeRoot>();
foundMatch(Left, Right, NodeMatchReason::Root);
}
};