Index: include/llvm/ADT/StringRef.h =================================================================== --- include/llvm/ADT/StringRef.h +++ include/llvm/ADT/StringRef.h @@ -750,9 +750,9 @@ /// string. /// /// If \p Separator is in the string, then the result is a pair (LHS, RHS) - /// such that (*this == LHS + Separator + RHS) is true and RHS is - /// minimal. If \p Separator is not in the string, then the result is a - /// pair (LHS, RHS) where (*this == LHS) and (RHS == ""). + /// such that (*this == LHS + Separator + RHS) is true and RHS is minimal. + /// If \p Separator is not in the string, then the result is a pair (LHS, + /// RHS) where (LHS == "") and (*this == RHS). /// /// \param Separator - The string to split on. /// \return - The split substrings. @@ -760,7 +760,7 @@ std::pair rsplit(StringRef Separator) const { size_t Idx = rfind(Separator); if (Idx == npos) - return std::make_pair(*this, StringRef()); + return std::make_pair(StringRef(), *this); return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos)); } @@ -803,9 +803,9 @@ /// character. /// /// If \p Separator is in the string, then the result is a pair (LHS, RHS) - /// such that (*this == LHS + Separator + RHS) is true and RHS is - /// minimal. If \p Separator is not in the string, then the result is a - /// pair (LHS, RHS) where (*this == LHS) and (RHS == ""). + /// such that (*this == LHS + Separator + RHS) is true and RHS is minimal. + /// If \p Separator is not in the string, then the result is a pair (LHS, + /// RHS) where (LHS == "") and (*this == RHS). /// /// \param Separator - The character to split on. /// \return - The split substrings. Index: unittests/ADT/StringRefTest.cpp =================================================================== --- unittests/ADT/StringRefTest.cpp +++ unittests/ADT/StringRefTest.cpp @@ -171,7 +171,7 @@ EXPECT_EQ(std::make_pair(StringRef("hell"), StringRef("")), Str.split('o')); - EXPECT_EQ(std::make_pair(StringRef("hello"), StringRef("")), + EXPECT_EQ(std::make_pair(StringRef(""), StringRef("hello")), Str.rsplit('X')); EXPECT_EQ(std::make_pair(StringRef("h"), StringRef("llo")), Str.rsplit('e')); @@ -188,7 +188,7 @@ Str.rsplit("h")); EXPECT_EQ(std::make_pair(StringRef("hell"), StringRef("")), Str.rsplit("o")); - EXPECT_EQ(std::make_pair(StringRef("hello"), StringRef("")), + EXPECT_EQ(std::make_pair(StringRef(""), StringRef("hello")), Str.rsplit("::")); EXPECT_EQ(std::make_pair(StringRef("hel"), StringRef("o")), Str.rsplit("l"));