[llvm] 6b49f30 - [llvm] Deprecate llvm::empty (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 18 22:01:41 PDT 2022
Author: Kazu Hirata
Date: 2022-09-18T22:01:32-07:00
New Revision: 6b49f30fca04ea3e4d57aef40e4bb6716a378870
URL: https://github.com/llvm/llvm-project/commit/6b49f30fca04ea3e4d57aef40e4bb6716a378870
DIFF: https://github.com/llvm/llvm-project/commit/6b49f30fca04ea3e4d57aef40e4bb6716a378870.diff
LOG: [llvm] Deprecate llvm::empty (NFC)
This patch deprecates llvm::empty as I've migrated all known uses of
llvm::empty(x) to x.empty().
Differential Revision: https://reviews.llvm.org/D134141
Added:
Modified:
llvm/include/llvm/ADT/STLExtras.h
llvm/unittests/ADT/STLExtrasTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index d0a8065fa4a88..9809b8bc01f3a 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -252,6 +252,7 @@ void adl_swap(T &&lhs, T &&rhs) noexcept(
/// Test whether \p RangeOrContainer is empty. Similar to C++17 std::empty.
template <typename T>
+LLVM_DEPRECATED("Use x.empty() instead", "empty")
constexpr bool empty(const T &RangeOrContainer) {
return adl_begin(RangeOrContainer) == adl_end(RangeOrContainer);
}
diff --git a/llvm/unittests/ADT/STLExtrasTest.cpp b/llvm/unittests/ADT/STLExtrasTest.cpp
index 0d931152c5db2..4a9c745f5328f 100644
--- a/llvm/unittests/ADT/STLExtrasTest.cpp
+++ b/llvm/unittests/ADT/STLExtrasTest.cpp
@@ -399,23 +399,6 @@ TEST(STLExtrasTest, ADLTest) {
EXPECT_EQ(5, count);
}
-TEST(STLExtrasTest, EmptyTest) {
- std::vector<void*> V;
- EXPECT_TRUE(llvm::empty(V));
- V.push_back(nullptr);
- EXPECT_FALSE(llvm::empty(V));
-
- std::initializer_list<int> E = {};
- std::initializer_list<int> NotE = {7, 13, 42};
- EXPECT_TRUE(llvm::empty(E));
- EXPECT_FALSE(llvm::empty(NotE));
-
- auto R0 = make_range(V.begin(), V.begin());
- EXPECT_TRUE(llvm::empty(R0));
- auto R1 = make_range(V.begin(), V.end());
- EXPECT_FALSE(llvm::empty(R1));
-}
-
TEST(STLExtrasTest, DropBeginTest) {
SmallVector<int, 5> vec{0, 1, 2, 3, 4};
More information about the llvm-commits
mailing list