@@ -848,33 +848,54 @@ bool swift::fine_grained_dependencies::emitReferenceDependencies(
848
848
static StringRef stripPrefix (const StringRef name) {
849
849
return name.ltrim (SourceFileDepGraph::noncascadingOrPrivatePrefix);
850
850
}
851
+ static StringRef stripFingerprint (const StringRef nameAndFingerprint) {
852
+ return nameAndFingerprint.split (SourceFileDepGraph::nameFingerprintSeparator)
853
+ .first ;
854
+ }
855
+ static StringRef stripName (const StringRef nameAndFingerprint) {
856
+ return nameAndFingerprint.split (SourceFileDepGraph::nameFingerprintSeparator)
857
+ .second ;
858
+ }
859
+ static std::string extractName (const StringRef prefixNameFingerprint) {
860
+ return stripFingerprint (stripPrefix (prefixNameFingerprint)).str ();
861
+ }
862
+ static Optional<std::string> extractFingerprint (
863
+ const StringRef prefixNameFingerprint) {
864
+ const auto fp = stripName (stripPrefix (prefixNameFingerprint));
865
+ return fp.empty () ? None : Optional<std::string>(fp.str ());
866
+ }
851
867
852
868
static std::vector<ContextNameFingerprint>
853
869
getBaseNameProvides (ArrayRef<std::string> simpleNames) {
854
870
std::vector<ContextNameFingerprint> result;
855
871
for (StringRef n : simpleNames)
856
- result.push_back (ContextNameFingerprint (" " , stripPrefix (n).str (), None));
872
+ result.push_back (ContextNameFingerprint (" " , extractName (n),
873
+ extractFingerprint (n)));
857
874
return result;
858
875
}
859
876
860
877
static std::vector<ContextNameFingerprint>
861
878
getMangledHolderProvides (ArrayRef<std::string> simpleNames) {
862
879
std::vector<ContextNameFingerprint> result;
863
880
for (StringRef n : simpleNames)
864
- result.push_back (ContextNameFingerprint (stripPrefix (n).str (), " " , None));
881
+ result.push_back (ContextNameFingerprint (extractName (n), " " ,
882
+ extractFingerprint (n)));
865
883
return result;
866
884
}
867
885
868
886
static std::vector<ContextNameFingerprint> getCompoundProvides (
869
887
ArrayRef<std::pair<std::string, std::string>> compoundNames) {
870
888
std::vector<ContextNameFingerprint> result;
871
889
for (const auto &p : compoundNames)
872
- result.push_back (ContextNameFingerprint (stripPrefix (p.first ),
873
- stripPrefix (p.second ), None));
890
+ result.push_back (ContextNameFingerprint (extractName (p.first ),
891
+ extractName (p.second ),
892
+ extractFingerprint (p.second )));
874
893
return result;
875
894
}
876
895
877
- static bool cascades (const std::string &s) { return s.empty () || s[0 ] != SourceFileDepGraph::noncascadingOrPrivatePrefix; }
896
+ static bool cascades (const std::string &s) {
897
+ return s.empty () || s[0 ] != SourceFileDepGraph::noncascadingOrPrivatePrefix;
898
+ }
878
899
879
900
// Use '_' as a prefix for a file-private member
880
901
static bool isPrivate (const std::string &s) {
@@ -904,7 +925,8 @@ getCompoundDepends(
904
925
// (On Linux, the compiler needs more verbosity than:
905
926
// result.push_back({{n, "", false}, cascades(n)});
906
927
result.push_back (
907
- std::make_pair (std::make_tuple (stripPrefix (n), std::string (), false ), cascades (n)));
928
+ std::make_pair (std::make_tuple (stripPrefix (n), std::string (), false ),
929
+ cascades (n)));
908
930
}
909
931
for (auto &p : compoundNames) {
910
932
// Likewise, for Linux expand the following out:
@@ -932,7 +954,8 @@ SourceFileDepGraph SourceFileDepGraph::simulateLoad(
932
954
SourceFileDepGraphConstructor c (
933
955
swiftDepsFilename, includePrivateDeps, hadCompilationError, interfaceHash,
934
956
getSimpleDepends (simpleNamesByRDK[dependsTopLevel]),
935
- getCompoundDepends (simpleNamesByRDK[dependsNominal], compoundNamesByRDK[dependsMember]),
957
+ getCompoundDepends (simpleNamesByRDK[dependsNominal],
958
+ compoundNamesByRDK[dependsMember]),
936
959
getSimpleDepends (simpleNamesByRDK[dependsDynamicLookup]),
937
960
getExternalDepends (simpleNamesByRDK[dependsExternal]),
938
961
{}, // precedence groups
0 commit comments