[clang] [clang-format][NFC] Don't always rebuild clang-format-check-format (PR #203828)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 14 22:37:35 PDT 2026
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/203828
Instead, checking the format of clan-format source only if the built clang-format binary or one of the source files is newer.
>From a170b69b3ac91e425c47e91aa6ec46eca3858c93 Mon Sep 17 00:00:00 2001
From: Owen Pan <owenpiano at gmail.com>
Date: Sun, 14 Jun 2026 22:26:22 -0700
Subject: [PATCH] [clang-format][NFC] Don't always rebuild
clang-format-check-format
Instead, checking the format of clan-format source only if the built
clang-format binary or one of the source files is newer.
---
clang/lib/Format/CMakeLists.txt | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Format/CMakeLists.txt b/clang/lib/Format/CMakeLists.txt
index 50c0683dc9b7f..3e19151790440 100644
--- a/clang/lib/Format/CMakeLists.txt
+++ b/clang/lib/Format/CMakeLists.txt
@@ -45,9 +45,12 @@ set(check_format_depends)
set(i 0)
foreach(file IN LISTS files)
add_custom_command(OUTPUT check_format_depend_${i}
- COMMAND clang-format ${file} | diff -u ${file} -
+ COMMAND clang-format ${file} | diff -u ${file} - &&
+ touch check_format_depend_${i}
VERBATIM
COMMENT "Checking format of ${file}"
+ DEPENDS clang-format
+ ${file}
)
list(APPEND check_format_depends check_format_depend_${i})
math(EXPR i ${i}+1)
More information about the cfe-commits
mailing list