//===----------------------------------------------------------------------===//
#include "llvm/ADT/FoldingSet.h"
-#include "llvm/ADT/APFloat.h"
-#include "llvm/ADT/APInt.h"
#include "llvm/Support/MathExtras.h"
#include <cassert>
+#include <cstring>
using namespace llvm;
//===----------------------------------------------------------------------===//
void FoldingSetNodeID::AddDouble(double D) {
AddInteger(DoubleToBits(D));
}
-void FoldingSetNodeID::AddAPFloat(const APFloat& apf) {
- APInt api = apf.convertToAPInt();
- AddAPInt(api);
-}
-void FoldingSetNodeID::AddAPInt(const APInt& api) {
- const uint64_t *p = api.getRawData();
- for (unsigned i=0; i<api.getNumWords(); i++)
- AddInteger(*p++);
-}
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;
/// 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;
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;
FoldingSetIteratorImpl::FoldingSetIteratorImpl(void **Bucket) {
// Skip to the first non-null non-self-cycle bucket.
- while (*Bucket == 0 || GetNextPtr(*Bucket) == 0)
+ while (*Bucket != reinterpret_cast<void*>(-1) &&
+ (*Bucket == 0 || GetNextPtr(*Bucket) == 0))
++Bucket;
NodePtr = static_cast<FoldingSetNode*>(*Bucket);
// Skip to the next non-null non-self-cycle bucket.
do {
++Bucket;
- } while (*Bucket == 0 || GetNextPtr(*Bucket) == 0);
+ } while (*Bucket != reinterpret_cast<void*>(-1) &&
+ (*Bucket == 0 || GetNextPtr(*Bucket) == 0));
NodePtr = static_cast<FoldingSetNode*>(*Bucket);
}