NNikolas Klauser[libc++] Granularize the rest of memory
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
[libc++] Granularize the rest of memory Reviewed By: ldionne, #libc Spies: vitalybuka, paulkirth, libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D132790 | 3 年前 | |
[libc++] Fix std::to_address(array). There were basically two bugs here: When C++20 to_address is called on int arr[10], then const _Ptr& becomes a reference to a const array, and then we dispatch to __to_address<const int(&)[10]>, which, oops, gives us a const int* result instead of an int* result. Solution: We need to provide the two standard-specified overloads of std::to_address in exactly the same way that we provide two overloads of __to_address. When __to_address is called on a pointer type, __to_address(const _Ptr&) is disabled so we successfully avoid trying to instantiate pointer_traits of that pointer type. But when it's called on an array type, it's not disabled for array types, so we go ahead and instantiate pointer_traits<int[10]>, which goes boom. Solution: We need to disable __to_address(const _Ptr&) for both pointer and array types. Also disable it for function types, so that they get the nice error message; and put a test on it. Differential Revision: https://reviews.llvm.org/D109331 | 4 年前 | |
[libc++] Fix std::to_address(array). There were basically two bugs here: When C++20 to_address is called on int arr[10], then const _Ptr& becomes a reference to a const array, and then we dispatch to __to_address<const int(&)[10]>, which, oops, gives us a const int* result instead of an int* result. Solution: We need to provide the two standard-specified overloads of std::to_address in exactly the same way that we provide two overloads of __to_address. When __to_address is called on a pointer type, __to_address(const _Ptr&) is disabled so we successfully avoid trying to instantiate pointer_traits of that pointer type. But when it's called on an array type, it's not disabled for array types, so we go ahead and instantiate pointer_traits<int[10]>, which goes boom. Solution: We need to disable __to_address(const _Ptr&) for both pointer and array types. Also disable it for function types, so that they get the nice error message; and put a test on it. Differential Revision: https://reviews.llvm.org/D109331 | 4 年前 | |
[libc++] Fix __wrap_iter to be a proper contiguous iterator. Instead of overloading __to_address, let's specialize pointer_traits. Function overloads need to be in scope at the point where they're called, whereas template specializations do not. (User code can provide pointer_traits specializations to be used by already-included library code, so obviously __wrap_iter can do the same.) pointer_traits<__wrap_iter<It>> cannot provide pointer_to, because you generally cannot create a __wrap_iter without also knowing the identity of the container into which you're trying to create an iterator. I believe this is OK; contiguous iterators are required to provide to_address but *not* necessarily pointer_to. Differential Revision: https://reviews.llvm.org/D110198 | 4 年前 |