swift-module-digester: remove some boiler-template for classifying node kinds.

This commit is contained in:
Xi Ge
2018-09-26 12:56:49 -07:00
parent 212530465c
commit ab8c1c7938
2 changed files with 17 additions and 48 deletions

View File

@@ -158,16 +158,12 @@ NodePtr UpdatedNodesMap::findUpdateCounterpart(const SDKNode *Node) const {
return Node == FoundPair->first ? FoundPair->second : FoundPair->first;
}
bool SDKNodeType::classof(const SDKNode *N) {
switch (N->getKind()) {
case SDKNodeKind::TypeNominal:
case SDKNodeKind::TypeFunc:
case SDKNodeKind::TypeAlias:
return true;
default:
return false;
}
#define NODE_KIND_RANGE(ID, FIRST, LAST) \
bool SDKNode##ID::classof(const SDKNode *N) { \
return N->getKind() >= SDKNodeKind::FIRST && \
N->getKind() <= SDKNodeKind::LAST; \
}
#include "swift/IDE/DigesterEnums.def"
unsigned SDKNode::getChildIndex(const SDKNode* Child) const {
auto It = std::find(Children.begin(), Children.end(), Child);
@@ -351,28 +347,6 @@ StringRef SDKNodeDecl::getFullyQualifiedName() const {
return getSDKContext().buffer(OS.str());
}
bool SDKNodeDecl::classof(const SDKNode *N) {
switch (N->getKind()) {
case SDKNodeKind::DeclConstructor:
case SDKNodeKind::DeclFunction:
case SDKNodeKind::DeclGetter:
case SDKNodeKind::DeclSetter:
case SDKNodeKind::DeclTypeAlias:
case SDKNodeKind::DeclType:
case SDKNodeKind::DeclVar:
case SDKNodeKind::DeclAssociatedType:
case SDKNodeKind::DeclSubscript:
return true;
case SDKNodeKind::Root:
case SDKNodeKind::TypeNominal:
case SDKNodeKind::TypeFunc:
case SDKNodeKind::TypeAlias:
return false;
}
llvm_unreachable("Unhandled SDKNodeKind in switch.");
}
bool SDKNodeDecl::hasDeclAttribute(DeclAttrKind DAKind) const {
return std::find(DeclAttributes.begin(), DeclAttributes.end(), DAKind) !=
DeclAttributes.end();
@@ -443,20 +417,6 @@ bool SDKNodeDeclType::isConformingTo(KnownProtocolKind Kind) const {
}
}
bool SDKNodeDeclAbstractFunc::classof(const SDKNode *N) {
switch (N->getKind()) {
case SDKNodeKind::DeclFunction:
case SDKNodeKind::DeclSetter:
case SDKNodeKind::DeclGetter:
case SDKNodeKind::DeclConstructor:
case SDKNodeKind::DeclSubscript:
return true;
default:
return false;
}
}
StringRef SDKNodeDeclAbstractFunc::getTypeRoleDescription(SDKContext &Ctx,
unsigned Index) {
if (Index == 0) {