Share some code that is common between integer and
[oota-llvm.git] / lib / Support / FoldingSet.cpp
index bf50ed43dfe178414e9eaa544f6acad3f52eb25c..80140438714d99284d247802e6d39d7653b4f4ca 100644 (file)
@@ -58,7 +58,7 @@ void FoldingSetNodeID::AddDouble(double D) {
  AddInteger(DoubleToBits(D));
 }
 void FoldingSetNodeID::AddString(const std::string &String) {
-  unsigned Size = String.size();
+  unsigned Size = static_cast<unsigned>(String.size());
   Bits.push_back(Size);
   if (!Size) return;
 
@@ -98,7 +98,7 @@ void FoldingSetNodeID::AddString(const std::string &String) {
 /// lookup the node in the FoldingSetImpl.
 unsigned FoldingSetNodeID::ComputeHash() const {
   // This is adapted from SuperFastHash by Paul Hsieh.
-  unsigned Hash = Bits.size();
+  unsigned Hash = static_cast<unsigned>(Bits.size());
   for (const unsigned *BP = &Bits[0], *E = BP+Bits.size(); BP != E; ++BP) {
     unsigned Data = *BP;
     Hash         += Data & 0xFFFF;
@@ -170,7 +170,7 @@ FoldingSetImpl::FoldingSetImpl(unsigned Log2InitSize) : NumNodes(0) {
   memset(Buckets, 0, NumBuckets*sizeof(void*));
   
   // Set the very last bucket to be a non-null "pointer".
-  Buckets[NumBuckets] = reinterpret_cast<void*>(-2);
+  Buckets[NumBuckets] = reinterpret_cast<void*>(-1);
 }
 FoldingSetImpl::~FoldingSetImpl() {
   delete [] Buckets;