[PATCH] D111000: [clang-format] allow clang-format to be passed a file of filenames so we can add a regression suite of "clean clang-formatted files" from LLVM

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 2 11:13:43 PDT 2021


MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: HazardyKnusperkeks, curdeius, krasimir.
MyDeveloperDay added projects: clang, clang-format.
Herald added subscribers: phosek, s.egerton, mstorsjo, cryptoad, simoncook, fedor.sergeev, dschuff.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a reviewer: sscalpone.
MyDeveloperDay requested review of this revision.
Herald added subscribers: sstefan1, aheejin.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a reviewer: baziotis.

When I make a change to clang-format I really want to run it over a large regression suite to ensure it doesn't cause any unexpected changes.

Building on the python script that creates the current status of all of LLVM, (see https://clang.llvm.org/docs/ClangFormattedStatus.html)
I now generate a list of "formatted files from LLVM" all 7900+ of them

This change now generates that list, and the change to clang-format allows us to run clang-format quickly over these files via the list of files.

/clang-format.exe -verbose -n --files=./clang/docs/tools/clang-formatted-files.txt

  Clang-formating 7926 files
  Formatting [1/7925] clang/bindings/python/tests/cindex/INPUTS/header1.h
  Formatting [2/7925] clang/bindings/python/tests/cindex/INPUTS/header2.h
  Formatting [3/7925] clang/bindings/python/tests/cindex/INPUTS/header3.h
  ....
  Formatting [7923/7925] pstl/include/pstl/internal/parallel_backend_utils.h
  Formatting [7924/7925] utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
  Formatting [7925/7925] utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h

This is needed because putting all those files on the command line is too long, and invoking 7900+ clang-formats is much slower (too slow to be honest)

Using this method it takes on 7.5 minutes (on my machine) to run `clang-format -n` over all of the files (7925), this should result in us testing any change quickly and easily.

We should be able to use rerunning this list to ensure that we don't regress clang-format over a large code base, but also use it to ensure none of the previous files which were 100% clang-formatted remain so. (which the LLVM premerge checks should be enforcing)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111000

Files:
  clang/docs/tools/clang-formatted-files.txt
  clang/docs/tools/generate_formatted_state.py
  clang/tools/clang-format/ClangFormat.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111000.376713.patch
Type: text/x-patch
Size: 380002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211002/a4f6b73c/attachment-0001.bin>


More information about the cfe-commits mailing list