Skip to content

Commit

Permalink
[libcxx][modules] protects users from relying on detail headers
Browse files Browse the repository at this point in the history
libc++ has started splicing standard library headers into much more
fine-grained content for maintainability. It's very likely that outdated
and naive tooling (some of which is outside of LLVM's scope) will
suggest users include things such as <__ranges/access.h> instead of
<ranges>, and Hyrum's law suggests that users will eventually begin to
rely on this without the help of tooling. As such, this commit
intends to protect users from themselves, by making it a hard error for
anyone outside of the standard library to include libc++ detail headers.

Differential Revision: https://reviews.llvm.org/D106124
  • Loading branch information
cjdb committed Feb 26, 2022
1 parent 274ec42 commit 5aaefa5
Show file tree
Hide file tree
Showing 1,147 changed files with 8,785 additions and 13 deletions.
2 changes: 1 addition & 1 deletion libcxx/cmake/Modules/HandleLibCXXABI.cmake
Expand Up @@ -117,7 +117,7 @@ elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi")

setup_abi_lib(
"-DLIBCXX_BUILDING_LIBCXXABI"
"${shared}" "${static}" "cxxabi.h;__cxxabi_config.h" "")
"${shared}" "${static}" "cxxabi.h;__cxxabi_config.h;threading_support.h" "")
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt")
if(NOT LIBCXX_CXX_ABI_INCLUDE_PATHS)
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "/usr/include/c++/v1")
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/adjacent_find.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/all_of.h
Expand Up @@ -14,6 +14,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/any_of.h
Expand Up @@ -14,6 +14,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/binary_search.h
Expand Up @@ -17,6 +17,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/clamp.h
Expand Up @@ -15,6 +15,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/comp.h
Expand Up @@ -13,6 +13,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/comp_ref_type.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/copy.h
Expand Up @@ -17,6 +17,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/copy_backward.h
Expand Up @@ -17,6 +17,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/copy_if.h
Expand Up @@ -13,6 +13,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/copy_n.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/count.h
Expand Up @@ -15,6 +15,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/count_if.h
Expand Up @@ -15,6 +15,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/equal.h
Expand Up @@ -17,6 +17,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/equal_range.h
Expand Up @@ -19,6 +19,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/fill.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/fill_n.h
Expand Up @@ -15,6 +15,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/find.h
Expand Up @@ -14,6 +14,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/find_end.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/find_first_of.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/find_if.h
Expand Up @@ -14,6 +14,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/find_if_not.h
Expand Up @@ -14,6 +14,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/for_each.h
Expand Up @@ -14,6 +14,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/for_each_n.h
Expand Up @@ -15,6 +15,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/generate.h
Expand Up @@ -13,6 +13,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/generate_n.h
Expand Up @@ -14,6 +14,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/half_positive.h
Expand Up @@ -14,6 +14,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/in_found_result.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/in_fun_result.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/in_in_out_result.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/in_in_result.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/in_out_out_result.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/in_out_result.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/includes.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/inplace_merge.h
Expand Up @@ -23,6 +23,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_PUSH_MACROS
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/is_heap.h
Expand Up @@ -17,6 +17,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/is_heap_until.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/is_partitioned.h
Expand Up @@ -13,6 +13,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/is_permutation.h
Expand Up @@ -18,6 +18,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/is_sorted.h
Expand Up @@ -17,6 +17,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/is_sorted_until.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/iter_swap.h
Expand Up @@ -15,6 +15,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/lexicographical_compare.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/lower_bound.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/make_heap.h
Expand Up @@ -17,6 +17,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/max.h
Expand Up @@ -17,6 +17,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_PUSH_MACROS
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/max_element.h
Expand Up @@ -16,6 +16,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__algorithm/merge.h
Expand Up @@ -17,6 +17,7 @@

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# pragma clang include_instead(<algorithm>)
#endif

_LIBCPP_BEGIN_NAMESPACE_STD
Expand Down

0 comments on commit 5aaefa5

Please sign in to comment.