[libc-commits] [libc] [libc][cmake] Report invalid clang-tidy path (PR #66475)

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Fri Sep 15 02:04:22 PDT 2023


https://github.com/gchatelet created https://github.com/llvm/llvm-project/pull/66475

Adds better error reporting for clang-tidy.


>From a0fe980503bdbab5e36bea1ac84c96a022020248 Mon Sep 17 00:00:00 2001
From: Guillaume Chatelet <gchatelet at google.com>
Date: Fri, 15 Sep 2023 09:02:56 +0000
Subject: [PATCH] [libc][cmake] Report invalid clang-tidy path

---
 libc/CMakeLists.txt | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index f81fe01b3918741..0cec6fc07d982b4 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -190,7 +190,17 @@ if(LLVM_LIBC_ENABLE_LINTING)
     if(LLVM_LIBC_CLANG_TIDY)
       # Check clang-tidy major version.
       execute_process(COMMAND ${LLVM_LIBC_CLANG_TIDY} "--version"
-                      OUTPUT_VARIABLE CLANG_TIDY_OUTPUT)
+        OUTPUT_VARIABLE CLANG_TIDY_OUTPUT
+        ERROR_VARIABLE CLANG_TIDY_ERROR
+        RESULT_VARIABLE CLANG_TIDY_RESULT)
+
+      if(CLANG_TIDY_RESULT AND NOT CLANG_TIDY_RESULT EQUAL 0)
+        message(FATAL_ERROR "Failed to execute '${LLVM_LIBC_CLANG_TIDY} --version'
+          output : '${CLANG_TIDY_OUTPUT}'
+          error  : '${CLANG_TIDY_ERROR}'
+          result : '${CLANG_TIDY_RESULT}'
+          ")
+      endif()
       string(REGEX MATCH "[0-9]+" CLANG_TIDY_VERSION "${CLANG_TIDY_OUTPUT}")
       string(REGEX MATCH "[0-9]+" CLANG_MAJOR_VERSION
         "${CMAKE_CXX_COMPILER_VERSION}")



More information about the libc-commits mailing list