From 9dfaf1ad31c913a35535748ef6bcdc31d2dfc985 Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Wed, 1 May 2024 19:20:31 +0200 Subject: [PATCH] More fixes. --- libcxx/modules/std/ranges.inc | 7 ++++--- .../tools/clang_tidy_checks/CMakeLists.txt | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/libcxx/modules/std/ranges.inc b/libcxx/modules/std/ranges.inc index 80f31c79a1a405..f71efe948ede10 100644 --- a/libcxx/modules/std/ranges.inc +++ b/libcxx/modules/std/ranges.inc @@ -138,9 +138,6 @@ export namespace std { } #endif // _LIBCPP_HAS_NO_LOCALIZATION -#if _LIBCPP_STD_VER >= 23 - // [range.adaptor.object], range adaptor objects - using std::ranges::range_adaptor_closure; // Note: This declaration not in the synopsis or explicitly in the wording. // However it is needed for the range adaptors. // [range.adaptor.object]/3 @@ -151,7 +148,11 @@ export namespace std { // involving an object of type cv D as an operand to the | operator is // undefined if overload resolution selects a program-defined operator| // function. + // This is used internally in C++20 mode. using std::ranges::operator|; +#if _LIBCPP_STD_VER >= 23 + // [range.adaptor.object], range adaptor objects + using std::ranges::range_adaptor_closure; #endif // [range.all], all view diff --git a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt index 734569b2f5af4b..4deac7cf3f781e 100644 --- a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt +++ b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt @@ -64,6 +64,25 @@ if(NOT HAS_CLANG_TIDY_HEADERS) "clang-tidy headers are not present.") return() endif() + +# The clangTidy plugin uses C++20, when using stdlibc++ verify the version is correct. +# Note it has not been tested whether version 11 works. +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test.cpp" " +#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE < 12 + # error The stdlibc++ version is too old. +#endif +int main(){} +") +try_compile(HAS_NEWER_STANDARD_LIBRARY + "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}/test.cpp" + LINK_LIBRARIES clangTidy) + +if(NOT HAS_NEWER_STANDARD_LIBRARY) + message(STATUS "Clang-tidy tests are disabled due to using " + "stdlibc++ older than version 12") + return() +endif() message(STATUS "Clang-tidy tests are enabled.") set(SOURCES