@@ -279,11 +279,9 @@ struct Obligation {
279
279
// / in the referenced name trackers associated with that file.
280
280
class DependencyVerifier {
281
281
SourceManager &SM;
282
- const DependencyTracker &DT;
283
282
284
283
public:
285
- explicit DependencyVerifier (SourceManager &SM, const DependencyTracker &DT)
286
- : SM(SM), DT(DT) {}
284
+ explicit DependencyVerifier (SourceManager &SM) : SM(SM) {}
287
285
288
286
bool verifyFile (const SourceFile *SF);
289
287
@@ -338,11 +336,11 @@ class DependencyVerifier {
338
336
}
339
337
340
338
private:
341
- StringRef copyDemangledTypeName (ASTContext &Ctx, StringRef str ) {
342
- Demangle::DemangleOptions Opts ;
343
- Opts. ShowPrivateDiscriminators = false ;
344
- Opts. DisplayModuleNames = true ;
345
- return Ctx.AllocateCopy (Demangle::demangleTypeAsString (str, Opts) );
339
+ StringRef copyQualifiedTypeName (ASTContext &Ctx, NominalTypeDecl *subject ) {
340
+ auto printOptions = PrintOptions () ;
341
+ printOptions. FullyQualifiedTypes = true ;
342
+ auto key = subject-> getDeclaredInterfaceType ()-> getString (printOptions) ;
343
+ return Ctx.AllocateCopy (key );
346
344
}
347
345
348
346
private:
@@ -428,60 +426,49 @@ bool DependencyVerifier::parseExpectations(
428
426
429
427
bool DependencyVerifier::constructObligations (const SourceFile *SF,
430
428
ObligationMap &Obligations) {
431
- auto *tracker = SF->getConfiguredReferencedNameTracker ();
432
- assert (tracker && " Constructed source file without referenced name tracker!" );
433
-
434
429
auto &Ctx = SF->getASTContext ();
435
- tracker->enumerateAllUses (
436
- /* includeIntrafileDeps*/ true , DT,
437
- [&](const fine_grained_dependencies::NodeKind kind, StringRef context,
438
- StringRef name, const bool isCascadingUse) {
439
- using NodeKind = fine_grained_dependencies::NodeKind;
440
- switch (kind) {
441
- case NodeKind::externalDepend:
442
- // We only care about the referenced name trackers for now. The set of
443
- // external dependencies is often quite a large subset of the SDK.
444
- return ;
445
- case NodeKind::nominal:
446
- // Nominals duplicate member entries. We care about the member itself.
447
- return ;
448
- case NodeKind::potentialMember: {
449
- auto key = copyDemangledTypeName (Ctx, context);
450
- auto nameCpy = Ctx.AllocateCopy (name);
430
+ Ctx.evaluator .enumerateReferencesInFile (
431
+ SF, [&](const auto &reference) {
432
+ const auto isCascadingUse = reference.cascades ;
433
+ using NodeKind = evaluator::DependencyCollector::Reference::Kind;
434
+ switch (reference.kind ) {
435
+ case NodeKind::Empty:
436
+ case NodeKind::Tombstone:
437
+ llvm_unreachable (" Cannot enumerate dead dependency!" );
438
+
439
+ case NodeKind::PotentialMember: {
440
+ auto key = copyQualifiedTypeName (Ctx, reference.subject );
451
441
Obligations.insert ({Obligation::Key::forPotentialMember (key),
452
- {nameCpy , Expectation::Kind::PotentialMember,
442
+ {" " , Expectation::Kind::PotentialMember,
453
443
isCascadingUse ? Expectation::Scope::Cascading
454
444
: Expectation::Scope::Private}});
455
445
}
456
446
break ;
457
- case NodeKind::member: {
458
- auto demContext = copyDemangledTypeName (Ctx, context);
447
+ case NodeKind::UsedMember: {
448
+ auto demContext = copyQualifiedTypeName (Ctx, reference.subject );
449
+ auto name = reference.name .userFacingName ();
459
450
auto key = Ctx.AllocateCopy ((demContext + " ." + name).str ());
460
451
Obligations.insert ({Obligation::Key::forMember (key),
461
452
{key, Expectation::Kind::Member,
462
453
isCascadingUse ? Expectation::Scope::Cascading
463
454
: Expectation::Scope::Private}});
464
455
}
465
456
break ;
466
- case NodeKind::dynamicLookup: {
467
- auto contextCpy = Ctx.AllocateCopy (context);
468
- auto key = Ctx.AllocateCopy (name);
457
+ case NodeKind::Dynamic: {
458
+ auto key = Ctx.AllocateCopy (reference.name .userFacingName ());
469
459
Obligations.insert ({Obligation::Key::forDynamicMember (key),
470
- {contextCpy , Expectation::Kind::DynamicMember,
460
+ {" " , Expectation::Kind::DynamicMember,
471
461
isCascadingUse ? Expectation::Scope::Cascading
472
462
: Expectation::Scope::Private}});
473
- break ;
474
463
}
475
- case NodeKind::topLevel:
476
- case NodeKind::sourceFileProvide : {
477
- auto key = Ctx.AllocateCopy (name);
464
+ break ;
465
+ case NodeKind::TopLevel : {
466
+ auto key = Ctx.AllocateCopy (reference. name . userFacingName () );
478
467
Obligations.insert ({Obligation::Key::forProvides (key),
479
468
{key, Expectation::Kind::Provides,
480
469
Expectation::Scope::None}});
481
- break ;
482
470
}
483
- case NodeKind::kindCount:
484
- llvm_unreachable (" Given count node?" );
471
+ break ;
485
472
}
486
473
});
487
474
@@ -491,8 +478,6 @@ bool DependencyVerifier::constructObligations(const SourceFile *SF,
491
478
bool DependencyVerifier::verifyObligations (
492
479
const SourceFile *SF, const std::vector<Expectation> &ExpectedDependencies,
493
480
ObligationMap &OM, llvm::StringMap<Expectation> &NegativeExpectations) {
494
- auto *tracker = SF->getConfiguredReferencedNameTracker ();
495
- assert (tracker && " Constructed source file without referenced name tracker!" );
496
481
auto &diags = SF->getASTContext ().Diags ;
497
482
for (auto &expectation : ExpectedDependencies) {
498
483
const bool wantsCascade = expectation.isCascading ();
@@ -645,21 +630,19 @@ bool DependencyVerifier::verifyFile(const SourceFile *SF) {
645
630
// MARK: Main entrypoints
646
631
// ===----------------------------------------------------------------------===//
647
632
648
- bool swift::verifyDependencies (SourceManager &SM, const DependencyTracker &DT,
649
- ArrayRef<FileUnit *> SFs) {
633
+ bool swift::verifyDependencies (SourceManager &SM, ArrayRef<FileUnit *> SFs) {
650
634
bool HadError = false ;
651
- DependencyVerifier Verifier{SM, DT };
635
+ DependencyVerifier Verifier{SM};
652
636
for (const auto *FU : SFs) {
653
637
if (const auto *SF = dyn_cast<SourceFile>(FU))
654
638
HadError |= Verifier.verifyFile (SF);
655
639
}
656
640
return HadError;
657
641
}
658
642
659
- bool swift::verifyDependencies (SourceManager &SM, const DependencyTracker &DT,
660
- ArrayRef<SourceFile *> SFs) {
643
+ bool swift::verifyDependencies (SourceManager &SM, ArrayRef<SourceFile *> SFs) {
661
644
bool HadError = false ;
662
- DependencyVerifier Verifier{SM, DT };
645
+ DependencyVerifier Verifier{SM};
663
646
for (const auto *SF : SFs) {
664
647
HadError |= Verifier.verifyFile (SF);
665
648
}
0 commit comments