[llvm] c4b39cd - [llvm][ADT] Mark `makeMutableArrayRef` as deprecated
Joe Loser via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 17 12:01:23 PST 2023
Author: Joe Loser
Date: 2023-01-17T13:01:11-07:00
New Revision: c4b39cd09c4eeef2b3e3d32cb674f92c17eeb517
URL: https://github.com/llvm/llvm-project/commit/c4b39cd09c4eeef2b3e3d32cb674f92c17eeb517
DIFF: https://github.com/llvm/llvm-project/commit/c4b39cd09c4eeef2b3e3d32cb674f92c17eeb517.diff
LOG: [llvm][ADT] Mark `makeMutableArrayRef` as deprecated
Now that all of the uses of `makeMutableArrayRef` are replaced in-tree with use
of deduction guides (see
https://github.com/llvm/llvm-project/commit/a288d7f937708cf67d960962bfa22ffae37ddbf4),
mark `makeMutableArrayRef` as deprecated.
Also remove the old tests for `makeMutableArrayRef` in favor of the ones
introduced with the deduction guides in
https://github.com/llvm/llvm-project/commit/38791259c1165cedfa313e06dc20e443f1e20634.
Differential Revision: https://reviews.llvm.org/D141872
Added:
Modified:
llvm/include/llvm/ADT/ArrayRef.h
llvm/unittests/ADT/ArrayRefTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index bad1fb564b621..a25cf1cf817ef 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -605,49 +605,57 @@ namespace llvm {
/// @}
/// Construct a MutableArrayRef from a single element.
- template<typename T>
+ template <typename T>
+ LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
MutableArrayRef<T> makeMutableArrayRef(T &OneElt) {
return OneElt;
}
/// Construct a MutableArrayRef from a pointer and length.
- template<typename T>
+ template <typename T>
+ LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
MutableArrayRef<T> makeMutableArrayRef(T *data, size_t length) {
return MutableArrayRef<T>(data, length);
}
/// Construct a MutableArrayRef from a SmallVector.
template <typename T>
+ LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
MutableArrayRef<T> makeMutableArrayRef(SmallVectorImpl<T> &Vec) {
return Vec;
}
/// Construct a MutableArrayRef from a SmallVector.
template <typename T, unsigned N>
+ LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
MutableArrayRef<T> makeMutableArrayRef(SmallVector<T, N> &Vec) {
return Vec;
}
/// Construct a MutableArrayRef from a std::vector.
- template<typename T>
+ template <typename T>
+ LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
MutableArrayRef<T> makeMutableArrayRef(std::vector<T> &Vec) {
return Vec;
}
/// Construct a MutableArrayRef from a std::array.
template <typename T, std::size_t N>
+ LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
MutableArrayRef<T> makeMutableArrayRef(std::array<T, N> &Arr) {
return Arr;
}
/// Construct a MutableArrayRef from a MutableArrayRef (no-op) (const)
template <typename T>
+ LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
MutableArrayRef<T> makeMutableArrayRef(const MutableArrayRef<T> &Vec) {
return Vec;
}
/// Construct a MutableArrayRef from a C array.
- template<typename T, size_t N>
+ template <typename T, size_t N>
+ LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
MutableArrayRef<T> makeMutableArrayRef(T (&Arr)[N]) {
return MutableArrayRef<T>(Arr);
}
diff --git a/llvm/unittests/ADT/ArrayRefTest.cpp b/llvm/unittests/ADT/ArrayRefTest.cpp
index 13a9d569c2ed2..fb25ee19c0b20 100644
--- a/llvm/unittests/ADT/ArrayRefTest.cpp
+++ b/llvm/unittests/ADT/ArrayRefTest.cpp
@@ -258,45 +258,6 @@ TEST(ArrayRefTest, ArrayRefFromStdArray) {
static_assert(std::is_trivially_copyable_v<ArrayRef<int>>,
"trivially copyable");
-TEST(ArrayRefTest, makeMutableArrayRef) {
- int A = 0;
- auto AR = makeMutableArrayRef(A);
- EXPECT_EQ(AR.data(), &A);
- EXPECT_EQ(AR.size(), (size_t)1);
-
- AR[0] = 1;
- EXPECT_EQ(A, 1);
-
- int B[] = {0, 1, 2, 3};
- auto BR1 = makeMutableArrayRef(&B[0], 4);
- auto BR2 = makeMutableArrayRef(B);
- EXPECT_EQ(BR1.data(), &B[0]);
- EXPECT_EQ(BR1.size(), (size_t)4);
- EXPECT_EQ(BR2.data(), &B[0]);
- EXPECT_EQ(BR2.size(), (size_t)4);
-
- SmallVector<int> C1;
- SmallVectorImpl<int> &C2 = C1;
- C1.resize(5);
- auto CR1 = makeMutableArrayRef(C1);
- auto CR2 = makeMutableArrayRef(C2);
- EXPECT_EQ(CR1.data(), C1.data());
- EXPECT_EQ(CR1.size(), C1.size());
- EXPECT_EQ(CR2.data(), C2.data());
- EXPECT_EQ(CR2.size(), C2.size());
-
- std::vector<int> D;
- D.resize(5);
- auto DR = makeMutableArrayRef(D);
- EXPECT_EQ(DR.data(), D.data());
- EXPECT_EQ(DR.size(), D.size());
-
- std::array<int, 5> E;
- auto ER = makeMutableArrayRef(E);
- EXPECT_EQ(ER.data(), E.data());
- EXPECT_EQ(ER.size(), E.size());
-}
-
TEST(ArrayRefTest, MutableArrayRefDeductionGuides) {
// Single element
{
More information about the llvm-commits
mailing list