@@ -906,11 +906,11 @@ static void witnessTableInstantiator(WitnessTable *instantiatedTable,
906
906
void * const *instantiationArgs) {
907
907
EXPECT_EQ (type, nullptr );
908
908
909
- EXPECT_EQ (((void **) instantiatedTable)[0 ], (void *) 123 );
910
- EXPECT_EQ (((void **) instantiatedTable)[1 ], (void *) 234 );
909
+ EXPECT_EQ (((void **) instantiatedTable)[1 ], (void *) 123 );
910
+ EXPECT_EQ (((void **) instantiatedTable)[2 ], (void *) 234 );
911
911
912
912
// The last witness is computed dynamically at instantiation time.
913
- ((void **) instantiatedTable)[2 ] = (void *) 345 ;
913
+ ((void **) instantiatedTable)[3 ] = (void *) 345 ;
914
914
915
915
auto conditionalTables =
916
916
reinterpret_cast <const WitnessTableSlice *>(instantiationArgs);
@@ -937,8 +937,8 @@ struct TestProtocol {
937
937
: descriptor(" TestProtocol" ,
938
938
nullptr ,
939
939
ProtocolDescriptorFlags ().withResilient(true )) {
940
- descriptor.NumMandatoryRequirements = 3 ;
941
- descriptor.NumRequirements = 5 ;
940
+ descriptor.NumMandatoryRequirements = 4 ;
941
+ descriptor.NumRequirements = 6 ;
942
942
initializeRelativePointer (
943
943
(int32_t *) &descriptor.Requirements ,
944
944
requirements);
@@ -975,6 +975,7 @@ GenericWitnessTable::PrivateDataType tablePrivateData3;
975
975
GenericWitnessTable::PrivateDataType tablePrivateData4;
976
976
977
977
const void *witnesses[] = {
978
+ (void *) 0 , // protocol descriptor
978
979
(void *) 123 ,
979
980
(void *) 234 ,
980
981
(void *) 0 , // filled in by instantiator function
@@ -996,7 +997,7 @@ TEST(WitnessTableTest, getGenericWitnessTable) {
996
997
// Conformance provides all requirements, and we don't have an
997
998
// instantiator, so we can just return the pattern.
998
999
{
999
- tableStorage1.WitnessTableSizeInWords = 5 ;
1000
+ tableStorage1.WitnessTableSizeInWords = 6 ;
1000
1001
tableStorage1.WitnessTablePrivateSizeInWords = 0 ;
1001
1002
initializeRelativePointer (&tableStorage1.Protocol , &testProtocol.descriptor );
1002
1003
initializeRelativePointer (&tableStorage1.Pattern , witnesses);
@@ -1019,7 +1020,7 @@ TEST(WitnessTableTest, getGenericWitnessTable) {
1019
1020
// Conformance provides all requirements, but we have private storage
1020
1021
// and an initializer, so we must instantiate.
1021
1022
{
1022
- tableStorage2.WitnessTableSizeInWords = 5 ;
1023
+ tableStorage2.WitnessTableSizeInWords = 6 ;
1023
1024
tableStorage2.WitnessTablePrivateSizeInWords = 1 + 1 ;
1024
1025
initializeRelativePointer (&tableStorage2.Protocol , &testProtocol.descriptor );
1025
1026
initializeRelativePointer (&tableStorage2.Pattern , witnesses);
@@ -1042,15 +1043,15 @@ TEST(WitnessTableTest, getGenericWitnessTable) {
1042
1043
EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[-1 ],
1043
1044
reinterpret_cast <void *>(678 ));
1044
1045
1045
- EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[0 ],
1046
- reinterpret_cast <void *>(123 ));
1047
1046
EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[1 ],
1048
- reinterpret_cast <void *>(234 ));
1047
+ reinterpret_cast <void *>(123 ));
1049
1048
EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[2 ],
1050
- reinterpret_cast <void *>(345 ));
1049
+ reinterpret_cast <void *>(234 ));
1051
1050
EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[3 ],
1052
- reinterpret_cast <void *>(456 ));
1051
+ reinterpret_cast <void *>(345 ));
1053
1052
EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[4 ],
1053
+ reinterpret_cast <void *>(456 ));
1054
+ EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[5 ],
1054
1055
reinterpret_cast <void *>(567 ));
1055
1056
1056
1057
return instantiatedTable;
@@ -1059,7 +1060,7 @@ TEST(WitnessTableTest, getGenericWitnessTable) {
1059
1060
1060
1061
// Conformance needs one default requirement to be filled in
1061
1062
{
1062
- tableStorage3.WitnessTableSizeInWords = 4 ;
1063
+ tableStorage3.WitnessTableSizeInWords = 5 ;
1063
1064
tableStorage3.WitnessTablePrivateSizeInWords = 1 + 1 ;
1064
1065
initializeRelativePointer (&tableStorage3.Protocol , &testProtocol.descriptor );
1065
1066
initializeRelativePointer (&tableStorage3.Pattern , witnesses);
@@ -1081,15 +1082,15 @@ TEST(WitnessTableTest, getGenericWitnessTable) {
1081
1082
EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[-1 ],
1082
1083
reinterpret_cast <void *>(678 ));
1083
1084
1084
- EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[0 ],
1085
- reinterpret_cast <void *>(123 ));
1086
1085
EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[1 ],
1087
- reinterpret_cast <void *>(234 ));
1086
+ reinterpret_cast <void *>(123 ));
1088
1087
EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[2 ],
1089
- reinterpret_cast <void *>(345 ));
1088
+ reinterpret_cast <void *>(234 ));
1090
1089
EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[3 ],
1091
- reinterpret_cast <void *>(456 ));
1090
+ reinterpret_cast <void *>(345 ));
1092
1091
EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[4 ],
1092
+ reinterpret_cast <void *>(456 ));
1093
+ EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[5 ],
1093
1094
reinterpret_cast <void *>(fakeDefaultWitness2));
1094
1095
1095
1096
return instantiatedTable;
@@ -1099,7 +1100,7 @@ TEST(WitnessTableTest, getGenericWitnessTable) {
1099
1100
// Third case: conformance needs both default requirements
1100
1101
// to be filled in
1101
1102
{
1102
- tableStorage4.WitnessTableSizeInWords = 3 ;
1103
+ tableStorage4.WitnessTableSizeInWords = 4 ;
1103
1104
tableStorage4.WitnessTablePrivateSizeInWords = 1 + 1 ;
1104
1105
initializeRelativePointer (&tableStorage4.Protocol , &testProtocol.descriptor );
1105
1106
initializeRelativePointer (&tableStorage4.Pattern , witnesses);
@@ -1121,15 +1122,15 @@ TEST(WitnessTableTest, getGenericWitnessTable) {
1121
1122
EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[-1 ],
1122
1123
reinterpret_cast <void *>(678 ));
1123
1124
1124
- EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[0 ],
1125
- reinterpret_cast <void *>(123 ));
1126
1125
EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[1 ],
1127
- reinterpret_cast <void *>(234 ));
1126
+ reinterpret_cast <void *>(123 ));
1128
1127
EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[2 ],
1129
- reinterpret_cast <void *>(345 ));
1128
+ reinterpret_cast <void *>(234 ));
1130
1129
EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[3 ],
1131
- reinterpret_cast <void *>(fakeDefaultWitness1 ));
1130
+ reinterpret_cast <void *>(345 ));
1132
1131
EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[4 ],
1132
+ reinterpret_cast <void *>(fakeDefaultWitness1));
1133
+ EXPECT_EQ (reinterpret_cast <void * const *>(instantiatedTable)[5 ],
1133
1134
reinterpret_cast <void *>(fakeDefaultWitness2));
1134
1135
1135
1136
return instantiatedTable;
0 commit comments