[libc++] Introduce __is_pointer_in_range
authorNikolas Klauser <nikolasklauser@berlin.de>
Wed, 7 Jun 2023 20:33:02 +0000 (13:33 -0700)
committerNikolas Klauser <nikolasklauser@berlin.de>
Wed, 7 Jun 2023 20:33:58 +0000 (13:33 -0700)
commit7949ee0d4f10f4fa3b3021fb6269e14175c3b0ae
treed714ea2a802a84b564404cc9b3230da3144138c9
parent5aea839ab3edeb58bb0eea833ad9427d0ae7ef67
[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
libcxx/.clang-format
libcxx/include/CMakeLists.txt
libcxx/include/__config
libcxx/include/__utility/is_pointer_in_range.h [new file with mode: 0644]
libcxx/include/module.modulemap.in
libcxx/include/string
libcxx/test/libcxx/utilities/is_pointer_in_range.pass.cpp [new file with mode: 0644]