mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-08 05:26:50 +00:00
Revert "Clean up SmallString a bit"
This reverts commit r203374. Ambiguities in assign... oh well. I'm just going to revert this and probably not try to recommit it as it's not terribly important. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203375 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ed8ba2e58e
commit
3e07f8a03d
@ -28,18 +28,30 @@ public:
|
|||||||
SmallString() {}
|
SmallString() {}
|
||||||
|
|
||||||
/// Initialize from a StringRef.
|
/// Initialize from a StringRef.
|
||||||
/*implicit*/ SmallString(StringRef S) : SmallVector<char, InternalLen>(S.begin(), S.end()) {}
|
SmallString(StringRef S) : SmallVector<char, InternalLen>(S.begin(), S.end()) {}
|
||||||
|
|
||||||
/// Initialize with a range.
|
/// Initialize with a range.
|
||||||
template<typename ItTy>
|
template<typename ItTy>
|
||||||
SmallString(ItTy S, ItTy E) : SmallVector<char, InternalLen>(S, E) {}
|
SmallString(ItTy S, ItTy E) : SmallVector<char, InternalLen>(S, E) {}
|
||||||
|
|
||||||
|
// Note that in order to add new overloads for append & assign, we have to
|
||||||
|
// duplicate the inherited versions so as not to inadvertently hide them.
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name String Assignment
|
/// @name String Assignment
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
// Provide assign from SmallVectorImpl<char>
|
/// Assign from a repeated element.
|
||||||
using SmallVectorImpl<char>::assign;
|
void assign(size_t NumElts, char Elt) {
|
||||||
|
this->SmallVectorImpl<char>::assign(NumElts, Elt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Assign from an iterator pair.
|
||||||
|
template<typename in_iter>
|
||||||
|
void assign(in_iter S, in_iter E) {
|
||||||
|
this->clear();
|
||||||
|
SmallVectorImpl<char>::append(S, E);
|
||||||
|
}
|
||||||
|
|
||||||
/// Assign from a StringRef.
|
/// Assign from a StringRef.
|
||||||
void assign(StringRef RHS) {
|
void assign(StringRef RHS) {
|
||||||
@ -53,7 +65,20 @@ public:
|
|||||||
SmallVectorImpl<char>::append(RHS.begin(), RHS.end());
|
SmallVectorImpl<char>::append(RHS.begin(), RHS.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
using SmallVectorImpl<char>::append;
|
/// @}
|
||||||
|
/// @name String Concatenation
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/// Append from an iterator pair.
|
||||||
|
template<typename in_iter>
|
||||||
|
void append(in_iter S, in_iter E) {
|
||||||
|
SmallVectorImpl<char>::append(S, E);
|
||||||
|
}
|
||||||
|
|
||||||
|
void append(size_t NumInputs, char Elt) {
|
||||||
|
SmallVectorImpl<char>::append(NumInputs, Elt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Append from a StringRef.
|
/// Append from a StringRef.
|
||||||
void append(StringRef RHS) {
|
void append(StringRef RHS) {
|
||||||
@ -69,6 +94,12 @@ public:
|
|||||||
/// @name String Comparison
|
/// @name String Comparison
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
|
/// Check for string equality. This is more efficient than compare() when
|
||||||
|
/// the relative ordering of inequal strings isn't needed.
|
||||||
|
bool equals(StringRef RHS) const {
|
||||||
|
return str().equals(RHS);
|
||||||
|
}
|
||||||
|
|
||||||
/// Check for string equality, ignoring case.
|
/// Check for string equality, ignoring case.
|
||||||
bool equals_lower(StringRef RHS) const {
|
bool equals_lower(StringRef RHS) const {
|
||||||
return str().equals_lower(RHS);
|
return str().equals_lower(RHS);
|
||||||
@ -245,9 +276,6 @@ public:
|
|||||||
/// Implicit conversion to StringRef.
|
/// Implicit conversion to StringRef.
|
||||||
operator StringRef() const { return str(); }
|
operator StringRef() const { return str(); }
|
||||||
|
|
||||||
// Provide op= for SmallVectorImpl<char>
|
|
||||||
using SmallVectorImpl<char>::operator=;
|
|
||||||
|
|
||||||
// Extra operators.
|
// Extra operators.
|
||||||
const SmallString &operator=(StringRef RHS) {
|
const SmallString &operator=(StringRef RHS) {
|
||||||
this->clear();
|
this->clear();
|
||||||
@ -255,15 +283,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
SmallString &operator+=(StringRef RHS) {
|
SmallString &operator+=(StringRef RHS) {
|
||||||
append(RHS.begin(), RHS.end());
|
this->append(RHS.begin(), RHS.end());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SmallString &operator+=(const SmallVectorImpl<char> &RHS) {
|
|
||||||
append(RHS.begin(), RHS.end());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
SmallString &operator+=(char C) {
|
SmallString &operator+=(char C) {
|
||||||
this->push_back(C);
|
this->push_back(C);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -451,12 +451,10 @@ public:
|
|||||||
|
|
||||||
void assign(unsigned NumElts, const T &Elt) {
|
void assign(unsigned NumElts, const T &Elt) {
|
||||||
clear();
|
clear();
|
||||||
append(NumElts, Elt);
|
if (this->capacity() < NumElts)
|
||||||
}
|
this->grow(NumElts);
|
||||||
|
this->setEnd(this->begin()+NumElts);
|
||||||
template <typename in_iter> void assign(in_iter S, in_iter E) {
|
std::uninitialized_fill(this->begin(), this->end(), Elt);
|
||||||
clear();
|
|
||||||
append(S, E);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator erase(iterator I) {
|
iterator erase(iterator I) {
|
||||||
|
@ -50,7 +50,8 @@ public:
|
|||||||
|
|
||||||
bool operator==(const DILineInfo &RHS) const {
|
bool operator==(const DILineInfo &RHS) const {
|
||||||
return Line == RHS.Line && Column == RHS.Column &&
|
return Line == RHS.Line && Column == RHS.Column &&
|
||||||
FileName == RHS.FileName && FunctionName == RHS.FunctionName;
|
FileName.equals(RHS.FileName) &&
|
||||||
|
FunctionName.equals(RHS.FunctionName);
|
||||||
}
|
}
|
||||||
bool operator!=(const DILineInfo &RHS) const {
|
bool operator!=(const DILineInfo &RHS) const {
|
||||||
return !(*this == RHS);
|
return !(*this == RHS);
|
||||||
|
@ -50,6 +50,13 @@ TEST_F(SmallStringTest, AssignRepeated) {
|
|||||||
EXPECT_STREQ("aaa", theString.c_str());
|
EXPECT_STREQ("aaa", theString.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(SmallStringTest, AssignIterPair) {
|
||||||
|
StringRef abc = "abc";
|
||||||
|
theString.assign(abc.begin(), abc.end());
|
||||||
|
EXPECT_EQ(3u, theString.size());
|
||||||
|
EXPECT_STREQ("abc", theString.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(SmallStringTest, AssignStringRef) {
|
TEST_F(SmallStringTest, AssignStringRef) {
|
||||||
StringRef abc = "abc";
|
StringRef abc = "abc";
|
||||||
theString.assign(abc);
|
theString.assign(abc);
|
||||||
@ -81,23 +88,6 @@ TEST_F(SmallStringTest, AppendStringRef) {
|
|||||||
EXPECT_STREQ("abcabc", theString.c_str());
|
EXPECT_STREQ("abcabc", theString.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SmallStringTest, PlusEqualsStringRef) {
|
|
||||||
StringRef abc = "abc";
|
|
||||||
theString += abc;
|
|
||||||
theString += abc;
|
|
||||||
EXPECT_EQ(6u, theString.size());
|
|
||||||
EXPECT_STREQ("abcabc", theString.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(SmallStringTest, PlusEqualsSmallVector) {
|
|
||||||
StringRef abc = "abc";
|
|
||||||
SmallVector<char, 10> abcVec(abc.begin(), abc.end());
|
|
||||||
theString += abcVec;
|
|
||||||
theString += abcVec;
|
|
||||||
EXPECT_EQ(6u, theString.size());
|
|
||||||
EXPECT_STREQ("abcabc", theString.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(SmallStringTest, AppendSmallVector) {
|
TEST_F(SmallStringTest, AppendSmallVector) {
|
||||||
StringRef abc = "abc";
|
StringRef abc = "abc";
|
||||||
SmallVector<char, 10> abcVec(abc.begin(), abc.end());
|
SmallVector<char, 10> abcVec(abc.begin(), abc.end());
|
||||||
|
@ -338,17 +338,6 @@ TYPED_TEST(SmallVectorTest, AssignTest) {
|
|||||||
this->assertValuesInOrder(this->theVector, 2u, 77, 77);
|
this->assertValuesInOrder(this->theVector, 2u, 77, 77);
|
||||||
}
|
}
|
||||||
|
|
||||||
TYPED_TEST(SmallVectorTest, AssignIterPair) {
|
|
||||||
SCOPED_TRACE("AssignIterPair");
|
|
||||||
|
|
||||||
std::vector<int> v;
|
|
||||||
v.push_back(1);
|
|
||||||
v.push_back(2);
|
|
||||||
this->theVector.push_back(Constructable(1));
|
|
||||||
this->theVector.assign(v.begin(), v.end());
|
|
||||||
this->assertValuesInOrder(this->theVector, 2u, 1, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Erase a single element
|
// Erase a single element
|
||||||
TYPED_TEST(SmallVectorTest, EraseTest) {
|
TYPED_TEST(SmallVectorTest, EraseTest) {
|
||||||
SCOPED_TRACE("EraseTest");
|
SCOPED_TRACE("EraseTest");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user