[llvm] ArrayRef: add missing constexpr annotations (NFC) (PR #98874)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 18 17:56:04 PDT 2024


kazutakahirata wrote:

> > This is a perfectly good patch on its own, since Data + Length will be optimized.
> 
> Please explain this

Are you referring to this?

```
constexpr iterator end() const { return Data + Length; }
```

If so, do you need `Data + Length` to be evaluated at compile time?

I haven't understood the application side of things, but if the `constexpr` being added makes a difference to you, you might want to add unit tests that depend on the `constexpr` being added.  You can do something like:

- `static_assert(Ref.size() == 3)`
- `if constexpr (foo == Ref.end())`


https://github.com/llvm/llvm-project/pull/98874


More information about the llvm-commits mailing list