@@ -1886,12 +1886,7 @@ bool swift::fixDeclarationObjCName(InFlightDiagnostic &diag, const ValueDecl *de
1886
1886
1887
1887
namespace {
1888
1888
// / 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 {
1895
1890
bool operator ()(ValueDecl *lhs, ValueDecl *rhs) const {
1896
1891
// If the declarations come from different modules, order based on the
1897
1892
// module.
@@ -1912,6 +1907,7 @@ namespace {
1912
1907
}
1913
1908
1914
1909
// Prefer the declaration that comes first in the source file.
1910
+ const auto &SrcMgr = lhsSF->getASTContext ().SourceMgr ;
1915
1911
return SrcMgr.isBeforeInBuffer (lhs->getLoc (), rhs->getLoc ());
1916
1912
}
1917
1913
@@ -1948,7 +1944,7 @@ static AbstractFunctionDecl *lookupObjCMethodInClass(
1948
1944
return nullptr ;
1949
1945
}
1950
1946
return *std::min_element (methods.begin (), methods.end (),
1951
- OrderDeclarations (srcMgr ));
1947
+ OrderDeclarations ());
1952
1948
}
1953
1949
1954
1950
// Recurse into the superclass.
@@ -1975,7 +1971,7 @@ bool swift::diagnoseUnintendedObjCMethodOverrides(SourceFile &sf) {
1975
1971
return false ;
1976
1972
1977
1973
// Sort the methods by declaration order.
1978
- std::sort (methods.begin (), methods.end (), OrderDeclarations (Ctx. SourceMgr ));
1974
+ std::sort (methods.begin (), methods.end (), OrderDeclarations ());
1979
1975
1980
1976
// For each Objective-C method declared in this file, check whether
1981
1977
// it overrides something in one of its superclasses. We
@@ -2077,8 +2073,7 @@ bool swift::diagnoseObjCMethodConflicts(SourceFile &sf) {
2077
2073
return false ;
2078
2074
2079
2075
auto &Ctx = sf.getASTContext ();
2080
-
2081
- OrderDeclarations ordering (Ctx.SourceMgr );
2076
+ OrderDeclarations ordering;
2082
2077
2083
2078
// Sort the set of conflicts so we get a deterministic order for
2084
2079
// diagnostics. We use the first conflicting declaration in each set to
0 commit comments