[clang] [clang] Use llvm::stable_sort (NFC) (PR #140413)
via cfe-commits
cfe-commits at lists.llvm.org
Sat May 17 15:11:11 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/140413.diff
6 Files Affected:
- (modified) clang/lib/AST/VTableBuilder.cpp (+2-2)
- (modified) clang/lib/Lex/ModuleMap.cpp (+1-1)
- (modified) clang/lib/Sema/SemaChecking.cpp (+4-5)
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+4-5)
- (modified) clang/unittests/Support/TimeProfilerTest.cpp (+4-5)
- (modified) clang/utils/TableGen/SveEmitter.cpp (+8-10)
``````````diff
diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index 6c97b8718c65e..0001745a6ff22 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -1595,8 +1595,8 @@ void ItaniumVTableBuilder::AddMethods(
NewVirtualFunctions.push_back(MD);
}
- std::stable_sort(
- NewImplicitVirtualFunctions.begin(), NewImplicitVirtualFunctions.end(),
+ llvm::stable_sort(
+ NewImplicitVirtualFunctions,
[](const CXXMethodDecl *A, const CXXMethodDecl *B) {
if (A == B)
return false;
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index d0732375f814e..4175959d8f55b 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -2021,7 +2021,7 @@ void ModuleMapLoader::handleUmbrellaDirDecl(
}
// Sort header paths so that the pcm doesn't depend on iteration order.
- std::stable_sort(Headers.begin(), Headers.end(), compareModuleHeaders);
+ llvm::stable_sort(Headers, compareModuleHeaders);
for (auto &Header : Headers)
Map.addHeader(ActiveModule, std::move(Header), ModuleMap::TextualHeader);
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 84b84de28c511..df04c37b9df0d 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -7526,11 +7526,10 @@ bool DecomposePrintfHandler::GetSpecifiers(
if (H.HadError)
return false;
- std::stable_sort(
- Args.begin(), Args.end(),
- [](const EquatableFormatArgument &A, const EquatableFormatArgument &B) {
- return A.getPosition() < B.getPosition();
- });
+ llvm::stable_sort(Args, [](const EquatableFormatArgument &A,
+ const EquatableFormatArgument &B) {
+ return A.getPosition() < B.getPosition();
+ });
return true;
}
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index b2a982e953012..b071c98051bbe 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -395,11 +395,10 @@ ParsedType Sema::getDestructorName(const IdentifierInfo &II,
FoundDecls.resize(NumNonExtensionDecls);
// List types before non-types.
- std::stable_sort(FoundDecls.begin(), FoundDecls.end(),
- [](NamedDecl *A, NamedDecl *B) {
- return isa<TypeDecl>(A->getUnderlyingDecl()) >
- isa<TypeDecl>(B->getUnderlyingDecl());
- });
+ llvm::stable_sort(FoundDecls, [](NamedDecl *A, NamedDecl *B) {
+ return isa<TypeDecl>(A->getUnderlyingDecl()) >
+ isa<TypeDecl>(B->getUnderlyingDecl());
+ });
// Suggest a fixit to properly name the destroyed type.
auto MakeFixItHint = [&]{
diff --git a/clang/unittests/Support/TimeProfilerTest.cpp b/clang/unittests/Support/TimeProfilerTest.cpp
index 7698742426dfc..a92b0eb11c423 100644
--- a/clang/unittests/Support/TimeProfilerTest.cpp
+++ b/clang/unittests/Support/TimeProfilerTest.cpp
@@ -137,11 +137,10 @@ std::string buildTraceGraph(StringRef Json) {
// started earlier are first in the list.
// Then do a stable sort, we need it for the trace graph.
std::reverse(Events.begin(), Events.end());
- std::stable_sort(
- Events.begin(), Events.end(), [](const auto &lhs, const auto &rhs) {
- return std::make_pair(lhs.TimestampBegin, -lhs.TimestampEnd) <
- std::make_pair(rhs.TimestampBegin, -rhs.TimestampEnd);
- });
+ llvm::stable_sort(Events, [](const auto &lhs, const auto &rhs) {
+ return std::make_pair(lhs.TimestampBegin, -lhs.TimestampEnd) <
+ std::make_pair(rhs.TimestampBegin, -rhs.TimestampEnd);
+ });
std::stringstream Stream;
// Write a newline for better testing with multiline string literal.
diff --git a/clang/utils/TableGen/SveEmitter.cpp b/clang/utils/TableGen/SveEmitter.cpp
index c48210633516e..1bae1c6a27afd 100644
--- a/clang/utils/TableGen/SveEmitter.cpp
+++ b/clang/utils/TableGen/SveEmitter.cpp
@@ -1275,16 +1275,14 @@ void SVEEmitter::createCoreHeaderIntrinsics(raw_ostream &OS,
// - Architectural guard (i.e. does it require SVE2 or SVE2_AES)
// - Class (is intrinsic overloaded or not)
// - Intrinsic name
- std::stable_sort(Defs.begin(), Defs.end(),
- [](const std::unique_ptr<Intrinsic> &A,
- const std::unique_ptr<Intrinsic> &B) {
- auto ToTuple = [](const std::unique_ptr<Intrinsic> &I) {
- return std::make_tuple(
- I->getSVEGuard().str() + I->getSMEGuard().str(),
- (unsigned)I->getClassKind(), I->getName());
- };
- return ToTuple(A) < ToTuple(B);
- });
+ llvm::stable_sort(Defs, [](const std::unique_ptr<Intrinsic> &A,
+ const std::unique_ptr<Intrinsic> &B) {
+ auto ToTuple = [](const std::unique_ptr<Intrinsic> &I) {
+ return std::make_tuple(I->getSVEGuard().str() + I->getSMEGuard().str(),
+ (unsigned)I->getClassKind(), I->getName());
+ };
+ return ToTuple(A) < ToTuple(B);
+ });
// Actually emit the intrinsic declarations.
for (auto &I : Defs)
``````````
</details>
https://github.com/llvm/llvm-project/pull/140413
More information about the cfe-commits
mailing list