Skip to content

Commit c4b39cd

Browse files
committed
[llvm][ADT] Mark makeMutableArrayRef as deprecated
Now that all of the uses of `makeMutableArrayRef` are replaced in-tree with use of deduction guides (see a288d7f), mark `makeMutableArrayRef` as deprecated. Also remove the old tests for `makeMutableArrayRef` in favor of the ones introduced with the deduction guides in 3879125. Differential Revision: https://reviews.llvm.org/D141872
1 parent 68c197f commit c4b39cd

File tree

2 files changed

+12
-43
lines changed

2 files changed

+12
-43
lines changed

llvm/include/llvm/ADT/ArrayRef.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,49 +605,57 @@ namespace llvm {
605605
/// @}
606606

607607
/// Construct a MutableArrayRef from a single element.
608-
template<typename T>
608+
template <typename T>
609+
LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
609610
MutableArrayRef<T> makeMutableArrayRef(T &OneElt) {
610611
return OneElt;
611612
}
612613

613614
/// Construct a MutableArrayRef from a pointer and length.
614-
template<typename T>
615+
template <typename T>
616+
LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
615617
MutableArrayRef<T> makeMutableArrayRef(T *data, size_t length) {
616618
return MutableArrayRef<T>(data, length);
617619
}
618620

619621
/// Construct a MutableArrayRef from a SmallVector.
620622
template <typename T>
623+
LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
621624
MutableArrayRef<T> makeMutableArrayRef(SmallVectorImpl<T> &Vec) {
622625
return Vec;
623626
}
624627

625628
/// Construct a MutableArrayRef from a SmallVector.
626629
template <typename T, unsigned N>
630+
LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
627631
MutableArrayRef<T> makeMutableArrayRef(SmallVector<T, N> &Vec) {
628632
return Vec;
629633
}
630634

631635
/// Construct a MutableArrayRef from a std::vector.
632-
template<typename T>
636+
template <typename T>
637+
LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
633638
MutableArrayRef<T> makeMutableArrayRef(std::vector<T> &Vec) {
634639
return Vec;
635640
}
636641

637642
/// Construct a MutableArrayRef from a std::array.
638643
template <typename T, std::size_t N>
644+
LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
639645
MutableArrayRef<T> makeMutableArrayRef(std::array<T, N> &Arr) {
640646
return Arr;
641647
}
642648

643649
/// Construct a MutableArrayRef from a MutableArrayRef (no-op) (const)
644650
template <typename T>
651+
LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
645652
MutableArrayRef<T> makeMutableArrayRef(const MutableArrayRef<T> &Vec) {
646653
return Vec;
647654
}
648655

649656
/// Construct a MutableArrayRef from a C array.
650-
template<typename T, size_t N>
657+
template <typename T, size_t N>
658+
LLVM_DEPRECATED("Use deduction guide instead", "MutableArrayRef")
651659
MutableArrayRef<T> makeMutableArrayRef(T (&Arr)[N]) {
652660
return MutableArrayRef<T>(Arr);
653661
}

llvm/unittests/ADT/ArrayRefTest.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -258,45 +258,6 @@ TEST(ArrayRefTest, ArrayRefFromStdArray) {
258258
static_assert(std::is_trivially_copyable_v<ArrayRef<int>>,
259259
"trivially copyable");
260260

261-
TEST(ArrayRefTest, makeMutableArrayRef) {
262-
int A = 0;
263-
auto AR = makeMutableArrayRef(A);
264-
EXPECT_EQ(AR.data(), &A);
265-
EXPECT_EQ(AR.size(), (size_t)1);
266-
267-
AR[0] = 1;
268-
EXPECT_EQ(A, 1);
269-
270-
int B[] = {0, 1, 2, 3};
271-
auto BR1 = makeMutableArrayRef(&B[0], 4);
272-
auto BR2 = makeMutableArrayRef(B);
273-
EXPECT_EQ(BR1.data(), &B[0]);
274-
EXPECT_EQ(BR1.size(), (size_t)4);
275-
EXPECT_EQ(BR2.data(), &B[0]);
276-
EXPECT_EQ(BR2.size(), (size_t)4);
277-
278-
SmallVector<int> C1;
279-
SmallVectorImpl<int> &C2 = C1;
280-
C1.resize(5);
281-
auto CR1 = makeMutableArrayRef(C1);
282-
auto CR2 = makeMutableArrayRef(C2);
283-
EXPECT_EQ(CR1.data(), C1.data());
284-
EXPECT_EQ(CR1.size(), C1.size());
285-
EXPECT_EQ(CR2.data(), C2.data());
286-
EXPECT_EQ(CR2.size(), C2.size());
287-
288-
std::vector<int> D;
289-
D.resize(5);
290-
auto DR = makeMutableArrayRef(D);
291-
EXPECT_EQ(DR.data(), D.data());
292-
EXPECT_EQ(DR.size(), D.size());
293-
294-
std::array<int, 5> E;
295-
auto ER = makeMutableArrayRef(E);
296-
EXPECT_EQ(ER.data(), E.data());
297-
EXPECT_EQ(ER.size(), E.size());
298-
}
299-
300261
TEST(ArrayRefTest, MutableArrayRefDeductionGuides) {
301262
// Single element
302263
{

0 commit comments

Comments
 (0)