StringMapEntryInitializer classes. Leave it for the compiler to figure out what
the type is and what "0" should be transformed into.
* Un-disable the unit tests which test the StringMapEntryInitializer class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61922
91177308-0d34-0410-b5e6-
96231b3b80d8
template<typename AllocatorTy>
static StringMapEntry *Create(const char *KeyStart, const char *KeyEnd,
AllocatorTy &Allocator) {
template<typename AllocatorTy>
static StringMapEntry *Create(const char *KeyStart, const char *KeyEnd,
AllocatorTy &Allocator) {
- return Create(KeyStart, KeyEnd, Allocator, (void*)0);
+ return Create(KeyStart, KeyEnd, Allocator, 0);
}
static StringMapEntry *Create(const char *KeyStart, const char *KeyEnd) {
}
static StringMapEntry *Create(const char *KeyStart, const char *KeyEnd) {
- return Create(KeyStart, KeyEnd, (void*)0);
+ return Create(KeyStart, KeyEnd, 0);
}
/// GetStringMapEntryFromValue - Given a value that is known to be embedded
}
/// GetStringMapEntryFromValue - Given a value that is known to be embedded
StringMapEntry<ValueTy> &GetOrCreateValue(const char *KeyStart,
const char *KeyEnd) {
StringMapEntry<ValueTy> &GetOrCreateValue(const char *KeyStart,
const char *KeyEnd) {
- return GetOrCreateValue(KeyStart, KeyEnd, (void*)0);
+ return GetOrCreateValue(KeyStart, KeyEnd, 0);
}
/// remove - Remove the specified key/value pair from the map, but do not
}
/// remove - Remove the specified key/value pair from the map, but do not
#include "llvm/ADT/StringMap.h"
using namespace llvm;
#include "llvm/ADT/StringMap.h"
using namespace llvm;
+namespace llvm {
+
+template <>
+class StringMapEntryInitializer<uint32_t> {
+public:
+ template <typename InitTy>
+ static void Initialize(StringMapEntry<uint32_t> &T, InitTy InitVal) {
+ T.second = InitVal;
+ }
+};
+
+}
+
namespace {
// Test fixture
namespace {
// Test fixture
// Test StringMapEntry::Create() method.
// DISABLED because this fails without a StringMapEntryInitializer, and
// I can't get it to compile with one.
// Test StringMapEntry::Create() method.
// DISABLED because this fails without a StringMapEntryInitializer, and
// I can't get it to compile with one.
-TEST_F(StringMapTest, DISABLED_StringMapEntryTest) {
+TEST_F(StringMapTest, StringMapEntryTest) {
+ MallocAllocator A;
StringMap<uint32_t>::value_type* entry =
StringMap<uint32_t>::value_type::Create(
StringMap<uint32_t>::value_type* entry =
StringMap<uint32_t>::value_type::Create(
- testKeyFirst, testKeyLast, 1u);
+ testKeyFirst, testKeyLast, A, 1u);
EXPECT_STREQ(testKey, entry->first());
EXPECT_EQ(1u, entry->second);
}
EXPECT_STREQ(testKey, entry->first());
EXPECT_EQ(1u, entry->second);
}
// Test insert() method
// DISABLED because this fails without a StringMapEntryInitializer, and
// I can't get it to compile with one.
// Test insert() method
// DISABLED because this fails without a StringMapEntryInitializer, and
// I can't get it to compile with one.
-TEST_F(StringMapTest, DISABLED_InsertTest) {
+TEST_F(StringMapTest, InsertTest) {
SCOPED_TRACE("InsertTest");
testMap.insert(
StringMap<uint32_t>::value_type::Create(
SCOPED_TRACE("InsertTest");
testMap.insert(
StringMap<uint32_t>::value_type::Create(