1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

The key of a StringMap can contain nul's in it, so having first() return

const char* doesn't make sense.  Have it return StringRef instead.

llvm-svn: 135167
This commit is contained in:
Chris Lattner 2011-07-14 18:31:43 +00:00
parent b252bb8f86
commit 5bf752bcf4
2 changed files with 4 additions and 4 deletions

View File

@ -140,7 +140,7 @@ public:
/// StringMapEntry object.
const char *getKeyData() const {return reinterpret_cast<const char*>(this+1);}
const char *first() const { return getKeyData(); }
StringRef first() const { return StringRef(getKeyData(), getKeyLength()); }
/// Create - Create a StringMapEntry for the specified key and default
/// construct the value.

View File

@ -51,7 +51,7 @@ protected:
// Iterator tests
StringMap<uint32_t>::iterator it = testMap.begin();
EXPECT_STREQ(testKey, it->first());
EXPECT_STREQ(testKey, it->first().data());
EXPECT_EQ(testValue, it->second);
++it;
EXPECT_TRUE(it == testMap.end());
@ -157,7 +157,7 @@ TEST_F(StringMapTest, IterationTest) {
it != testMap.end(); ++it) {
std::stringstream ss;
ss << "key_" << it->second;
ASSERT_STREQ(ss.str().c_str(), it->first());
ASSERT_STREQ(ss.str().c_str(), it->first().data());
visited[it->second] = true;
}
@ -189,7 +189,7 @@ TEST_F(StringMapTest, StringMapEntryTest) {
StringMap<uint32_t>::value_type* entry =
StringMap<uint32_t>::value_type::Create(
testKeyFirst, testKeyFirst + testKeyLength, 1u);
EXPECT_STREQ(testKey, entry->first());
EXPECT_STREQ(testKey, entry->first().data());
EXPECT_EQ(1u, entry->second);
free(entry);
}