@@ -45,12 +45,15 @@ class Context {
4545 public:
4646 // Uses a 64-bit integer so we don't have to worry about the unlikely case
4747 // of overflowing a 32-bit counter.
48- using ReprTy = uint64_t ;
48+ using ValTy = uint64_t ;
49+ static constexpr const ValTy InvalidVal = 0 ;
4950
5051 private:
5152 // Default initialization results in an invalid ID.
52- ReprTy Val = std::numeric_limits<ReprTy>::max();
53- explicit CallbackID (ReprTy Val) : Val{Val} {}
53+ ValTy Val = InvalidVal;
54+ explicit CallbackID (ValTy Val) : Val{Val} {
55+ assert (Val != InvalidVal && " newly-created ID is invalid!" );
56+ }
5457
5558 public:
5659 CallbackID () = default ;
@@ -99,7 +102,7 @@ class Context {
99102 // / A counter used for assigning callback IDs during registration. The same
100103 // / counter is used for all kinds of callbacks so we can detect mismatched
101104 // / registration/deregistration.
102- CallbackID::ReprTy NextCallbackID = 0 ;
105+ CallbackID::ValTy NextCallbackID = 1 ;
103106
104107 // / Remove \p V from the maps and returns the unique_ptr.
105108 std::unique_ptr<Value> detachLLVMValue (llvm::Value *V);
@@ -284,7 +287,7 @@ class Context {
284287// DenseMap info for CallbackIDs
285288template <> struct DenseMapInfo <sandboxir::Context::CallbackID> {
286289 using CallbackID = sandboxir::Context::CallbackID;
287- using ReprInfo = DenseMapInfo<CallbackID::ReprTy >;
290+ using ReprInfo = DenseMapInfo<CallbackID::ValTy >;
288291
289292 static CallbackID getEmptyKey () {
290293 return CallbackID{ReprInfo::getEmptyKey ()};
0 commit comments