Skip to content

Commit 6290cc3

Browse files
[clang] Use llvm::stable_sort (NFC) (#140413)
1 parent ff78648 commit 6290cc3

File tree

6 files changed

+23
-28
lines changed

6 files changed

+23
-28
lines changed

clang/lib/AST/VTableBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,8 +1595,8 @@ void ItaniumVTableBuilder::AddMethods(
15951595
NewVirtualFunctions.push_back(MD);
15961596
}
15971597

1598-
std::stable_sort(
1599-
NewImplicitVirtualFunctions.begin(), NewImplicitVirtualFunctions.end(),
1598+
llvm::stable_sort(
1599+
NewImplicitVirtualFunctions,
16001600
[](const CXXMethodDecl *A, const CXXMethodDecl *B) {
16011601
if (A == B)
16021602
return false;

clang/lib/Lex/ModuleMap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,7 @@ void ModuleMapLoader::handleUmbrellaDirDecl(
20212021
}
20222022

20232023
// Sort header paths so that the pcm doesn't depend on iteration order.
2024-
std::stable_sort(Headers.begin(), Headers.end(), compareModuleHeaders);
2024+
llvm::stable_sort(Headers, compareModuleHeaders);
20252025

20262026
for (auto &Header : Headers)
20272027
Map.addHeader(ActiveModule, std::move(Header), ModuleMap::TextualHeader);

clang/lib/Sema/SemaChecking.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7526,11 +7526,10 @@ bool DecomposePrintfHandler::GetSpecifiers(
75267526
if (H.HadError)
75277527
return false;
75287528

7529-
std::stable_sort(
7530-
Args.begin(), Args.end(),
7531-
[](const EquatableFormatArgument &A, const EquatableFormatArgument &B) {
7532-
return A.getPosition() < B.getPosition();
7533-
});
7529+
llvm::stable_sort(Args, [](const EquatableFormatArgument &A,
7530+
const EquatableFormatArgument &B) {
7531+
return A.getPosition() < B.getPosition();
7532+
});
75347533
return true;
75357534
}
75367535

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,10 @@ ParsedType Sema::getDestructorName(const IdentifierInfo &II,
395395
FoundDecls.resize(NumNonExtensionDecls);
396396

397397
// List types before non-types.
398-
std::stable_sort(FoundDecls.begin(), FoundDecls.end(),
399-
[](NamedDecl *A, NamedDecl *B) {
400-
return isa<TypeDecl>(A->getUnderlyingDecl()) >
401-
isa<TypeDecl>(B->getUnderlyingDecl());
402-
});
398+
llvm::stable_sort(FoundDecls, [](NamedDecl *A, NamedDecl *B) {
399+
return isa<TypeDecl>(A->getUnderlyingDecl()) >
400+
isa<TypeDecl>(B->getUnderlyingDecl());
401+
});
403402

404403
// Suggest a fixit to properly name the destroyed type.
405404
auto MakeFixItHint = [&]{

clang/unittests/Support/TimeProfilerTest.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,10 @@ std::string buildTraceGraph(StringRef Json) {
137137
// started earlier are first in the list.
138138
// Then do a stable sort, we need it for the trace graph.
139139
std::reverse(Events.begin(), Events.end());
140-
std::stable_sort(
141-
Events.begin(), Events.end(), [](const auto &lhs, const auto &rhs) {
142-
return std::make_pair(lhs.TimestampBegin, -lhs.TimestampEnd) <
143-
std::make_pair(rhs.TimestampBegin, -rhs.TimestampEnd);
144-
});
140+
llvm::stable_sort(Events, [](const auto &lhs, const auto &rhs) {
141+
return std::make_pair(lhs.TimestampBegin, -lhs.TimestampEnd) <
142+
std::make_pair(rhs.TimestampBegin, -rhs.TimestampEnd);
143+
});
145144

146145
std::stringstream Stream;
147146
// Write a newline for better testing with multiline string literal.

clang/utils/TableGen/SveEmitter.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,16 +1275,14 @@ void SVEEmitter::createCoreHeaderIntrinsics(raw_ostream &OS,
12751275
// - Architectural guard (i.e. does it require SVE2 or SVE2_AES)
12761276
// - Class (is intrinsic overloaded or not)
12771277
// - Intrinsic name
1278-
std::stable_sort(Defs.begin(), Defs.end(),
1279-
[](const std::unique_ptr<Intrinsic> &A,
1280-
const std::unique_ptr<Intrinsic> &B) {
1281-
auto ToTuple = [](const std::unique_ptr<Intrinsic> &I) {
1282-
return std::make_tuple(
1283-
I->getSVEGuard().str() + I->getSMEGuard().str(),
1284-
(unsigned)I->getClassKind(), I->getName());
1285-
};
1286-
return ToTuple(A) < ToTuple(B);
1287-
});
1278+
llvm::stable_sort(Defs, [](const std::unique_ptr<Intrinsic> &A,
1279+
const std::unique_ptr<Intrinsic> &B) {
1280+
auto ToTuple = [](const std::unique_ptr<Intrinsic> &I) {
1281+
return std::make_tuple(I->getSVEGuard().str() + I->getSMEGuard().str(),
1282+
(unsigned)I->getClassKind(), I->getName());
1283+
};
1284+
return ToTuple(A) < ToTuple(B);
1285+
});
12881286

12891287
// Actually emit the intrinsic declarations.
12901288
for (auto &I : Defs)

0 commit comments

Comments
 (0)