Skip to content

Commit da78d93

Browse files
committed
Remove OrderDeclaration's SourceManager parameter
We can get it from the SourceFile.
1 parent b982693 commit da78d93

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

lib/Sema/TypeCheckDeclObjC.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,12 +1886,7 @@ bool swift::fixDeclarationObjCName(InFlightDiagnostic &diag, const ValueDecl *de
18861886

18871887
namespace {
18881888
/// Produce a deterministic ordering of the given declarations.
1889-
class OrderDeclarations {
1890-
SourceManager &SrcMgr;
1891-
1892-
public:
1893-
OrderDeclarations(SourceManager &srcMgr) : SrcMgr(srcMgr) { }
1894-
1889+
struct OrderDeclarations {
18951890
bool operator()(ValueDecl *lhs, ValueDecl *rhs) const {
18961891
// If the declarations come from different modules, order based on the
18971892
// module.
@@ -1912,6 +1907,7 @@ namespace {
19121907
}
19131908

19141909
// Prefer the declaration that comes first in the source file.
1910+
const auto &SrcMgr = lhsSF->getASTContext().SourceMgr;
19151911
return SrcMgr.isBeforeInBuffer(lhs->getLoc(), rhs->getLoc());
19161912
}
19171913

@@ -1948,7 +1944,7 @@ static AbstractFunctionDecl *lookupObjCMethodInClass(
19481944
return nullptr;
19491945
}
19501946
return *std::min_element(methods.begin(), methods.end(),
1951-
OrderDeclarations(srcMgr));
1947+
OrderDeclarations());
19521948
}
19531949

19541950
// Recurse into the superclass.
@@ -1975,7 +1971,7 @@ bool swift::diagnoseUnintendedObjCMethodOverrides(SourceFile &sf) {
19751971
return false;
19761972

19771973
// Sort the methods by declaration order.
1978-
std::sort(methods.begin(), methods.end(), OrderDeclarations(Ctx.SourceMgr));
1974+
std::sort(methods.begin(), methods.end(), OrderDeclarations());
19791975

19801976
// For each Objective-C method declared in this file, check whether
19811977
// it overrides something in one of its superclasses. We
@@ -2077,8 +2073,7 @@ bool swift::diagnoseObjCMethodConflicts(SourceFile &sf) {
20772073
return false;
20782074

20792075
auto &Ctx = sf.getASTContext();
2080-
2081-
OrderDeclarations ordering(Ctx.SourceMgr);
2076+
OrderDeclarations ordering;
20822077

20832078
// Sort the set of conflicts so we get a deterministic order for
20842079
// diagnostics. We use the first conflicting declaration in each set to

0 commit comments

Comments
 (0)