@@ -42,7 +42,8 @@ struct Symbol::Storage final
42
42
public llvm::TrailingObjects<Storage, unsigned , Term> {
43
43
friend class Symbol ;
44
44
45
- llvm::PointerIntPair<const ProtocolDecl *, 3 > ProtoAndKind;
45
+ Symbol::Kind Kind;
46
+ const ProtocolDecl *Proto = nullptr ;
46
47
47
48
union {
48
49
Identifier Name;
@@ -52,26 +53,28 @@ struct Symbol::Storage final
52
53
};
53
54
54
55
explicit Storage (Identifier name) {
55
- ProtoAndKind. setInt ( unsigned ( Symbol::Kind::Name)) ;
56
+ Kind = Symbol::Kind::Name;
56
57
Name = name;
57
58
}
58
59
59
60
explicit Storage (LayoutConstraint layout) {
60
- ProtoAndKind. setInt ( unsigned ( Symbol::Kind::Layout)) ;
61
+ Kind = Symbol::Kind::Layout;
61
62
Layout = layout;
62
63
}
63
64
64
65
explicit Storage (const ProtocolDecl *proto) {
65
- ProtoAndKind.setPointerAndInt (proto, unsigned (Symbol::Kind::Protocol));
66
+ Kind = Symbol::Kind::Protocol;
67
+ Proto = proto;
66
68
}
67
69
68
70
explicit Storage (GenericTypeParamType *param) {
69
- ProtoAndKind. setInt ( unsigned ( Symbol::Kind::GenericParam)) ;
71
+ Kind = Symbol::Kind::GenericParam;
70
72
GenericParam = param;
71
73
}
72
74
73
75
Storage (const ProtocolDecl *proto, Identifier name) {
74
- ProtoAndKind.setPointerAndInt (proto, unsigned (Symbol::Kind::AssociatedType));
76
+ Kind = Symbol::Kind::AssociatedType;
77
+ Proto = proto;
75
78
Name = name;
76
79
}
77
80
@@ -82,7 +85,7 @@ struct Symbol::Storage final
82
85
assert (!type->hasTypeVariable ());
83
86
assert (type->hasTypeParameter () != substitutions.empty ());
84
87
85
- ProtoAndKind. setInt ( unsigned ( kind)) ;
88
+ Kind = kind;
86
89
ConcreteType = type;
87
90
88
91
*getTrailingObjects<unsigned >() = substitutions.size ();
@@ -95,7 +98,8 @@ struct Symbol::Storage final
95
98
assert (!type->hasTypeVariable ());
96
99
assert (type->hasTypeParameter () != substitutions.empty ());
97
100
98
- ProtoAndKind.setPointerAndInt (proto, unsigned (Symbol::Kind::ConcreteConformance));
101
+ Kind = Symbol::Kind::ConcreteConformance;
102
+ Proto = proto;
99
103
100
104
*getTrailingObjects<unsigned >() = substitutions.size ();
101
105
ConcreteType = type;
@@ -105,10 +109,9 @@ struct Symbol::Storage final
105
109
}
106
110
107
111
size_t numTrailingObjects (OverloadToken<unsigned >) const {
108
- auto kind = Symbol::Kind (ProtoAndKind.getInt ());
109
- return (kind == Symbol::Kind::Superclass ||
110
- kind == Symbol::Kind::ConcreteType ||
111
- kind == Symbol::Kind::ConcreteConformance);
112
+ return (Kind == Symbol::Kind::Superclass ||
113
+ Kind == Symbol::Kind::ConcreteType ||
114
+ Kind == Symbol::Kind::ConcreteConformance);
112
115
}
113
116
114
117
size_t numTrailingObjects (OverloadToken<Term>) const {
@@ -132,7 +135,7 @@ struct Symbol::Storage final
132
135
};
133
136
134
137
Symbol::Kind Symbol::getKind () const {
135
- return Kind ( Ptr->ProtoAndKind . getInt ()) ;
138
+ return Ptr->Kind ;
136
139
}
137
140
138
141
// / Get the identifier associated with an unbound name symbol or an
@@ -149,7 +152,7 @@ const ProtocolDecl *Symbol::getProtocol() const {
149
152
assert (getKind () == Kind::Protocol ||
150
153
getKind () == Kind::AssociatedType ||
151
154
getKind () == Kind::ConcreteConformance);
152
- return Ptr->ProtoAndKind . getPointer () ;
155
+ return Ptr->Proto ;
153
156
}
154
157
155
158
// / Get the generic parameter associated with a generic parameter symbol.
@@ -441,6 +444,7 @@ const ProtocolDecl *Symbol::getRootProtocol() const {
441
444
case Symbol::Kind::Superclass:
442
445
case Symbol::Kind::ConcreteType:
443
446
case Symbol::Kind::ConcreteConformance:
447
+ case Symbol::Kind::Shape:
444
448
break ;
445
449
}
446
450
@@ -512,6 +516,7 @@ Optional<int> Symbol::compare(Symbol other, RewriteContext &ctx) const {
512
516
break ;
513
517
}
514
518
519
+ case Kind::Shape:
515
520
case Kind::GenericParam: {
516
521
auto *param = getGenericParam ();
517
522
auto *otherParam = other.getGenericParam ();
@@ -593,6 +598,7 @@ Symbol Symbol::withConcreteSubstitutions(
593
598
case Kind::Name:
594
599
case Kind::Protocol:
595
600
case Kind::AssociatedType:
601
+ case Kind::Shape:
596
602
case Kind::Layout:
597
603
break ;
598
604
}
@@ -710,15 +716,20 @@ void Symbol::dump(llvm::raw_ostream &out) const {
710
716
out << getProtocol ()->getName ();
711
717
out << " ]" ;
712
718
return ;
719
+
720
+ case Kind::Shape: {
721
+ out << " [shape]" ;
722
+ return ;
723
+ }
713
724
}
714
725
715
726
llvm_unreachable (" Bad symbol kind" );
716
727
}
717
728
718
729
void Symbol::Storage::Profile (llvm::FoldingSetNodeID &id) const {
719
- id.AddInteger (ProtoAndKind. getInt ( ));
730
+ id.AddInteger (unsigned (Kind ));
720
731
721
- switch (Symbol:: Kind(ProtoAndKind. getInt ()) ) {
732
+ switch (Kind) {
722
733
case Symbol::Kind::Name:
723
734
id.AddPointer (Name.get ());
724
735
return ;
@@ -728,15 +739,19 @@ void Symbol::Storage::Profile(llvm::FoldingSetNodeID &id) const {
728
739
return ;
729
740
730
741
case Symbol::Kind::Protocol:
731
- id.AddPointer (ProtoAndKind. getPointer () );
742
+ id.AddPointer (Proto );
732
743
return ;
733
744
734
745
case Symbol::Kind::GenericParam:
735
746
id.AddPointer (GenericParam);
736
747
return ;
737
748
749
+ case Symbol::Kind::Shape:
750
+ // Nothing more to add.
751
+ return ;
752
+
738
753
case Symbol::Kind::AssociatedType: {
739
- id.AddPointer (ProtoAndKind. getPointer () );
754
+ id.AddPointer (Proto );
740
755
id.AddPointer (Name.get ());
741
756
return ;
742
757
}
@@ -752,7 +767,7 @@ void Symbol::Storage::Profile(llvm::FoldingSetNodeID &id) const {
752
767
}
753
768
754
769
case Symbol::Kind::ConcreteConformance: {
755
- id.AddPointer (ProtoAndKind. getPointer () );
770
+ id.AddPointer (Proto );
756
771
id.AddPointer (ConcreteType.getPointer ());
757
772
758
773
id.AddInteger (getNumSubstitutions ());
@@ -764,4 +779,4 @@ void Symbol::Storage::Profile(llvm::FoldingSetNodeID &id) const {
764
779
}
765
780
766
781
llvm_unreachable (" Bad symbol kind" );
767
- }
782
+ }
0 commit comments