Skip to content

Commit 4674ad5

Browse files
authored
[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.
1 parent c256965 commit 4674ad5

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/IDE/ModuleInterfacePrinting.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,12 @@ void swift::ide::printSubmoduleInterface(
450450

451451
// Sort imported declarations in source order *within a submodule*.
452452
for (auto &P : ClangDecls) {
453-
std::sort(P.second.begin(), P.second.end(),
454-
[&](std::pair<Decl *, clang::SourceLocation> LHS,
455-
std::pair<Decl *, clang::SourceLocation> RHS) -> bool {
456-
return ClangSourceManager.isBeforeInTranslationUnit(LHS.second,
457-
RHS.second);
458-
});
453+
std::stable_sort(P.second.begin(), P.second.end(),
454+
[&](std::pair<Decl *, clang::SourceLocation> LHS,
455+
std::pair<Decl *, clang::SourceLocation> RHS) -> bool {
456+
return ClangSourceManager.isBeforeInTranslationUnit(LHS.second,
457+
RHS.second);
458+
});
459459
}
460460

461461
// Sort Swift declarations so that we print them in a consistent order.

test/ClangImporter/Inputs/SwiftPrivateAttr.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ struct NSOptions : OptionSet {
107107
static var __PrivA: NSOptions { get }
108108
static var B: NSOptions { get }
109109
}
110-
@available(swift, obsoleted: 3, renamed: "__PrivCFType")
111-
typealias __PrivCFTypeRef = __PrivCFType
112110
class __PrivCFType : _CFObject {
113111
}
112+
@available(swift, obsoleted: 3, renamed: "__PrivCFType")
113+
typealias __PrivCFTypeRef = __PrivCFType
114+
typealias __PrivCFSub = __PrivCFType
114115
@available(swift, obsoleted: 3, renamed: "__PrivCFSub")
115116
typealias __PrivCFSubRef = __PrivCFSub
116-
typealias __PrivCFSub = __PrivCFType
117117
typealias __PrivInt = Int32

0 commit comments

Comments
 (0)