@@ -6907,35 +6907,32 @@ void GenericSignatureBuilder::checkSameTypeConstraints(
6907
6907
// connect all of the components, or else we wouldn't have an equivalence
6908
6908
// class.
6909
6909
if (intercomponentEdges.size () > numComponents - 1 ) {
6910
- auto &sourceMgr = getASTContext ().SourceMgr ;
6911
-
6912
6910
// First let's order all of the intercomponent edges
6913
6911
// as written in source, this helps us to diagnose
6914
6912
// all of the duplicate constraints in correct order.
6915
- std::vector<unsigned > sourceOrderedEdges;
6916
- for (unsigned i : indices ( intercomponentEdges) )
6917
- sourceOrderedEdges.push_back (i );
6913
+ std::vector<IntercomponentEdge * > sourceOrderedEdges;
6914
+ for (auto &edge : intercomponentEdges)
6915
+ sourceOrderedEdges.push_back (&edge );
6918
6916
6919
- std::sort (sourceOrderedEdges.begin (), sourceOrderedEdges.end (),
6920
- [&sourceMgr, &intercomponentEdges](
6921
- const unsigned &indexA, const unsigned &indexB) -> bool {
6922
- auto &a = intercomponentEdges[indexA];
6923
- auto &b = intercomponentEdges[indexB];
6917
+ llvm::array_pod_sort (
6918
+ sourceOrderedEdges.begin (), sourceOrderedEdges.end (),
6919
+ [](IntercomponentEdge *const *a, IntercomponentEdge *const *b) -> int {
6920
+ auto &sourceMgr = (*a)->constraint .value ->getASTContext ().SourceMgr ;
6924
6921
6925
- auto locA = a. constraint .source ->getLoc ();
6926
- auto locB = b. constraint .source ->getLoc ();
6922
+ auto locA = (*a)-> constraint .source ->getLoc ();
6923
+ auto locB = (*b)-> constraint .source ->getLoc ();
6927
6924
6928
- auto bufferA = sourceMgr.findBufferContainingLoc (locA);
6929
- auto bufferB = sourceMgr.findBufferContainingLoc (locB);
6925
+ auto bufferA = sourceMgr.findBufferContainingLoc (locA);
6926
+ auto bufferB = sourceMgr.findBufferContainingLoc (locB);
6930
6927
6931
- if (bufferA != bufferB)
6932
- return bufferA < bufferB;
6928
+ if (bufferA != bufferB)
6929
+ return bufferA < bufferB ? - 1 : 1 ;
6933
6930
6934
- auto offsetA = sourceMgr.getLocOffsetInBuffer (locA, bufferA);
6935
- auto offsetB = sourceMgr.getLocOffsetInBuffer (locB, bufferB);
6931
+ auto offsetA = sourceMgr.getLocOffsetInBuffer (locA, bufferA);
6932
+ auto offsetB = sourceMgr.getLocOffsetInBuffer (locB, bufferB);
6936
6933
6937
- return offsetA < offsetB;
6938
- });
6934
+ return offsetA < offsetB ? - 1 : ( offsetA == offsetB ? 0 : 1 ) ;
6935
+ });
6939
6936
6940
6937
auto isDiagnosable = [](const IntercomponentEdge &edge, bool isPrimary) {
6941
6938
return edge.constraint .source ->shouldDiagnoseRedundancy (isPrimary);
@@ -6949,8 +6946,8 @@ void GenericSignatureBuilder::checkSameTypeConstraints(
6949
6946
// entry is found, that entry is going to point to previous
6950
6947
// declaration and is going to mark current edge as a duplicate of
6951
6948
// such entry.
6952
- for (const unsigned edgeIdx : sourceOrderedEdges) {
6953
- const auto &edge = intercomponentEdges [edgeIdx];
6949
+ for (auto edgeIdx : indices ( sourceOrderedEdges) ) {
6950
+ const auto &edge = *sourceOrderedEdges [edgeIdx];
6954
6951
6955
6952
Type lhs = edge.constraint .getSubjectDependentType (genericParams);
6956
6953
Type rhs = edge.constraint .value ;
@@ -7016,7 +7013,7 @@ void GenericSignatureBuilder::checkSameTypeConstraints(
7016
7013
edge.constraint .value );
7017
7014
7018
7015
if (previousIndex) {
7019
- auto &prevEquiv = intercomponentEdges [*previousIndex]. constraint ;
7016
+ auto &prevEquiv = sourceOrderedEdges [*previousIndex]-> constraint ;
7020
7017
Diags.diagnose (
7021
7018
prevEquiv.source ->getLoc (), diag::previous_same_type_constraint,
7022
7019
prevEquiv.source ->classifyDiagKind (),
0 commit comments