@@ -184,17 +184,17 @@ class SymbolSearchContext {
184184public:
185185 SymbolSearchContext (SymbolQuery &Q) : Q(Q) {}
186186
187- bool hasSearched (LibraryInfo *Lib) const { return Searched.count (Lib); }
187+ bool hasSearched (const LibraryInfo *Lib) const { return Searched.count (Lib); }
188188
189- void markSearched (LibraryInfo *Lib) { Searched.insert (Lib); }
189+ void markSearched (const LibraryInfo *Lib) { Searched.insert (Lib); }
190190
191191 inline bool allResolved () const { return Q.allResolved (); }
192192
193193 SymbolQuery &query () { return Q; }
194194
195195private:
196196 SymbolQuery &Q;
197- DenseSet<LibraryInfo *> Searched;
197+ DenseSet<const LibraryInfo *> Searched;
198198};
199199
200200void LibraryResolver::resolveSymbolsInLibrary (
@@ -226,19 +226,18 @@ void LibraryResolver::resolveSymbolsInLibrary(
226226 return EnumerateResult::Continue;
227227 },
228228 Opts);
229+ };
229230
231+ if (!Lib.hasFilter ()) {
232+ LLVM_DEBUG (dbgs () << " Building filter for library: " << Lib.getFullPath ()
233+ << " \n " ;);
234+ enumerateSymbolsIfNeeded ();
230235 if (DiscoveredSymbols.empty ()) {
231236 LLVM_DEBUG (dbgs () << " No symbols and remove library : "
232237 << Lib.getFullPath () << " \n " ;);
233238 LibMgr.removeLibrary (Lib.getFullPath ());
234239 return ;
235240 }
236- };
237-
238- if (!Lib.hasFilter ()) {
239- LLVM_DEBUG (dbgs () << " Building filter for library: " << Lib.getFullPath ()
240- << " \n " ;);
241- enumerateSymbolsIfNeeded ();
242241 SmallVector<StringRef> SymbolVec;
243242 SymbolVec.reserve (DiscoveredSymbols.size ());
244243 for (const auto &KV : DiscoveredSymbols)
@@ -288,24 +287,22 @@ void LibraryResolver::searchSymbolsInLibraries(
288287
289288 SymbolSearchContext Ctx (Q);
290289 while (!Ctx.allResolved ()) {
290+ std::vector<std::shared_ptr<LibraryInfo>> Libs;
291+ LibMgr.getLibraries (S, K, Libs, [&](const LibraryInfo &Lib) {
292+ return !Ctx.hasSearched (&Lib);
293+ });
291294
292- for (auto &Lib : LibMgr.getView (S, K)) {
293- if (Ctx.hasSearched (Lib.get ()))
294- continue ;
295+ if (Libs.empty () && !scanLibrariesIfNeeded (K, scanBatchSize))
296+ break ; // no more new libs to scan
295297
298+ for (auto &Lib : Libs) {
296299 // can use Async here?
297300 resolveSymbolsInLibrary (*Lib, Ctx.query (), Config.Options );
298301 Ctx.markSearched (Lib.get ());
299302
300303 if (Ctx.allResolved ())
301304 return ;
302305 }
303-
304- if (Ctx.allResolved ())
305- return ;
306-
307- if (!scanLibrariesIfNeeded (K, scanBatchSize))
308- break ; // no more new libs to scan
309306 }
310307 };
311308
0 commit comments