Skip to content

Commit 3e34c8c

Browse files
committed
[CS] NFC: Use SIMPLE_LOCATOR_PATH_ELT in a couple of switches
This avoids us having to add new cases in the common case of adding a new simple locator element.
1 parent 26a432d commit 3e34c8c

File tree

2 files changed

+8
-51
lines changed

2 files changed

+8
-51
lines changed

lib/Sema/ConstraintLocator.cpp

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,6 @@ void ConstraintLocator::Profile(llvm::FoldingSetNodeID &id, Expr *anchor,
5252
id.AddPointer(kpElt.getKeyPathDecl());
5353
break;
5454
}
55-
case ApplyArgument:
56-
case ApplyFunction:
57-
case FunctionArgument:
58-
case FunctionResult:
59-
case OptionalPayload:
60-
case Member:
61-
case MemberRefBase:
62-
case UnresolvedMember:
63-
case SubscriptMember:
64-
case ConstructorMember:
65-
case LValueConversion:
66-
case RValueAdjustment:
67-
case ClosureResult:
68-
case ParentType:
69-
case ExistentialSuperclassType:
70-
case InstanceType:
71-
case SequenceElementType:
72-
case AutoclosureResult:
7355
case GenericArgument:
7456
case NamedTupleElement:
7557
case TupleElement:
@@ -78,20 +60,18 @@ void ConstraintLocator::Profile(llvm::FoldingSetNodeID &id, Expr *anchor,
7860
case KeyPathComponent:
7961
case ConditionalRequirement:
8062
case TypeParameterRequirement:
81-
case ImplicitlyUnwrappedDisjunctionChoice:
82-
case DynamicLookupResult:
8363
case ContextualType:
84-
case SynthesizedArgument:
85-
case KeyPathType:
86-
case KeyPathRoot:
87-
case KeyPathValue:
88-
case KeyPathComponentResult:
89-
case Condition:
64+
case SynthesizedArgument: {
9065
auto numValues = numNumericValuesInPathElement(elt.getKind());
9166
for (unsigned i = 0; i < numValues; ++i)
9267
id.AddInteger(elt.getValue(i));
9368
break;
9469
}
70+
#define SIMPLE_LOCATOR_PATH_ELT(Name) case Name :
71+
#include "ConstraintLocatorPathElts.def"
72+
// Nothing to do for simple locator elements.
73+
break;
74+
}
9575
}
9676
}
9777

lib/Sema/ConstraintLocator.h

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -63,34 +63,11 @@ class ConstraintLocator : public llvm::FoldingSetNode {
6363
/// element kind.
6464
static unsigned numNumericValuesInPathElement(PathElementKind kind) {
6565
switch (kind) {
66-
case ApplyArgument:
67-
case ApplyFunction:
66+
#define SIMPLE_LOCATOR_PATH_ELT(Name) case Name :
67+
#include "ConstraintLocatorPathElts.def"
6868
case GenericParameter:
69-
case FunctionArgument:
70-
case FunctionResult:
71-
case OptionalPayload:
72-
case Member:
73-
case MemberRefBase:
74-
case UnresolvedMember:
75-
case SubscriptMember:
76-
case ConstructorMember:
77-
case LValueConversion:
78-
case RValueAdjustment:
79-
case ClosureResult:
80-
case ParentType:
81-
case InstanceType:
82-
case ExistentialSuperclassType:
83-
case SequenceElementType:
84-
case AutoclosureResult:
8569
case ProtocolRequirement:
8670
case Witness:
87-
case ImplicitlyUnwrappedDisjunctionChoice:
88-
case DynamicLookupResult:
89-
case KeyPathType:
90-
case KeyPathRoot:
91-
case KeyPathValue:
92-
case KeyPathComponentResult:
93-
case Condition:
9471
return 0;
9572

9673
case ContextualType:

0 commit comments

Comments
 (0)