[clang] [clang-format][NFC] Add CMake target clang-format-check-format (PR #95873)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 17 19:04:38 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)

<details>
<summary>Changes</summary>

Adpated from polly-check-format.

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


1 Files Affected:

- (modified) clang/lib/Format/CMakeLists.txt (+24) 


``````````diff
diff --git a/clang/lib/Format/CMakeLists.txt b/clang/lib/Format/CMakeLists.txt
index 84a3c136f650a..b787b11ac7b74 100644
--- a/clang/lib/Format/CMakeLists.txt
+++ b/clang/lib/Format/CMakeLists.txt
@@ -29,3 +29,27 @@ add_clang_library(clangFormat
   clangToolingCore
   clangToolingInclusions
   )
+
+file(GLOB_RECURSE files
+  *.cpp
+  *.h
+  ../../include/clang/Format/*.h
+  ../../tools/clang-format/*.cpp
+  ../../unittests/Format/*.cpp
+  ../../unittests/Format/*.h
+  )
+
+set(check_format_depends)
+set(i 0)
+foreach (file IN LISTS files)
+  add_custom_command(OUTPUT clang-format-check-format${i}
+    COMMAND clang-format ${file} | diff -u ${file} -
+    VERBATIM
+    COMMENT "Checking format of ${file}..."
+  )
+  list(APPEND check_format_depends "clang-format-check-format${i}")
+
+  math(EXPR i ${i}+1)
+endforeach ()
+
+add_custom_target(clang-format-check-format DEPENDS ${check_format_depends})

``````````

</details>


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


More information about the cfe-commits mailing list