[Serialization] Preserve source order in serialization (#18361)

We previously shied away from this in order to not /accidentally/
depend on it, but it becomes interesting again with textual
interfaces, which can certainly be read by humans. The cross-file
order is the order of input files, which is at least controllable by
users.
This commit is contained in:
Jordan Rose
2018-07-31 13:15:07 -07:00
committed by GitHub
parent 3439333f79
commit 2dfa303975
12 changed files with 229 additions and 238 deletions

View File

@@ -497,7 +497,7 @@ void swift::ide::printSubmoduleInterface(
// If the group name is specified, we sort them according to their source order,
// which is the order preserved by getTopLevelDecls.
if (GroupNames.empty()) {
std::sort(SwiftDecls.begin(), SwiftDecls.end(),
std::stable_sort(SwiftDecls.begin(), SwiftDecls.end(),
[&](Decl *LHS, Decl *RHS) -> bool {
auto *LHSValue = dyn_cast<ValueDecl>(LHS);
auto *RHSValue = dyn_cast<ValueDecl>(RHS);