@@ -352,22 +352,33 @@ void StoreUnitRepo::registerUnit(StringRef unitName) {
352
352
CanonicalFilePath CanonSysroot = CanonPathCache->getCanonicalPath (Reader.getSysrootPath (), WorkDir);
353
353
unitImport.setSysroot (CanonSysroot);
354
354
355
- // Collect the newly discovered records and process them outside of the libIndexStore callback.
355
+ // Collect the dependency info and process them outside of the libIndexStore callback.
356
356
// This is because processing populates the database and C++ exceptions can be thrown; libIndexStore builds with -fno-exceptions so we cannot
357
357
// be throwing C++ exceptions from inside its frames.
358
- SmallVector<StoreSymbolRecordRef, 16 > newStoreRecords;
359
-
358
+ struct UnitDependencyInfo {
359
+ IndexUnitDependency::DependencyKind Kind;
360
+ bool IsSystem;
361
+ std::string FilePath;
362
+ std::string Name;
363
+ std::string ModuleName;
364
+ };
365
+ SmallVector<UnitDependencyInfo, 16 > dependencies;
360
366
Reader.foreachDependency ([&](IndexUnitDependency Dep)->bool {
361
- switch (Dep.getKind ()) {
367
+ dependencies.push_back (UnitDependencyInfo{Dep.getKind (), Dep.isSystem (), Dep.getFilePath (), Dep.getName (), Dep.getModuleName ()});
368
+ return true ;
369
+ });
370
+
371
+ for (const UnitDependencyInfo &dep : dependencies) {
372
+ switch (dep.Kind ) {
362
373
case IndexUnitDependency::DependencyKind::Record: {
363
- CanonicalFilePath CanonPath = CanonPathCache->getCanonicalPath (Dep. getFilePath () , WorkDir);
374
+ CanonicalFilePath CanonPath = CanonPathCache->getCanonicalPath (dep. FilePath , WorkDir);
364
375
if (CanonPath.empty ())
365
376
break ;
366
377
367
- if (!Dep. isSystem () )
378
+ if (!dep. IsSystem )
368
379
UserFileDepends.push_back (CanonPath);
369
- StringRef recordName = Dep. getName () ;
370
- StringRef moduleName = Dep. getModuleName () ;
380
+ StringRef recordName = dep. Name ;
381
+ StringRef moduleName = dep. ModuleName ;
371
382
if (moduleName.empty ()) {
372
383
// Workaround for swift compiler not associating the module name with records of swift files.
373
384
// FIXME: Fix this on swift compiler and remove this.
@@ -376,7 +387,7 @@ void StoreUnitRepo::registerUnit(StringRef unitName) {
376
387
}
377
388
}
378
389
bool isNewProvider;
379
- IDCode providerCode = unitImport.addProviderDependency (recordName, CanonPath, moduleName, Dep. isSystem () , &isNewProvider);
390
+ IDCode providerCode = unitImport.addProviderDependency (recordName, CanonPath, moduleName, dep. IsSystem , &isNewProvider);
380
391
if (!isNewProvider)
381
392
break ;
382
393
@@ -387,32 +398,27 @@ void StoreUnitRepo::registerUnit(StringRef unitName) {
387
398
break ;
388
399
}
389
400
390
- newStoreRecords. push_back ( std::move ( Rec) );
401
+ SymIndex-> importSymbols ( import , Rec);
391
402
break ;
392
403
}
393
404
394
405
case IndexUnitDependency::DependencyKind::Unit: {
395
- IDCode unitDepCode = unitImport.addUnitDependency (Dep. getName () );
396
- if (!Dep. isSystem () )
406
+ IDCode unitDepCode = unitImport.addUnitDependency (dep. Name );
407
+ if (!dep. IsSystem )
397
408
UserUnitDepends.push_back (unitDepCode);
398
409
break ;
399
410
}
400
411
401
412
case IndexUnitDependency::DependencyKind::File: {
402
- CanonicalFilePath CanonPath = CanonPathCache->getCanonicalPath (Dep. getFilePath () , WorkDir);
413
+ CanonicalFilePath CanonPath = CanonPathCache->getCanonicalPath (dep. FilePath , WorkDir);
403
414
if (CanonPath.empty ())
404
415
break ;
405
416
406
- if (!Dep. isSystem () )
417
+ if (!dep. IsSystem )
407
418
UserFileDepends.push_back (CanonPath);
408
419
unitImport.addFileDependency (CanonPath);
409
420
}
410
421
}
411
- return true ;
412
- });
413
-
414
- for (const auto &rec : newStoreRecords) {
415
- SymIndex->importSymbols (import , rec);
416
422
}
417
423
418
424
unitImport.commit ();
0 commit comments