[libcxx-commits] [libcxx] [libc++][CMake] Adds option to disable clang-tidy. (PR #95654)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jun 15 04:58:24 PDT 2024


https://github.com/mordante created https://github.com/llvm/llvm-project/pull/95654

There have been some reports that always enabling clang-tidy (added in #90077) has some false positives in the detection. It would be good to fix these. This adds an escape hatch to disable the tests, which avoids blocking users with this issue.

>From 33699d72208b6b2b362c5490f10b2f059a365d44 Mon Sep 17 00:00:00 2001
From: Mark de Wever <koraq at xs4all.nl>
Date: Sat, 15 Jun 2024 13:54:58 +0200
Subject: [PATCH] [libc++][CMake] Adds option to disable clang-tidy.

There have been some reports that always enabling clang-tidy (added in
#90077) has some false positives in the detection. It would be good to fix
these. This adds an escape hatch to disable the tests, which avoids
blocking users with this issue.
---
 libcxx/CMakeLists.txt            | 4 ++++
 libcxx/test/tools/CMakeLists.txt | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 4b927017f8c2a..9a35ff30114cd 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -60,6 +60,10 @@ option(LIBCXX_ENABLE_FILESYSTEM
    available on the platform. This includes things like most parts of <filesystem> and
    others like <fstream>" ON)
 option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
+option(LIBCXX_DISABLE_CLANG_TIDY_TESTS
+  "Disables test using the clang-tidy plugin. This option should only be used
+   when autodetection fails, please file a bug report so the autodetection can
+   be improved." OFF)
 set(LIBCXX_SUPPORTED_HARDENING_MODES none fast extensive debug)
 set(LIBCXX_HARDENING_MODE "none" CACHE STRING
   "Specify the default hardening mode to use. This mode will be used inside the
diff --git a/libcxx/test/tools/CMakeLists.txt b/libcxx/test/tools/CMakeLists.txt
index 6d99c53ad46d9..801e45521edb8 100644
--- a/libcxx/test/tools/CMakeLists.txt
+++ b/libcxx/test/tools/CMakeLists.txt
@@ -5,4 +5,8 @@ if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
   message(STATUS "Clang-tidy tests are disabled due to non-clang based compiler.")
   return()
 endif()
+if(LIBCXX_DISABLE_CLANG_TIDY_TESTS)
+  message(STATUS "Clang-tidy tests are disabled by the configuration option LIBCXX_DISABLE_CLANG_TIDY_TESTS.")
+  return()
+endif()
 add_subdirectory(clang_tidy_checks)



More information about the libcxx-commits mailing list