mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
swift-module-digester: remove some boiler-template for classifying node kinds.
This commit is contained in:
@@ -50,19 +50,28 @@
|
||||
#define SPECIAL_CASE_ID(NAME)
|
||||
#endif
|
||||
|
||||
#ifndef NODE_KIND_RANGE
|
||||
#define NODE_KIND_RANGE(ID, First, Last)
|
||||
#endif
|
||||
|
||||
NODE_KIND(Root, Root)
|
||||
NODE_KIND(TypeNominal, TypeNominal)
|
||||
NODE_KIND(TypeFunc, TypeFunc)
|
||||
NODE_KIND(TypeAlias, TypeNameAlias)
|
||||
NODE_KIND(DeclType, TypeDecl)
|
||||
NODE_KIND_RANGE(Type, TypeNominal, TypeAlias)
|
||||
|
||||
NODE_KIND(DeclFunction, Function)
|
||||
NODE_KIND(DeclConstructor, Constructor)
|
||||
NODE_KIND(DeclGetter, Getter)
|
||||
NODE_KIND(DeclSetter, Setter)
|
||||
NODE_KIND(DeclSubscript, Subscript)
|
||||
NODE_KIND_RANGE(DeclAbstractFunc, DeclFunction, DeclSubscript)
|
||||
|
||||
NODE_KIND(DeclType, TypeDecl)
|
||||
NODE_KIND(DeclVar, Var)
|
||||
NODE_KIND(DeclTypeAlias, TypeAlias)
|
||||
NODE_KIND(DeclAssociatedType, AssociatedType)
|
||||
NODE_KIND(DeclSubscript, Subscript)
|
||||
NODE_KIND_RANGE(Decl, DeclFunction, DeclAssociatedType)
|
||||
|
||||
NODE_ANNOTATION(Added)
|
||||
NODE_ANNOTATION(Removed)
|
||||
@@ -106,7 +115,6 @@ NODE_ANNOTATION_CHANGE_KIND(Rename)
|
||||
// Keep type rewritten the last one.
|
||||
NODE_ANNOTATION_CHANGE_KIND(TypeRewritten)
|
||||
|
||||
|
||||
KEY_BOOL(IsImplicit, implicit)
|
||||
KEY_BOOL(IsThrowing, throwing)
|
||||
KEY_BOOL(IsMutating, mutating)
|
||||
@@ -194,6 +202,7 @@ SPECIAL_CASE_ID(ToIntMax)
|
||||
SPECIAL_CASE_ID(ToUIntMax)
|
||||
SPECIAL_CASE_ID(UIApplicationMain)
|
||||
|
||||
#undef NODE_KIND_RANGE
|
||||
#undef SPECIAL_CASE_ID
|
||||
#undef DIFF_ITEM_KEY_KIND_INT
|
||||
#undef DIFF_ITEM_KEY_KIND_STRING
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user