swift-api-digester: sort migration scripts before serializing them.

This commit is contained in:
Xi Ge
2018-05-22 13:39:46 -07:00
parent 3a51bd66d2
commit 5212311cc0
4 changed files with 215 additions and 388 deletions

View File

@@ -2987,8 +2987,8 @@ void TypeMemberDiffFinder::dump(llvm::raw_ostream &os) const {
}
namespace {
template<typename T>
template<typename T>
void removeRedundantAndSort(std::vector<T> &Diffs) {
std::set<T> DiffSet(Diffs.begin(), Diffs.end());
Diffs.assign(DiffSet.begin(), DiffSet.end());
@@ -2997,7 +2997,6 @@ void removeRedundantAndSort(std::vector<T> &Diffs) {
template<typename T>
void serializeDiffs(llvm::raw_ostream &Fs, std::vector<T> &Diffs) {
removeRedundantAndSort(Diffs);
if (Diffs.empty())
return;
Fs << "\n";
@@ -3823,6 +3822,10 @@ static int compareSDKs(StringRef LeftPath, StringRef RightPath,
auto &typeMemberDiffs = Ctx.getTypeMemberDiffs();
std::error_code EC;
llvm::raw_fd_ostream Fs(DiffPath, EC, llvm::sys::fs::F_None);
removeRedundantAndSort(AllItems);
removeRedundantAndSort(typeMemberDiffs);
removeRedundantAndSort(AllNoEscapingFuncs);
removeRedundantAndSort(Overloads);
if (options::OutputInJson) {
std::vector<APIDiffItem*> TotalItems;
std::transform(AllItems.begin(), AllItems.end(),