diff options
author | Joe Loser <joeloser93@gmail.com> | 2021-10-29 19:04:32 -0400 |
---|---|---|
committer | Joe Loser <joeloser93@gmail.com> | 2021-10-29 19:04:54 -0400 |
commit | 40a6be4346097c008998d702381b07acbc6c9ae2 (patch) | |
tree | 212d0ea84443a4bf70570bbba1b3542d97278587 /clang/lib/Basic/FileManager.cpp | |
parent | d321548c3ce987f4f21350ba1c81fdb5d4354224 (diff) | |
download | llvm-40a6be4346097c008998d702381b07acbc6c9ae2.zip llvm-40a6be4346097c008998d702381b07acbc6c9ae2.tar.gz llvm-40a6be4346097c008998d702381b07acbc6c9ae2.tar.bz2 |
[libc++] Ensure valid view for view_interface template parameter
Some types that inherit from `view_interface` do not meet the
preconditions. This came up during discussion
in https://reviews.llvm.org/D112631. Currently, the behavior is IFNDR,
but the preconditions can be easily checked, so let's do so.
In particular, we know each public member function calls the
`__derived()` private function, so we can do the check there. We
intentionally do it as a `static_assert` instead of a `requires` clause
to avoid hard erroring in some cases, such as with incomplete types. An
example hard error is:
```
llvm-project/build/include/c++/v1/__ranges/view_interface.h:48:14: note: because 'sizeof(_Tp)' would be invalid: invalid application of 'sizeof' to an incomplete type 'MoveOnlyForwardRange'
requires { sizeof(_Tp); } &&
^
llvm-project/build/include/c++/v1/__ranges/view_interface.h:73:26: error: no matching member function for call to '__derived'
return ranges::begin(__derived()) == ranges::end(__derived());
^~~~~~~~~
llvm-project/libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp:187:31: note: in instantiation of function template specialization 'std::ranges::view_interface<MoveOnlyForwardRange>::empty<Mov
eOnlyForwardRange>' requested here
assert(!std::move(moveOnly).empty());
```
Reviewed By: Quuxplusone, Mordante, #libc
Differential Revision: https://reviews.llvm.org/D112665
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
0 files changed, 0 insertions, 0 deletions