Skip to content

Commit 04d44bf

Browse files
committed
[SourceKit] Sort ReferencedDecls when printing them
This assures stable sort order when comparing solver-based and AST-based results.
1 parent 6d0a092 commit 04d44bf

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tools/SourceKit/include/SourceKit/Core/LangSupport.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,15 @@ struct CursorSymbolInfo {
556556
for (auto ParentContext : ParentContexts) {
557557
ParentContext.print(OS, Indentation + " ");
558558
}
559+
560+
llvm::SmallVector<ReferencedDeclInfo> SortedReferencedSymbols(
561+
ReferencedSymbols.begin(), ReferencedSymbols.end());
562+
std::sort(SortedReferencedSymbols.begin(), SortedReferencedSymbols.end(),
563+
[](const ReferencedDeclInfo &LHS, const ReferencedDeclInfo &RHS) {
564+
return LHS.USR < RHS.USR;
565+
});
559566
OS << Indentation << "ReferencedSymbols:" << '\n';
560-
for (auto ReferencedSymbol : ReferencedSymbols) {
567+
for (auto ReferencedSymbol : SortedReferencedSymbols) {
561568
ReferencedSymbol.print(OS, Indentation + " ");
562569
}
563570
OS << Indentation << "ReceiverUSRs:" << '\n';

0 commit comments

Comments
 (0)