[libcxx-commits] [libcxx] 664f345 - [libc++] Improves clang-tidy configuration.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sun Feb 26 03:19:56 PST 2023


Author: Mark de Wever
Date: 2023-02-26T12:19:50+01:00
New Revision: 664f345cd53d1f624d94f9889a1c9fff803e3391

URL: https://github.com/llvm/llvm-project/commit/664f345cd53d1f624d94f9889a1c9fff803e3391
DIFF: https://github.com/llvm/llvm-project/commit/664f345cd53d1f624d94f9889a1c9fff803e3391.diff

LOG: [libc++] Improves clang-tidy configuration.

The current clang-tidy settings work in the CI but not on all systems
outside the CI.
- The range 16...17 doesn't work when only clang-17 is installed.
- Running CMake a second time will fail.

This addresses these issues.

Reviewed By: philnik, #libc

Differential Revision: https://reviews.llvm.org/D144785

Added: 
    

Modified: 
    libcxx/test/tools/clang_tidy_checks/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
index f5484fb16ce10..f1664eee1f6e8 100644
--- a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
+++ b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
@@ -3,7 +3,16 @@
 set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
 set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
 
-find_package(Clang 16...17)
+# The find_package changes these variables. This leaves the build in an odd
+# state. Calling cmake a second time tries to write site config information in
+# the system's libc++. Restoring these setting after testing fixes this issue.
+set(LLVM_DIR_SAVE ${LLVM_DIR})
+set(Clang_DIR_SAVE ${Clang_DIR})
+
+find_package(Clang 16)
+if (NOT Clang_FOUND)
+  find_package(Clang 17)
+endif()
 
 set(SOURCES
     abi_tag_on_virtual.cpp
@@ -21,6 +30,9 @@ if(NOT Clang_FOUND)
   return()
 endif()
 
+set(LLVM_DIR "${LLVM_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for LLVM." FORCE)
+set(Clang_DIR "${Clang_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for Clang." FORCE)
+
 message(STATUS "Found system-installed LLVM ${LLVM_PACKAGE_VERSION} with headers in ${LLVM_INCLUDE_DIRS}")
 
 set(CMAKE_CXX_STANDARD 20)


        


More information about the libcxx-commits mailing list