[libcxx-commits] [libcxx] f7f8645 - [libc++] Improve the format ignorelist generation.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Fri Feb 17 09:02:03 PST 2023


Author: Mark de Wever
Date: 2023-02-17T18:01:57+01:00
New Revision: f7f86451ecd78e0b48be905da7f9ae5f7f92647e

URL: https://github.com/llvm/llvm-project/commit/f7f86451ecd78e0b48be905da7f9ae5f7f92647e
DIFF: https://github.com/llvm/llvm-project/commit/f7f86451ecd78e0b48be905da7f9ae5f7f92647e.diff

LOG: [libc++] Improve the format ignorelist generation.

Several improvements
- Only add files that we actually want to format.
- Sort according to a fixed locale.

Some drive-by fixes
- Rename a text file, this avoids a filter exception.
- Adds a some missing source files extensions.
- Removes unused extensions hh, hxx, cc, and cxx from clang-format.

Reviewed By: philnik, #libc

Differential Revision: https://reviews.llvm.org/D144126

Added: 
    libcxx/src/support/solaris/README.txt

Modified: 
    libcxx/utils/ci/run-buildbot
    libcxx/utils/data/ignore_format.txt
    libcxx/utils/generate_ignore_format.sh

Removed: 
    libcxx/src/support/solaris/README


################################################################################
diff  --git a/libcxx/src/support/solaris/README b/libcxx/src/support/solaris/README.txt
similarity index 100%
rename from libcxx/src/support/solaris/README
rename to libcxx/src/support/solaris/README.txt

diff  --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 0b79798db6553..d7292ce4c6be2 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -187,7 +187,7 @@ check-format)
     fi
     ${GIT_CLANG_FORMAT} \
         --
diff  \
-        --extensions ',h,hh,hpp,hxx,c,cc,cxx,cpp' HEAD~1 \
+        --extensions ',h,hpp,c,cpp,inc,ipp' HEAD~1 \
         -- $(find libcxx/{benchmarks,include,src}/ -type f | grep -vf libcxx/utils/data/ignore_format.txt) \
         | tee ${BUILD_DIR}/clang-format.patch
     # Check if the 
diff  is empty, fail otherwise.

diff  --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt
index 49c2d4b8bd0d6..a3da9d5681737 100644
--- a/libcxx/utils/data/ignore_format.txt
+++ b/libcxx/utils/data/ignore_format.txt
@@ -1,4 +1,3 @@
-libcxx/benchmarks/CMakeLists.txt
 libcxx/benchmarks/CartesianBenchmarks.h
 libcxx/benchmarks/ContainerBenchmarks.h
 libcxx/benchmarks/GenerateInput.h
@@ -29,8 +28,6 @@ libcxx/benchmarks/formatter_int.bench.cpp
 libcxx/benchmarks/format_to.bench.cpp
 libcxx/benchmarks/format_to_n.bench.cpp
 libcxx/benchmarks/function.bench.cpp
-libcxx/benchmarks/lit.cfg.py
-libcxx/benchmarks/lit.site.cfg.py.in
 libcxx/benchmarks/map.bench.cpp
 libcxx/benchmarks/ordered_set.bench.cpp
 libcxx/benchmarks/random.bench.cpp
@@ -38,7 +35,6 @@ libcxx/benchmarks/string.bench.cpp
 libcxx/benchmarks/stringstream.bench.cpp
 libcxx/benchmarks/unordered_set_operations.bench.cpp
 libcxx/benchmarks/vector_operations.bench.cpp
-libcxx/include/CMakeLists.txt
 libcxx/include/__algorithm/binary_search.h
 libcxx/include/__algorithm/clamp.h
 libcxx/include/__algorithm/comp.h
@@ -312,7 +308,6 @@ libcxx/include/__concepts/swappable.h
 libcxx/include/__concepts/totally_ordered.h
 libcxx/include/condition_variable
 libcxx/include/__config
-libcxx/include/__config_site.in
 libcxx/include/__coroutine/coroutine_handle.h
 libcxx/include/__coroutine/coroutine_traits.h
 libcxx/include/__coroutine/noop_coroutine_handle.h
@@ -470,7 +465,6 @@ libcxx/include/__iterator/sortable.h
 libcxx/include/__iterator/unreachable_sentinel.h
 libcxx/include/__iterator/wrap_iter.h
 libcxx/include/latch
-libcxx/include/libcxx.imp
 libcxx/include/limits
 libcxx/include/limits.h
 libcxx/include/list
@@ -506,7 +500,6 @@ libcxx/include/__memory/temp_value.h
 libcxx/include/__memory/uninitialized_algorithms.h
 libcxx/include/__memory/unique_ptr.h
 libcxx/include/__memory/uses_allocator.h
-libcxx/include/module.modulemap.in
 libcxx/include/mutex
 libcxx/include/__mutex_base
 libcxx/include/new
@@ -789,7 +782,6 @@ libcxx/include/vector
 libcxx/include/__verbose_abort
 libcxx/include/wchar.h
 libcxx/include/wctype.h
-libcxx/src/CMakeLists.txt
 libcxx/src/any.cpp
 libcxx/src/atomic.cpp
 libcxx/src/barrier.cpp

diff  --git a/libcxx/utils/generate_ignore_format.sh b/libcxx/utils/generate_ignore_format.sh
index 7df8245df64a7..c07b76d8966e2 100755
--- a/libcxx/utils/generate_ignore_format.sh
+++ b/libcxx/utils/generate_ignore_format.sh
@@ -7,11 +7,22 @@ if [ -z "${CLANG_FORMAT}" ]; then
 fi
 
 rm libcxx/utils/data/ignore_format.txt
-for file in $(find libcxx/{benchmarks,include,src}/ -type f); do
+# This uses the same matches as the check-format CI step.
+#
+# Since it's hard to match empty extensions the following
+# method is used, remove all files with an extension, then
+# add the list of extensions that should be formatted.
+for file in $(find libcxx/{benchmarks,include,src}/ -type f -not -name '*.*' -or \( \
+	 -name "*.h" -or -name "*.hpp" -or \
+	 -name "*.c" -or -name "*.cpp" -or \
+	 -name "*.inc" -or -name "*.ipp" \
+	 \) ); do
+
   ${CLANG_FORMAT} --Werror --dry-run ${file} >& /dev/null
   if [ $? != 0 ]; then
     echo ${file} >> libcxx/utils/data/ignore_format.txt
   fi
 done
 
-sort libcxx/utils/data/ignore_format.txt -d -o libcxx/utils/data/ignore_format.txt
+# Force sorting not to depend on the system's locale.
+LC_ALL=C sort libcxx/utils/data/ignore_format.txt -d -o libcxx/utils/data/ignore_format.txt


        


More information about the libcxx-commits mailing list