[clang] [llvm] [ADT] Add and use (for AArch64) `ValueOrSentinel<T, Sentinel>` (PR #158120)
    Benjamin Maxwell via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Fri Sep 12 06:59:59 PDT 2025
    
    
  
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
    
    
More information about the llvm-commits
mailing list