From 38593664b02bca98904c4b1883b0a489b5aaacbe Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 8 Jan 2009 08:26:46 +0000 Subject: [PATCH] * Don't explicitly cast "0" to "void*". This doesn't work well with specialized 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 --- include/llvm/ADT/StringMap.h | 6 +++--- unittests/ADT/StringMapTest.cpp | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index ac2705574ed..aec84a95034 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -182,7 +182,7 @@ public: template static StringMapEntry *Create(const char *KeyStart, const char *KeyEnd, AllocatorTy &Allocator) { - return Create(KeyStart, KeyEnd, Allocator, (void*)0); + return Create(KeyStart, KeyEnd, Allocator, 0); } @@ -195,7 +195,7 @@ public: } 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 @@ -378,7 +378,7 @@ public: StringMapEntry &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 diff --git a/unittests/ADT/StringMapTest.cpp b/unittests/ADT/StringMapTest.cpp index 3f135f6bd7b..bceff19c12d 100644 --- a/unittests/ADT/StringMapTest.cpp +++ b/unittests/ADT/StringMapTest.cpp @@ -11,6 +11,19 @@ #include "llvm/ADT/StringMap.h" using namespace llvm; +namespace llvm { + +template <> +class StringMapEntryInitializer { +public: + template + static void Initialize(StringMapEntry &T, InitTy InitVal) { + T.second = InitVal; + } +}; + +} + namespace { // Test fixture @@ -140,10 +153,11 @@ TEST_F(StringMapTest, InsertAndEraseTest) { // 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::value_type* entry = StringMap::value_type::Create( - testKeyFirst, testKeyLast, 1u); + testKeyFirst, testKeyLast, A, 1u); EXPECT_STREQ(testKey, entry->first()); EXPECT_EQ(1u, entry->second); } @@ -151,7 +165,7 @@ TEST_F(StringMapTest, DISABLED_StringMapEntryTest) { // 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::value_type::Create( -- 2.34.1