@@ -1100,41 +1100,9 @@ static llvm::Constant *getObjCEncodingForTypes(IRGenModule &IGM,
1100
1100
return IGM.getAddrOfGlobalString (encodingString);
1101
1101
}
1102
1102
1103
- static llvm::Constant *
1104
- getObjectEncodingFromClangNode (IRGenModule &IGM, Decl *d,
1105
- bool useExtendedEncoding) {
1106
- // Use the clang node's encoding if there is a clang node.
1107
- if (d->getClangNode ()) {
1108
- auto clangDecl = d->getClangNode ().castAsDecl ();
1109
- auto &clangASTContext = IGM.getClangASTContext ();
1110
- std::string typeStr;
1111
- if (auto objcMethodDecl = dyn_cast<clang::ObjCMethodDecl>(clangDecl)) {
1112
- typeStr = clangASTContext.getObjCEncodingForMethodDecl (
1113
- objcMethodDecl, useExtendedEncoding /* extended*/ );
1114
- }
1115
- if (auto objcPropertyDecl = dyn_cast<clang::ObjCPropertyDecl>(clangDecl)) {
1116
- typeStr = clangASTContext.getObjCEncodingForPropertyDecl (objcPropertyDecl,
1117
- nullptr );
1118
- }
1119
- if (!typeStr.empty ()) {
1120
- return IGM.getAddrOfGlobalString (typeStr.c_str ());
1121
- }
1122
- }
1123
- return nullptr ;
1124
- }
1125
-
1126
- static llvm::Constant *getObjCEncodingForMethod (IRGenModule &IGM,
1127
- CanSILFunctionType fnType,
1128
- bool useExtendedEncoding,
1129
- Decl *optionalDecl) {
1130
- // Use the decl's ClangNode to get the encoding if possible.
1131
- if (optionalDecl) {
1132
- if (auto *enc = getObjectEncodingFromClangNode (IGM, optionalDecl,
1133
- useExtendedEncoding)) {
1134
- return enc;
1135
- }
1136
- }
1137
-
1103
+ static llvm::Constant *getObjCEncodingForMethodType (IRGenModule &IGM,
1104
+ CanSILFunctionType fnType,
1105
+ bool useExtendedEncoding) {
1138
1106
// Get the inputs without 'self'.
1139
1107
auto inputs = fnType->getParameters ().drop_back ();
1140
1108
@@ -1160,13 +1128,11 @@ irgen::emitObjCMethodDescriptorParts(IRGenModule &IGM,
1160
1128
// / The first element is the selector.
1161
1129
descriptor.selectorRef = IGM.getAddrOfObjCMethodName (selector.str ());
1162
1130
1163
- // / The second element is the method signature. A method signature is made
1164
- // / of the return type @encoding and every parameter type @encoding, glued
1165
- // / with numbers that used to represent stack offsets for each of these
1166
- // / elements.
1131
+ // / The second element is the method signature. A method signature is made of
1132
+ // / the return type @encoding and every parameter type @encoding, glued with
1133
+ // / numbers that used to represent stack offsets for each of these elements.
1167
1134
CanSILFunctionType methodType = getObjCMethodType (IGM, method);
1168
- descriptor.typeEncoding =
1169
- getObjCEncodingForMethod (IGM, methodType, /* extended*/ false , method);
1135
+ descriptor.typeEncoding = getObjCEncodingForMethodType (IGM, methodType, /* extended*/ false );
1170
1136
1171
1137
// / The third element is the method implementation pointer.
1172
1138
if (!concrete) {
@@ -1225,13 +1191,10 @@ irgen::emitObjCGetterDescriptorParts(IRGenModule &IGM,
1225
1191
Selector getterSel (subscript, Selector::ForGetter);
1226
1192
ObjCMethodDescriptor descriptor{};
1227
1193
descriptor.selectorRef = IGM.getAddrOfObjCMethodName (getterSel.str ());
1228
-
1229
- auto methodTy =
1230
- getObjCMethodType (IGM, subscript->getOpaqueAccessor (AccessorKind::Get));
1231
- descriptor.typeEncoding =
1232
- getObjCEncodingForMethod (IGM, methodTy,
1233
- /* extended*/ false , subscript);
1234
-
1194
+ auto methodTy = getObjCMethodType (IGM,
1195
+ subscript->getOpaqueAccessor (AccessorKind::Get));
1196
+ descriptor.typeEncoding = getObjCEncodingForMethodType (IGM, methodTy,
1197
+ /* extended*/ false );
1235
1198
descriptor.silFunction = nullptr ;
1236
1199
descriptor.impl = getObjCGetterPointer (IGM, subscript,
1237
1200
descriptor.silFunction );
@@ -1303,9 +1266,8 @@ irgen::emitObjCSetterDescriptorParts(IRGenModule &IGM,
1303
1266
descriptor.selectorRef = IGM.getAddrOfObjCMethodName (setterSel.str ());
1304
1267
auto methodTy = getObjCMethodType (IGM,
1305
1268
subscript->getOpaqueAccessor (AccessorKind::Set));
1306
- descriptor.typeEncoding =
1307
- getObjCEncodingForMethod (IGM, methodTy,
1308
- /* extended*/ false , subscript);
1269
+ descriptor.typeEncoding = getObjCEncodingForMethodType (IGM, methodTy,
1270
+ /* extended*/ false );
1309
1271
descriptor.silFunction = nullptr ;
1310
1272
descriptor.impl = getObjCSetterPointer (IGM, subscript,
1311
1273
descriptor.silFunction );
@@ -1361,33 +1323,23 @@ static void emitObjCDescriptor(IRGenModule &IGM,
1361
1323
// / };
1362
1324
void irgen::emitObjCMethodDescriptor (IRGenModule &IGM,
1363
1325
ConstantArrayBuilder &descriptors,
1364
- AbstractFunctionDecl *method,
1365
- llvm::StringSet<> &uniqueSelectors) {
1366
- // Don't emit a selector twice.
1367
- Selector selector (method);
1368
- if (!uniqueSelectors.insert (selector.str ()).second )
1369
- return ;
1370
-
1326
+ AbstractFunctionDecl *method) {
1371
1327
ObjCMethodDescriptor descriptor (
1372
1328
emitObjCMethodDescriptorParts (IGM, method, /* concrete*/ true ));
1373
1329
emitObjCDescriptor (IGM, descriptors, descriptor);
1374
1330
}
1375
1331
1376
- void irgen::emitObjCIVarInitDestroyDescriptor (
1377
- IRGenModule &IGM, ConstantArrayBuilder &descriptors, ClassDecl *cd,
1378
- llvm::Function *objcImpl, bool isDestroyer,
1379
- llvm::StringSet<> &uniqueSelectors) {
1332
+ void irgen::emitObjCIVarInitDestroyDescriptor (IRGenModule &IGM,
1333
+ ConstantArrayBuilder &descriptors,
1334
+ ClassDecl *cd,
1335
+ llvm::Function *objcImpl,
1336
+ bool isDestroyer) {
1380
1337
// / The first element is the selector.
1381
1338
SILDeclRef declRef = SILDeclRef (cd,
1382
1339
isDestroyer? SILDeclRef::Kind::IVarDestroyer
1383
1340
: SILDeclRef::Kind::IVarInitializer,
1384
1341
/* foreign*/ true );
1385
1342
Selector selector (declRef);
1386
-
1387
- // Don't emit a selector twice.
1388
- if (!uniqueSelectors.insert (selector.str ()).second )
1389
- return ;
1390
-
1391
1343
ObjCMethodDescriptor descriptor{};
1392
1344
descriptor.selectorRef = IGM.getAddrOfObjCMethodName (selector.str ());
1393
1345
@@ -1406,18 +1358,11 @@ void irgen::emitObjCIVarInitDestroyDescriptor(
1406
1358
buildMethodDescriptor (IGM, descriptors, descriptor);
1407
1359
}
1408
1360
1409
-
1410
1361
llvm::Constant *
1411
1362
irgen::getMethodTypeExtendedEncoding (IRGenModule &IGM,
1412
- AbstractFunctionDecl *method,
1413
- llvm::StringSet<> &uniqueSelectors) {
1414
- // Don't emit a selector twice.
1415
- Selector selector (method);
1416
- if (!uniqueSelectors.insert (selector.str ()).second )
1417
- return nullptr ;
1418
-
1363
+ AbstractFunctionDecl *method) {
1419
1364
CanSILFunctionType methodType = getObjCMethodType (IGM, method);
1420
- return getObjCEncodingForMethod (IGM, methodType, true /* Extended*/ , method );
1365
+ return getObjCEncodingForMethodType (IGM, methodType, true /* Extended*/ );
1421
1366
}
1422
1367
1423
1368
llvm::Constant *
0 commit comments