MacDue wrote:

> > That looks like a slightly less general version of this class, so 
> > UnsignedOrNone could be implemented as `UnsignedOrNone = 
> > ValueOrSentinel<unsigned, -1>`.
> 
> Actually could not. Some `UnsignedOrNone` values are stored in bit-fields 
> which are less then 32 bits, so the sentinel is stored as `0` and value `x` 
> is stored as `x + 1` to avoid wrong value when converting bit-fields back to 
> `UnsignedOrNone`.

I've tweaked `ValueOrSentinel` to allow passing an "adjustment" which allows it 
to handle use cases like `UnsignedOrNone`.

https://github.com/llvm/llvm-project/pull/158120
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to