[llvm-commits] [llvm] r61922 - in /llvm/trunk: include/llvm/ADT/StringMap.h unittests/ADT/StringMapTest.cpp
Bill Wendling
isanbard at gmail.com
Thu Jan 8 00:26:47 PST 2009
Author: void
Date: Thu Jan 8 02:26:46 2009
New Revision: 61922
URL: http://llvm.org/viewvc/llvm-project?rev=61922&view=rev
Log:
* 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.
Modified:
llvm/trunk/include/llvm/ADT/StringMap.h
llvm/trunk/unittests/ADT/StringMapTest.cpp
Modified: llvm/trunk/include/llvm/ADT/StringMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=61922&r1=61921&r2=61922&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringMap.h (original)
+++ llvm/trunk/include/llvm/ADT/StringMap.h Thu Jan 8 02:26:46 2009
@@ -182,7 +182,7 @@
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);
}
@@ -195,7 +195,7 @@
}
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 @@
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
Modified: llvm/trunk/unittests/ADT/StringMapTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringMapTest.cpp?rev=61922&r1=61921&r2=61922&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/StringMapTest.cpp (original)
+++ llvm/trunk/unittests/ADT/StringMapTest.cpp Thu Jan 8 02:26:46 2009
@@ -11,6 +11,19 @@
#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
@@ -140,10 +153,11 @@
// 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(
- testKeyFirst, testKeyLast, 1u);
+ testKeyFirst, testKeyLast, A, 1u);
EXPECT_STREQ(testKey, entry->first());
EXPECT_EQ(1u, entry->second);
}
@@ -151,7 +165,7 @@
// 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(
More information about the llvm-commits
mailing list