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

Adpated from polly-check-format.

>From ab2a61d1939f4be4551949e979fd43b9e11c5c49 Mon Sep 17 00:00:00 2001
From: Owen Pan <owenpi...@gmail.com>
Date: Mon, 17 Jun 2024 18:49:22 -0700
Subject: [PATCH] [clang-format][NFC] Add CMake target
 clang-format-check-format

Adpated from polly-check-format.
---
 clang/lib/Format/CMakeLists.txt | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

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})

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to