@@ -1143,34 +1143,27 @@ void ExtensionDecl::addedMember(Decl *member) {
11431143// MemberLookupTable is constructed (and possibly has entries in it),
11441144// MemberLookupTable is incrementally reconstituted with new members.
11451145
1146- static bool
1146+ static void
11471147populateLookupTableEntryFromLazyIDCLoader (ASTContext &ctx,
11481148 MemberLookupTable &LookupTable,
11491149 DeclBaseName name,
11501150 IterableDeclContext *IDC) {
11511151 auto ci = ctx.getOrCreateLazyIterableContextData (IDC,
11521152 /* 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);
11661159 }
11671160}
11681161
11691162static void
11701163populateLookupTableEntryFromExtensions (ASTContext &ctx,
11711164 MemberLookupTable &table,
1172- NominalTypeDecl *nominal ,
1173- DeclBaseName name ) {
1165+ DeclBaseName name ,
1166+ NominalTypeDecl *nominal ) {
11741167 assert (!table.isLazilyComplete (name) &&
11751168 " Should not be searching extensions for complete name!" );
11761169
@@ -1185,12 +1178,7 @@ populateLookupTableEntryFromExtensions(ASTContext &ctx,
11851178 " Extension without deserializable content has lazy members!" );
11861179 assert (!e->hasUnparsedMembers ());
11871180
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);
11941182 }
11951183}
11961184
@@ -1280,55 +1268,44 @@ DirectLookupRequest::evaluate(Evaluator &evaluator,
12801268
12811269 decl->prepareLookupTable ();
12821270
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) {
12991273 // Make sure we have the complete list of members (in this nominal and in
13001274 // all extensions).
13011275 (void )decl->getMembers ();
13021276
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 ();
13081280
1309- table.updateLookupTable (decl);
1310- };
1311-
1312- auto &Table = *decl->LookupTable ;
1313- if (!useNamedLazyMemberLoading) {
1314- updateLookupTable (Table, disableAdditionalExtensionLoading);
1281+ Table.updateLookupTable (decl);
1282+ }
13151283 } else if (!Table.isLazilyComplete (name.getBaseName ())) {
13161284 // The lookup table believes it doesn't have a complete accounting of this
13171285 // name - either because we're never seen it before, or another extension
13181286 // was registered since the last time we searched. Ask the loaders to give
13191287 // us a hand.
13201288 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 );
13251293 }
1294+
1295+ // FIXME: If disableAdditionalExtensionLoading is true, we should
1296+ // not mark the entry as complete.
13261297 Table.markLazilyComplete (baseName);
13271298 }
13281299
13291300 // 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);
13321309}
13331310
13341311void ClassDecl::createObjCMethodLookup () {
0 commit comments