[llvm] [llvm] Use llvm::equal (NFC) (PR #169173)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 22 09:32:41 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/169173
While I am at it, this patch uses const l-value references for
std::shared_ptr. We don't need to increment the reference count by
passing std::shared_ptr by value.
Identified with llvm-use-ranges.
>From b4fdc98dca3e0263a376b1365a08db0080cf8de0 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 22 Nov 2025 09:07:31 -0800
Subject: [PATCH] [llvm] Use llvm::equal (NFC)
While I am at it, this patch uses const l-value references for
std::shared_ptr. We don't need to increment the reference count by
passing std::shared_ptr by value.
Identified with llvm-use-ranges.
---
llvm/lib/CodeGen/CallingConvLower.cpp | 3 +--
llvm/lib/TextAPI/InterfaceFile.cpp | 11 +++++------
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/llvm/lib/CodeGen/CallingConvLower.cpp b/llvm/lib/CodeGen/CallingConvLower.cpp
index df3433199681b..644e9bff8929a 100644
--- a/llvm/lib/CodeGen/CallingConvLower.cpp
+++ b/llvm/lib/CodeGen/CallingConvLower.cpp
@@ -290,6 +290,5 @@ bool CCState::resultsCompatible(CallingConv::ID CalleeCC,
llvm_unreachable("Unknown location kind");
};
- return std::equal(RVLocs1.begin(), RVLocs1.end(), RVLocs2.begin(),
- RVLocs2.end(), AreCompatible);
+ return llvm::equal(RVLocs1, RVLocs2, AreCompatible);
}
diff --git a/llvm/lib/TextAPI/InterfaceFile.cpp b/llvm/lib/TextAPI/InterfaceFile.cpp
index a201554de9e64..b35f7fdd3a207 100644
--- a/llvm/lib/TextAPI/InterfaceFile.cpp
+++ b/llvm/lib/TextAPI/InterfaceFile.cpp
@@ -421,12 +421,11 @@ bool InterfaceFile::operator==(const InterfaceFile &O) const {
return false;
}
- if (!std::equal(Documents.begin(), Documents.end(), O.Documents.begin(),
- O.Documents.end(),
- [](const std::shared_ptr<InterfaceFile> LHS,
- const std::shared_ptr<InterfaceFile> RHS) {
- return *LHS == *RHS;
- }))
+ if (!llvm::equal(Documents, O.Documents,
+ [](const std::shared_ptr<InterfaceFile> &LHS,
+ const std::shared_ptr<InterfaceFile> &RHS) {
+ return *LHS == *RHS;
+ }))
return false;
return true;
}
More information about the llvm-commits
mailing list