[libcxx-commits] [PATCH] D106124: [libcxx][modules] protects users from relying on ranges detail headers
Zoe Carver via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jul 16 10:14:19 PDT 2021
zoecarver added inline comments.
================
Comment at: libcxx/include/__ranges/drop_view.h:13
#include <__config>
+#if defined(_LIBCPP_HAS_NO_MODULES) && !defined(_LIBCPP_DETAIL_HEADERS_ALLOWED)
+# error <__ranges/drop_view.h> is a libc++ detail header and can't be directly included by users. Please '#include <ranges>' instead.
----------------
Two suggestions:
1) could we make this a smaller macro? For example, could we make it so that in `drop_view.h` I only have to type out `_LIBCPP_PRIVATE_HEADER(ranges, __ranges/drop_view.h)`?
2) Could we somehow roll this into `_LIBCPP_PUSH_MACROS` and `_LIBCPP_POP_MACROS` so that we don't even need to update it? This would require some creative design work but I think it might be doable.
================
Comment at: libcxx/test/libcxx/diagnostics/detail.headers/ranges/view_interface.header.verify.cpp:13
+// expected-error@*:* {{<__ranges/view_interface.h> is a libc++ detail header and can't be directly included by users. Please '#include <ranges>' instead.}}
+#include <__ranges/view_interface.h>
----------------
Could these tests be turned into a custom shell test that automates all this? I don't really want to have to do //another// thing every time I add a header file.
(You can use `RUN: <whatever>` [[ https://github.com/llvm/llvm-project/blob/main/libcxx/test/std/namespace/addressable_functions.sh.cpp#L15 | like this ]].)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106124/new/
https://reviews.llvm.org/D106124
More information about the libcxx-commits
mailing list