diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h --- a/llvm/include/llvm/ADT/ArrayRef.h +++ b/llvm/include/llvm/ADT/ArrayRef.h @@ -605,49 +605,57 @@ /// @} /// Construct a MutableArrayRef from a single element. - template + template + LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef") MutableArrayRef makeMutableArrayRef(T &OneElt) { return OneElt; } /// Construct a MutableArrayRef from a pointer and length. - template + template + LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef") MutableArrayRef makeMutableArrayRef(T *data, size_t length) { return MutableArrayRef(data, length); } /// Construct a MutableArrayRef from a SmallVector. template + LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef") MutableArrayRef makeMutableArrayRef(SmallVectorImpl &Vec) { return Vec; } /// Construct a MutableArrayRef from a SmallVector. template + LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef") MutableArrayRef makeMutableArrayRef(SmallVector &Vec) { return Vec; } /// Construct a MutableArrayRef from a std::vector. - template + template + LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef") MutableArrayRef makeMutableArrayRef(std::vector &Vec) { return Vec; } /// Construct a MutableArrayRef from a std::array. template + LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef") MutableArrayRef makeMutableArrayRef(std::array &Arr) { return Arr; } /// Construct a MutableArrayRef from a MutableArrayRef (no-op) (const) template + LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef") MutableArrayRef makeMutableArrayRef(const MutableArrayRef &Vec) { return Vec; } /// Construct a MutableArrayRef from a C array. - template + template + LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef") MutableArrayRef makeMutableArrayRef(T (&Arr)[N]) { return MutableArrayRef(Arr); } diff --git a/llvm/unittests/ADT/ArrayRefTest.cpp b/llvm/unittests/ADT/ArrayRefTest.cpp --- a/llvm/unittests/ADT/ArrayRefTest.cpp +++ b/llvm/unittests/ADT/ArrayRefTest.cpp @@ -258,45 +258,6 @@ static_assert(std::is_trivially_copyable_v>, "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 C1; - SmallVectorImpl &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 D; - D.resize(5); - auto DR = makeMutableArrayRef(D); - EXPECT_EQ(DR.data(), D.data()); - EXPECT_EQ(DR.size(), D.size()); - - std::array E; - auto ER = makeMutableArrayRef(E); - EXPECT_EQ(ER.data(), E.data()); - EXPECT_EQ(ER.size(), E.size()); -} - TEST(ArrayRefTest, MutableArrayRefDeductionGuides) { // Single element {