Skip to content

Commit b801331

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

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,13 @@ struct CursorSymbolInfo {
557557
for (auto ParentContext : ParentContexts) {
558558
ParentContext.print(OS, Indentation + " ");
559559
}
560+
561+
llvm::SmallVector<ReferencedDeclInfo> SortedReferencedSymbols(
562+
ReferencedSymbols.begin(), ReferencedSymbols.end());
563+
std::sort(SortedReferencedSymbols.begin(), SortedReferencedSymbols.end(),
564+
[](const ReferencedDeclInfo &LHS, const ReferencedDeclInfo &RHS) {
565+
return LHS.USR < RHS.USR;
566+
});
560567
OS << Indentation << "ReferencedSymbols:" << '\n';
561568
for (auto ReferencedSymbol : ReferencedSymbols) {
562569
ReferencedSymbol.print(OS, Indentation + " ");

0 commit comments

Comments
 (0)