@@ -50,6 +50,10 @@ public struct TypeQualifiers
50
50
public bool IsConst ;
51
51
public bool IsVolatile ;
52
52
public bool IsRestrict ;
53
+
54
+ public override int GetHashCode ( ) =>
55
+ IsConst . GetHashCode ( ) ^ IsVolatile . GetHashCode ( ) ^
56
+ IsRestrict . GetHashCode ( ) ;
53
57
}
54
58
55
59
/// <summary>
@@ -101,10 +105,8 @@ public override bool Equals(object obj)
101
105
return ! ( left == right ) ;
102
106
}
103
107
104
- public override int GetHashCode ( )
105
- {
106
- return base . GetHashCode ( ) ;
107
- }
108
+ public override int GetHashCode ( ) => Type == null ?
109
+ Qualifiers . GetHashCode ( ) : Type . GetHashCode ( ) ^ Qualifiers . GetHashCode ( ) ;
108
110
}
109
111
110
112
/// <summary>
@@ -147,10 +149,7 @@ public override bool Equals(object obj)
147
149
return Declaration . Equals ( type . Declaration ) ;
148
150
}
149
151
150
- public override int GetHashCode ( )
151
- {
152
- return base . GetHashCode ( ) ;
153
- }
152
+ public override int GetHashCode ( ) => Declaration . GetHashCode ( ) ;
154
153
}
155
154
156
155
/// <summary>
@@ -220,7 +219,8 @@ public override bool Equals(object obj)
220
219
221
220
public override int GetHashCode ( )
222
221
{
223
- return base . GetHashCode ( ) ;
222
+ return QualifiedType . GetHashCode ( ) ^ SizeType . GetHashCode ( ) ^
223
+ Size . GetHashCode ( ) ^ ElementSize . GetHashCode ( ) ;
224
224
}
225
225
}
226
226
@@ -285,10 +285,11 @@ public override bool Equals(object obj)
285
285
return ReturnType . Equals ( type . ReturnType ) && Parameters . SequenceEqual ( type . Parameters ) ;
286
286
}
287
287
288
- public override int GetHashCode ( )
289
- {
290
- return base . GetHashCode ( ) ;
291
- }
288
+ public override int GetHashCode ( ) =>
289
+ Parameters . Aggregate ( ReturnType . GetHashCode ( ) ,
290
+ ( p1 , p2 ) => p1 . GetHashCode ( ) ^ p2 . GetHashCode ( ) ) ^
291
+ CallingConvention . GetHashCode ( ) ^
292
+ ExceptionSpecType . GetHashCode ( ) ;
292
293
}
293
294
294
295
/// <summary>
@@ -360,10 +361,8 @@ public override bool Equals(object obj)
360
361
&& Modifier == type . Modifier ;
361
362
}
362
363
363
- public override int GetHashCode ( )
364
- {
365
- return base . GetHashCode ( ) ;
366
- }
364
+ public override int GetHashCode ( ) =>
365
+ QualifiedPointee . GetHashCode ( ) ^ Modifier . GetHashCode ( ) ;
367
366
}
368
367
369
368
/// <summary>
@@ -407,10 +406,7 @@ public override bool Equals(object obj)
407
406
return QualifiedPointee . Equals ( pointer . QualifiedPointee ) ;
408
407
}
409
408
410
- public override int GetHashCode ( )
411
- {
412
- return base . GetHashCode ( ) ;
413
- }
409
+ public override int GetHashCode ( ) => QualifiedPointee . GetHashCode ( ) ;
414
410
}
415
411
416
412
/// <summary>
@@ -451,10 +447,7 @@ public override bool Equals(object obj)
451
447
return Declaration . Type . Equals ( typedef == null ? obj : typedef . Declaration . Type ) ;
452
448
}
453
449
454
- public override int GetHashCode ( )
455
- {
456
- return base . GetHashCode ( ) ;
457
- }
450
+ public override int GetHashCode ( ) => Declaration . Type . GetHashCode ( ) ;
458
451
}
459
452
460
453
/// <summary>
@@ -508,10 +501,8 @@ public override bool Equals(object obj)
508
501
&& Equivalent . Equals ( attributed . Equivalent ) ;
509
502
}
510
503
511
- public override int GetHashCode ( )
512
- {
513
- return base . GetHashCode ( ) ;
514
- }
504
+ public override int GetHashCode ( ) =>
505
+ Modified . GetHashCode ( ) ^ Equivalent . GetHashCode ( ) ;
515
506
}
516
507
517
508
/// <summary>
@@ -530,12 +521,16 @@ public DecayedType()
530
521
public DecayedType ( DecayedType type )
531
522
: base ( type )
532
523
{
533
- Decayed = new QualifiedType ( ( Type ) type . Decayed . Type . Clone ( ) , type . Decayed . Qualifiers ) ;
534
- Original = new QualifiedType ( ( Type ) type . Original . Type . Clone ( ) , type . Original . Qualifiers ) ;
535
- Pointee = new QualifiedType ( ( Type ) type . Pointee . Type . Clone ( ) , type . Pointee . Qualifiers ) ;
524
+ Decayed = new QualifiedType ( ( Type ) type . Decayed . Type . Clone ( ) ,
525
+ type . Decayed . Qualifiers ) ;
526
+ Original = new QualifiedType ( ( Type ) type . Original . Type . Clone ( ) ,
527
+ type . Original . Qualifiers ) ;
528
+ Pointee = new QualifiedType ( ( Type ) type . Pointee . Type . Clone ( ) ,
529
+ type . Pointee . Qualifiers ) ;
536
530
}
537
531
538
- public override T Visit < T > ( ITypeVisitor < T > visitor , TypeQualifiers quals = new TypeQualifiers ( ) )
532
+ public override T Visit < T > ( ITypeVisitor < T > visitor ,
533
+ TypeQualifiers quals = new TypeQualifiers ( ) )
539
534
{
540
535
return visitor . VisitDecayedType ( this , quals ) ;
541
536
}
@@ -553,10 +548,9 @@ public override bool Equals(object obj)
553
548
return Original . Equals ( decay . Original ) ;
554
549
}
555
550
556
- public override int GetHashCode ( )
557
- {
558
- return base . GetHashCode ( ) ;
559
- }
551
+ public override int GetHashCode ( ) =>
552
+ Decayed . GetHashCode ( ) ^ Original . GetHashCode ( ) ^
553
+ Pointee . GetHashCode ( ) ;
560
554
}
561
555
562
556
/// <summary>
@@ -724,10 +718,10 @@ public override bool Equals(object obj)
724
718
( Desugared . Type != null && Desugared == type . Desugared ) ) ;
725
719
}
726
720
727
- public override int GetHashCode ( )
728
- {
729
- return base . GetHashCode ( ) ;
730
- }
721
+ public override int GetHashCode ( ) =>
722
+ Arguments . Aggregate ( Template . GetHashCode ( ) ,
723
+ ( a1 , a2 ) => a1 . GetHashCode ( ) ^ a2 . GetHashCode ( ) ) ^
724
+ Desugared . GetHashCode ( ) ;
731
725
}
732
726
733
727
/// <summary>
@@ -778,10 +772,9 @@ public override bool Equals(object obj)
778
772
Desugared == type . Desugared ;
779
773
}
780
774
781
- public override int GetHashCode ( )
782
- {
783
- return base . GetHashCode ( ) ;
784
- }
775
+ public override int GetHashCode ( ) =>
776
+ Arguments . Aggregate ( Desugared . GetHashCode ( ) ,
777
+ ( a1 , a2 ) => a1 . GetHashCode ( ) ^ a2 . GetHashCode ( ) ) ;
785
778
}
786
779
787
780
/// <summary>
@@ -834,10 +827,12 @@ public override bool Equals(object obj)
834
827
&& IsParameterPack == type . IsParameterPack ;
835
828
}
836
829
837
- public override int GetHashCode ( )
838
- {
839
- return base . GetHashCode ( ) ;
840
- }
830
+ public override int GetHashCode ( ) =>
831
+ Parameter == null ?
832
+ Depth . GetHashCode ( ) ^ Index . GetHashCode ( ) ^
833
+ IsParameterPack . GetHashCode ( ) :
834
+ Parameter . GetHashCode ( ) ^ Depth . GetHashCode ( ) ^
835
+ Index . GetHashCode ( ) ^ IsParameterPack . GetHashCode ( ) ;
841
836
}
842
837
843
838
/// <summary>
@@ -879,10 +874,7 @@ public override bool Equals(object obj)
879
874
return Replacement . Equals ( type . Replacement ) ;
880
875
}
881
876
882
- public override int GetHashCode ( )
883
- {
884
- return base . GetHashCode ( ) ;
885
- }
877
+ public override int GetHashCode ( ) => Replacement . GetHashCode ( ) ;
886
878
}
887
879
888
880
/// <summary>
@@ -933,10 +925,11 @@ public override bool Equals(object obj)
933
925
&& Class . Equals ( type . Class ) ;
934
926
}
935
927
936
- public override int GetHashCode ( )
937
- {
938
- return base . GetHashCode ( ) ;
939
- }
928
+ public override int GetHashCode ( ) =>
929
+ TemplateSpecialization != null && Class != null
930
+ ? TemplateSpecialization . GetHashCode ( ) ^ Class . GetHashCode ( )
931
+ : TemplateSpecialization != null ? TemplateSpecialization . GetHashCode ( )
932
+ : Class . GetHashCode ( ) ;
940
933
}
941
934
942
935
/// <summary>
@@ -967,6 +960,9 @@ public override object Clone()
967
960
{
968
961
return new DependentNameType ( this ) ;
969
962
}
963
+
964
+ public override int GetHashCode ( ) =>
965
+ Qualifier . GetHashCode ( ) ^ Identifier . GetHashCode ( ) ;
970
966
}
971
967
972
968
/// <summary>
@@ -1010,10 +1006,7 @@ public override bool Equals(object obj)
1010
1006
return Type == type . Type ;
1011
1007
}
1012
1008
1013
- public override int GetHashCode ( )
1014
- {
1015
- return base . GetHashCode ( ) ;
1016
- }
1009
+ public override int GetHashCode ( ) => Type . GetHashCode ( ) ;
1017
1010
}
1018
1011
1019
1012
public class PackExpansionType : Type
@@ -1063,6 +1056,9 @@ public override object Clone()
1063
1056
{
1064
1057
return new UnaryTransformType ( this ) ;
1065
1058
}
1059
+
1060
+ public override int GetHashCode ( ) =>
1061
+ Desugared . GetHashCode ( ) ^ BaseType . GetHashCode ( ) ;
1066
1062
}
1067
1063
1068
1064
public class VectorType : Type
@@ -1088,6 +1084,9 @@ public override object Clone()
1088
1084
{
1089
1085
return new VectorType ( this ) ;
1090
1086
}
1087
+
1088
+ public override int GetHashCode ( ) =>
1089
+ ElementType . GetHashCode ( ) ^ NumElements . GetHashCode ( ) ;
1091
1090
}
1092
1091
1093
1092
public class UnsupportedType : Type
@@ -1117,6 +1116,8 @@ public override object Clone()
1117
1116
{
1118
1117
return new UnsupportedType ( this ) ;
1119
1118
}
1119
+
1120
+ public override int GetHashCode ( ) => Description . GetHashCode ( ) ;
1120
1121
}
1121
1122
1122
1123
public class CustomType : UnsupportedType
@@ -1223,10 +1224,7 @@ public override bool Equals(object obj)
1223
1224
return Type == type . Type ;
1224
1225
}
1225
1226
1226
- public override int GetHashCode ( )
1227
- {
1228
- return base . GetHashCode ( ) ;
1229
- }
1227
+ public override int GetHashCode ( ) => Type . GetHashCode ( ) ;
1230
1228
}
1231
1229
1232
1230
#endregion
0 commit comments