diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h index 4e97e9ca2de0..9cb25b09c6cb 100644 --- a/llvm/include/llvm/ADT/ArrayRef.h +++ b/llvm/include/llvm/ADT/ArrayRef.h @@ -272,16 +272,6 @@ namespace llvm { return std::vector(Data, Data+Length); } - /// @} - /// @name Comparison operators - /// @{ - - friend bool operator==(ArrayRef LHS, ArrayRef RHS) { - return LHS.equals(RHS); - } - - friend bool operator!=(ArrayRef LHS, ArrayRef RHS) { return !(LHS == RHS); } - /// @} }; @@ -520,6 +510,22 @@ namespace llvm { return MutableArrayRef(data, length); } + /// @} + /// @name ArrayRef Comparison Operators + /// @{ + + template + inline bool operator==(ArrayRef LHS, ArrayRef RHS) { + return LHS.equals(RHS); + } + + template + inline bool operator!=(ArrayRef LHS, ArrayRef RHS) { + return !(LHS == RHS); + } + + /// @} + // ArrayRefs can be treated like a POD type. template struct isPodLike; template struct isPodLike> { diff --git a/llvm/unittests/ADT/ArrayRefTest.cpp b/llvm/unittests/ADT/ArrayRefTest.cpp index 7f97c40d41c6..e01d212f218b 100644 --- a/llvm/unittests/ADT/ArrayRefTest.cpp +++ b/llvm/unittests/ADT/ArrayRefTest.cpp @@ -188,10 +188,6 @@ TEST(ArrayRefTest, Equals) { EXPECT_TRUE(AR1b.equals({3, 4, 5, 6})); EXPECT_FALSE(AR1b.equals({2, 3, 4, 5, 6})); EXPECT_FALSE(AR1b.equals({3, 4, 5, 6, 7})); - - SmallVector V1{1, 2, 3, 4, 5, 6, 7, 8}; - EXPECT_EQ(AR1, V1); - EXPECT_EQ(V1, AR1); } TEST(ArrayRefTest, EmptyEquals) {