File tree Expand file tree Collapse file tree 6 files changed +28
-19
lines changed Expand file tree Collapse file tree 6 files changed +28
-19
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ option(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS
123123 to provide compile-time errors when using features unavailable on some version of
124124 the shared library they shipped should turn this on and see `include/__availability`
125125 for more details." OFF )
126+ option (LIBCXX_ENABLE_CLANG_TIDY "Whether to compile and run clang-tidy checks" OFF )
126127
127128if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
128129 set (LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-gcc.cfg.in" )
@@ -862,6 +863,10 @@ add_subdirectory(modules)
862863
863864set (LIBCXX_TEST_DEPS "cxx_experimental" )
864865
866+ if (LIBCXX_ENABLE_CLANG_TIDY)
867+ list (APPEND LIBCXX_TEST_DEPS cxx-tidy)
868+ endif ()
869+
865870list (APPEND LIBCXX_TEST_DEPS generate-cxx-modules)
866871
867872if (LIBCXX_INCLUDE_BENCHMARKS)
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ Deprecations and Removals
8282 libatomic is not available. If you are one such user, please reach out to the libc++ developers so we can collaborate
8383 on a path for supporting atomics properly on freestanding platforms.
8484
85+
8586Upcoming Deprecations and Removals
8687----------------------------------
8788
@@ -106,6 +107,3 @@ Build System Changes
106107
107108- The ``LIBCXX_EXECUTOR `` and ``LIBCXXABI_EXECUTOR `` CMake variables have been removed. Please
108109 set ``LIBCXX_TEST_PARAMS `` to ``executor=<...> `` instead.
109-
110- - The Cmake variable ``LIBCXX_ENABLE_CLANG_TIDY `` has been removed. The build system has been changed
111- to automatically detect the presence of ``clang-tidy `` and the required ``Clang `` libraries.
Original file line number Diff line number Diff line change 11
22set (LIBCXX_TEST_TOOLS_PATH ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
33
4- if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
5- message (STATUS "Clang-tidy tests are disabled due to non-clang based compiler." )
6- return ()
4+ # TODO: Remove LIBCXX_ENABLE_CLANG_TIDY
5+ if (LIBCXX_ENABLE_CLANG_TIDY)
6+ if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
7+ message (STATUS "Clang-tidy can only be used when building libc++ with "
8+ "a clang compiler." )
9+ return ()
10+ endif ()
11+ add_subdirectory (clang_tidy_checks)
712endif ()
8- add_subdirectory (clang_tidy_checks)
Original file line number Diff line number Diff line change @@ -9,17 +9,6 @@ set(Clang_DIR_SAVE ${Clang_DIR})
99# versions must match. Otherwise there likely will be ODR-violations. This had
1010# led to crashes and incorrect output of the clang-tidy based checks.
1111find_package (Clang ${CMAKE_CXX_COMPILER_VERSION} )
12- if (NOT Clang_FOUND)
13- message (STATUS "Clang-tidy tests are disabled since the "
14- "Clang development package is unavailable." )
15- return ()
16- endif ()
17- if (NOT TARGET clangTidy)
18- message (STATUS "Clang-tidy tests are disabled since the "
19- "Clang development package has no clangTidy target." )
20- return ()
21- endif ()
22- message (STATUS "Clang-tidy tests are enabled." )
2312
2413set (SOURCES
2514 abi_tag_on_virtual.cpp
@@ -33,7 +22,11 @@ set(SOURCES
3322 libcpp_module.cpp
3423 )
3524
36- list (APPEND LIBCXX_TEST_DEPS cxx-tidy)
25+ if (NOT Clang_FOUND)
26+ message (STATUS "Could not find a suitable version of the Clang development package;
27+ custom libc++ clang-tidy checks will not be available." )
28+ return ()
29+ endif ()
3730
3831set (LLVM_DIR "${LLVM_DIR_SAVE} " CACHE PATH "The directory containing a CMake configuration file for LLVM." FORCE)
3932set (Clang_DIR "${Clang_DIR_SAVE} " CACHE PATH "The directory containing a CMake configuration file for Clang." FORCE)
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ definitions:
4343
4444environment_definitions :
4545 _common_env : &common_env
46+ ENABLE_CLANG_TIDY : " On"
4647 LLVM_SYMBOLIZER_PATH : " /usr/bin/llvm-symbolizer-${LLVM_HEAD_VERSION}"
4748 CLANG_CRASH_DIAGNOSTICS_DIR : " crash_diagnostics"
4849 CC : clang-${LLVM_HEAD_VERSION}
Original file line number Diff line number Diff line change @@ -44,6 +44,9 @@ CMAKE The CMake binary to use. This variable is optional.
4444CLANG_FORMAT The clang-format binary to use when generating the format
4545 ignore list.
4646
47+ ENABLE_CLANG_TIDY Whether to compile and run clang-tidy checks. This variable
48+ is optional.
49+
4750EOF
4851}
4952
@@ -108,6 +111,10 @@ function clean() {
108111 rm -rf " ${BUILD_DIR} "
109112}
110113
114+ if [ -z " ${ENABLE_CLANG_TIDY} " ]; then
115+ ENABLE_CLANG_TIDY=Off
116+ fi
117+
111118function generate-cmake-base() {
112119 echo " --- Generating CMake"
113120 ${CMAKE} \
@@ -119,6 +126,7 @@ function generate-cmake-base() {
119126 -DLIBCXX_ENABLE_WERROR=YES \
120127 -DLIBCXXABI_ENABLE_WERROR=YES \
121128 -DLIBUNWIND_ENABLE_WERROR=YES \
129+ -DLIBCXX_ENABLE_CLANG_TIDY=${ENABLE_CLANG_TIDY} \
122130 -DLLVM_LIT_ARGS=" -sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
123131 " ${@ } "
124132}
You can’t perform that action at this time.
0 commit comments