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

via libc-commits libc-commits at lists.llvm.org
Fri Sep 15 02:05:24 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc
            
<details>
<summary>Changes</summary>
Adds better error reporting for clang-tidy.

--
Full diff: https://github.com/llvm/llvm-project/pull/66475.diff

1 Files Affected:

- (modified) libc/CMakeLists.txt (+11-1) 


<pre>
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} &quot;--version&quot;
-                      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 &quot;Failed to execute &#x27;${LLVM_LIBC_CLANG_TIDY} --version&#x27;
+          output : &#x27;${CLANG_TIDY_OUTPUT}&#x27;
+          error  : &#x27;${CLANG_TIDY_ERROR}&#x27;
+          result : &#x27;${CLANG_TIDY_RESULT}&#x27;
+          &quot;)
+      endif()
       string(REGEX MATCH &quot;[0-9]+&quot; CLANG_TIDY_VERSION &quot;${CLANG_TIDY_OUTPUT}&quot;)
       string(REGEX MATCH &quot;[0-9]+&quot; CLANG_MAJOR_VERSION
         &quot;${CMAKE_CXX_COMPILER_VERSION}&quot;)
</pre>
</details>


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


More information about the libc-commits mailing list