Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/IDE/ModuleInterfacePrinting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions test/ClangImporter/Inputs/SwiftPrivateAttr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ struct NSOptions : OptionSet {
static var __PrivA: NSOptions { get }
static var B: NSOptions { get }
}
@available(swift, obsoleted: 3, renamed: "__PrivCFType")
typealias __PrivCFTypeRef = __PrivCFType
class __PrivCFType : _CFObject {
}
@available(swift, obsoleted: 3, renamed: "__PrivCFType")
typealias __PrivCFTypeRef = __PrivCFType
typealias __PrivCFSub = __PrivCFType
@available(swift, obsoleted: 3, renamed: "__PrivCFSub")
typealias __PrivCFSubRef = __PrivCFSub
typealias __PrivCFSub = __PrivCFType
typealias __PrivInt = Int32