mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SymbolGraph] Make symbol-graph output deterministic
SymbolGraph generation iterating over llvm::DenseSet, which makes the
symbols and relationship fields appear in non-deterministic ordering.
Switch to use llvm::SetVector to preserve the insertion order from
SourceEntityWalker to make order deterministic.
Resolves: https://github.com/swiftlang/swift/issues/59602
(cherry picked from commit dfa4a27ec8)
This commit is contained in:
@@ -650,21 +650,6 @@ void SymbolGraph::serialize(llvm::json::OStream &OS) {
|
||||
}
|
||||
});
|
||||
|
||||
#ifndef NDEBUG
|
||||
// FIXME (solver-based-verification-sorting): In assert builds sort the
|
||||
// edges so we get consistent symbol graph output. This allows us to compare
|
||||
// the string representation of the symbolgraph between the solver-based
|
||||
// and AST-based result.
|
||||
// This can be removed once the AST-based cursor info has been removed.
|
||||
SmallVector<Edge> Edges(this->Edges.begin(), this->Edges.end());
|
||||
std::sort(Edges.begin(), Edges.end(), [](const Edge &LHS, const Edge &RHS) {
|
||||
SmallString<256> LHSTargetUSR, RHSTargetUSR;
|
||||
LHS.Target.getUSR(LHSTargetUSR);
|
||||
RHS.Target.getUSR(RHSTargetUSR);
|
||||
return LHSTargetUSR < RHSTargetUSR;
|
||||
});
|
||||
#endif
|
||||
|
||||
OS.attributeArray("relationships", [&](){
|
||||
for (const auto &Relationship : Edges) {
|
||||
Relationship.serialize(OS);
|
||||
|
||||
Reference in New Issue
Block a user