@@ -1143,34 +1143,27 @@ void ExtensionDecl::addedMember(Decl *member) {
1143
1143
// MemberLookupTable is constructed (and possibly has entries in it),
1144
1144
// MemberLookupTable is incrementally reconstituted with new members.
1145
1145
1146
- static bool
1146
+ static void
1147
1147
populateLookupTableEntryFromLazyIDCLoader (ASTContext &ctx,
1148
1148
MemberLookupTable &LookupTable,
1149
1149
DeclBaseName name,
1150
1150
IterableDeclContext *IDC) {
1151
1151
auto ci = ctx.getOrCreateLazyIterableContextData (IDC,
1152
1152
/* lazyLoader=*/ nullptr );
1153
- if (auto res = ci->loader ->loadNamedMembers (IDC, name, ci->memberData )) {
1154
- if (auto s = ctx.Stats ) {
1155
- ++s->getFrontendCounters ().NamedLazyMemberLoadSuccessCount ;
1156
- }
1157
- for (auto d : *res) {
1158
- LookupTable.addMember (d);
1159
- }
1160
- return false ;
1161
- } else {
1162
- if (auto s = ctx.Stats ) {
1163
- ++s->getFrontendCounters ().NamedLazyMemberLoadFailureCount ;
1164
- }
1165
- return true ;
1153
+ auto res = ci->loader ->loadNamedMembers (IDC, name, ci->memberData );
1154
+ if (auto s = ctx.Stats ) {
1155
+ ++s->getFrontendCounters ().NamedLazyMemberLoadSuccessCount ;
1156
+ }
1157
+ for (auto d : res) {
1158
+ LookupTable.addMember (d);
1166
1159
}
1167
1160
}
1168
1161
1169
1162
static void
1170
1163
populateLookupTableEntryFromExtensions (ASTContext &ctx,
1171
1164
MemberLookupTable &table,
1172
- NominalTypeDecl *nominal ,
1173
- DeclBaseName name ) {
1165
+ DeclBaseName name ,
1166
+ NominalTypeDecl *nominal ) {
1174
1167
assert (!table.isLazilyComplete (name) &&
1175
1168
" Should not be searching extensions for complete name!" );
1176
1169
@@ -1185,12 +1178,7 @@ populateLookupTableEntryFromExtensions(ASTContext &ctx,
1185
1178
" Extension without deserializable content has lazy members!" );
1186
1179
assert (!e->hasUnparsedMembers ());
1187
1180
1188
- // Try lazy loading. If that fails, then we fall back by loading the
1189
- // entire extension. FIXME: It's rather unfortunate that we fall off the
1190
- // happy path because the Clang Importer can't handle lazy import-as-member.
1191
- if (populateLookupTableEntryFromLazyIDCLoader (ctx, table, name, e)) {
1192
- e->loadAllMembers ();
1193
- }
1181
+ populateLookupTableEntryFromLazyIDCLoader (ctx, table, name, e);
1194
1182
}
1195
1183
}
1196
1184
@@ -1280,55 +1268,44 @@ DirectLookupRequest::evaluate(Evaluator &evaluator,
1280
1268
1281
1269
decl->prepareLookupTable ();
1282
1270
1283
- auto tryCacheLookup =
1284
- [=](MemberLookupTable &table,
1285
- DeclName name) -> Optional<TinyPtrVector<ValueDecl *>> {
1286
- // Look for a declaration with this name.
1287
- auto known = table.find (name);
1288
- if (known == table.end ()) {
1289
- return None;
1290
- }
1291
-
1292
- // We found something; return it.
1293
- return maybeFilterOutAttrImplements (known->second , name,
1294
- includeAttrImplements);
1295
- };
1296
-
1297
- auto updateLookupTable = [&decl](MemberLookupTable &table,
1298
- bool noExtensions) {
1271
+ auto &Table = *decl->LookupTable ;
1272
+ if (!useNamedLazyMemberLoading) {
1299
1273
// Make sure we have the complete list of members (in this nominal and in
1300
1274
// all extensions).
1301
1275
(void )decl->getMembers ();
1302
1276
1303
- if (noExtensions)
1304
- return ;
1305
-
1306
- for (auto E : decl->getExtensions ())
1307
- (void )E->getMembers ();
1277
+ if (!disableAdditionalExtensionLoading) {
1278
+ for (auto E : decl->getExtensions ())
1279
+ (void )E->getMembers ();
1308
1280
1309
- table.updateLookupTable (decl);
1310
- };
1311
-
1312
- auto &Table = *decl->LookupTable ;
1313
- if (!useNamedLazyMemberLoading) {
1314
- updateLookupTable (Table, disableAdditionalExtensionLoading);
1281
+ Table.updateLookupTable (decl);
1282
+ }
1315
1283
} else if (!Table.isLazilyComplete (name.getBaseName ())) {
1316
1284
// The lookup table believes it doesn't have a complete accounting of this
1317
1285
// name - either because we're never seen it before, or another extension
1318
1286
// was registered since the last time we searched. Ask the loaders to give
1319
1287
// us a hand.
1320
1288
DeclBaseName baseName (name.getBaseName ());
1321
- if ( populateLookupTableEntryFromLazyIDCLoader (ctx, Table, baseName, decl)) {
1322
- updateLookupTable (Table, disableAdditionalExtensionLoading);
1323
- } else if (!disableAdditionalExtensionLoading) {
1324
- populateLookupTableEntryFromExtensions (ctx, Table, decl, baseName );
1289
+ populateLookupTableEntryFromLazyIDCLoader (ctx, Table, baseName, decl);
1290
+
1291
+ if (!disableAdditionalExtensionLoading) {
1292
+ populateLookupTableEntryFromExtensions (ctx, Table, baseName, decl );
1325
1293
}
1294
+
1295
+ // FIXME: If disableAdditionalExtensionLoading is true, we should
1296
+ // not mark the entry as complete.
1326
1297
Table.markLazilyComplete (baseName);
1327
1298
}
1328
1299
1329
1300
// Look for a declaration with this name.
1330
- return tryCacheLookup (Table, name)
1331
- .getValueOr (TinyPtrVector<ValueDecl *>());
1301
+ auto known = Table.find (name);
1302
+ if (known == Table.end ()) {
1303
+ return TinyPtrVector<ValueDecl *>();
1304
+ }
1305
+
1306
+ // We found something; return it.
1307
+ return maybeFilterOutAttrImplements (known->second , name,
1308
+ includeAttrImplements);
1332
1309
}
1333
1310
1334
1311
void ClassDecl::createObjCMethodLookup () {
0 commit comments