#include <cassert>
#include <cstring>
+#include "llvm/Support/DataTypes.h"
namespace llvm {
// If small, this is # elts allocated consequtively
unsigned NumElements;
+ unsigned NumTombstones;
void *SmallArray[1]; // Must be last ivar.
public:
SmallPtrSetImpl(unsigned SmallSize) {
delete[] CurArray;
}
+ bool empty() const { return size() == 0; }
+ unsigned size() const { return NumElements; }
+
static void *getTombstoneMarker() { return reinterpret_cast<void*>(-2); }
static void *getEmptyMarker() {
// Note that -1 is chosen to make clear() efficiently implementable with
// Fill the array with empty markers.
memset(CurArray, -1, CurArraySize*sizeof(void*));
NumElements = 0;
+ NumTombstones = 0;
}
/// insert - This returns true if the pointer was new to the set, false if it
enum {
// We could just use NextVal = N+1, but this converges faster. N|(N-1) sets
// the right-most zero bits to one all at once, e.g. 0b0011000 -> 0b0011111.
- NextVal = (N|(N-1)) + 1,
- Val = NextPowerOfTwo<NextVal>::Val
+ Val = NextPowerOfTwo<(N|(N-1)) + 1>::Val
};
};