[libc++] Introduce __is_pointer_in_range

This checks whether a pointer is within a range, even during constant evaluation. This allows running optimized code paths during constant evaluation, instead of falling back to the general-purpose implementation all the time. This is also a central place for comparing unrelated pointers, which is technically UB.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D143327

GitOrigin-RevId: 7949ee0d4f10f4fa3b3021fb6269e14175c3b0ae
7 files changed