Skip to content

Commit 7c78a7a

Browse files
authored
Merge pull request #26099 from gmittert/ATrueOrdering
Sort `DeclAttributeAndRange`s Deterministically
2 parents ca1e808 + bfae015 commit 7c78a7a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/IDE/SyntaxModel.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,10 +1080,13 @@ bool ModelASTWalker::handleAttrRanges(ArrayRef<DeclAttributeAndRange> DeclRanges
10801080

10811081
SmallVector<DeclAttributeAndRange, 4> SortedRanges(DeclRanges.begin(),
10821082
DeclRanges.end());
1083-
std::sort(SortedRanges.begin(), SortedRanges.end(),
1084-
[&](DeclAttributeAndRange LHS, DeclAttributeAndRange RHS) {
1085-
return SM.isBeforeInBuffer(LHS.second.Start, RHS.second.End);
1086-
});
1083+
std::sort(
1084+
SortedRanges.begin(), SortedRanges.end(),
1085+
[&](DeclAttributeAndRange LHS, DeclAttributeAndRange RHS) {
1086+
// Since attributes don't overlap it's safe to compare just by the
1087+
// range's Start
1088+
return SM.isBeforeInBuffer(LHS.second.Start, RHS.second.Start);
1089+
});
10871090
// Handle duplicate synthesized attributes due to * in @available
10881091
auto NewEnd = std::unique(SortedRanges.begin(), SortedRanges.end(),
10891092
[&](DeclAttributeAndRange LHS, DeclAttributeAndRange RHS) {

0 commit comments

Comments
 (0)