[IDE] Preserve order for Clang declarations with the same source loc. (#9581)

This usually indicates the same declaration being imported multiple
ways; trust the ClangImporter to provide a reasonable order for these.
This commit is contained in:
Jordan Rose
2017-05-14 12:36:48 -07:00
committed by GitHub
parent c256965212
commit 4674ad59ef
2 changed files with 9 additions and 9 deletions

View File

@@ -450,12 +450,12 @@ void swift::ide::printSubmoduleInterface(
// Sort imported declarations in source order *within a submodule*.
for (auto &P : ClangDecls) {
std::sort(P.second.begin(), P.second.end(),
[&](std::pair<Decl *, clang::SourceLocation> LHS,
std::pair<Decl *, clang::SourceLocation> RHS) -> bool {
return ClangSourceManager.isBeforeInTranslationUnit(LHS.second,
RHS.second);
});
std::stable_sort(P.second.begin(), P.second.end(),
[&](std::pair<Decl *, clang::SourceLocation> LHS,
std::pair<Decl *, clang::SourceLocation> RHS) -> bool {
return ClangSourceManager.isBeforeInTranslationUnit(LHS.second,
RHS.second);
});
}
// Sort Swift declarations so that we print them in a consistent order.