|
From: Eyal S. <eya...@gm...> - 2023-04-18 03:41:47
|
The problem with doing this is that it really messes with the git blame, introducing a lot of changes! If you do this, you should probably add some sort of formatting check to a CI process somewhere, otherwise your work will get stale and you'll just be doing the clang-format again in a year from now. Good luck to you trying to get everyone to agree on a format! Ha! Eyal On Mon, Apr 17, 2023 at 9:31 PM Nicholas Nethercote <n.n...@gm...> wrote: > Is there any appetite for clang-formatting Valgrind's code? I've now used > auto-formatters in C++, Rust, and Python, and found it an excellent > experience, and I get annoyed when working on code without auto-formatting. > The C++ case was Firefox, where a large and old codebase was formatted. So > it is possible (and better, IMO) to not just limit it to new code. > > It could certainly be done in pieces, e.g. one directory at a time, > something like that. > > Nick > > On Tue, 18 Apr 2023 at 06:07, Paul Floyd <pa...@so...> wrote: > >> >> https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=1b3430761f6bda43b8187dbd342b34cb5c99df3f >> >> commit 1b3430761f6bda43b8187dbd342b34cb5c99df3f >> Author: Paul Floyd <pj...@wa...> >> Date: Mon Apr 17 22:05:30 2023 +0200 >> >> Bug 468401 - [PATCH] Add a style file for clang-format >> >> Patch submitted by: >> Petr Pavlu <pet...@da...> >> >> Diff: >> --- >> .clang-format | 17 +++++++++++++++++ >> .gitignore | 1 + >> NEWS | 1 + >> README_DEVELOPERS | 18 ++++++++++++++++++ >> 4 files changed, 37 insertions(+) >> >> diff --git a/.clang-format b/.clang-format >> new file mode 100644 >> index 0000000000..4450e737ac >> --- /dev/null >> +++ b/.clang-format >> @@ -0,0 +1,17 @@ >> +--- >> +Language: Cpp >> +BasedOnStyle: LLVM >> + >> +AlignConsecutiveAssignments: true >> +AlignConsecutiveDeclarations: true >> +AlignConsecutiveMacros: true >> +AllowAllParametersOfDeclarationOnNextLine: true >> +BinPackParameters: false >> +BreakBeforeBraces: Linux >> +ContinuationIndentWidth: 3 >> +IndentWidth: 3 >> +PointerAlignment: Left >> +# Mark the VG_(), ML_() and tool macros as type declarations which they >> are >> +# sufficiently close to, otherwise clang-format gets confused by them. >> +TypenameMacros: [VG_, ML_, CLG_, DRD_, HG_, MC_] >> +... >> diff --git a/.gitignore b/.gitignore >> index a88ab4dd43..6622e7c59e 100644 >> --- a/.gitignore >> +++ b/.gitignore >> @@ -3,6 +3,7 @@ >> # / >> /.in_place >> /.vs >> +/.clang-format >> /acinclude.m4 >> /aclocal.m4 >> /autom4te-*.cache >> diff --git a/NEWS b/NEWS >> index 43ff9766bd..696720e97e 100644 >> --- a/NEWS >> +++ b/NEWS >> @@ -152,6 +152,7 @@ are not entered into bugzilla tend to get forgotten >> about or ignored. >> 467714 fdleak_* and rlimit tests fail when parent process has more than >> 64 descriptors opened >> 467839 Gdbserver: Improve compatibility of library directory name >> +468401 [PATCH] Add a style file for clang-format >> 468556 Build failure for vgdb >> n-i-bz FreeBSD rfork syscall fail with EINVAL or ENOSYS rather than >> VG_(unimplemented) >> >> diff --git a/README_DEVELOPERS b/README_DEVELOPERS >> index 9c04763d47..979ee13b4a 100644 >> --- a/README_DEVELOPERS >> +++ b/README_DEVELOPERS >> @@ -372,3 +372,21 @@ translated, and that includes the address. >> Then re-run with 999999 changed to the highest bb number shown. >> This will print the one line per block, and also will print a >> disassembly of the block in which the fault occurred. >> + >> + >> +Formatting the code with clang-format >> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> +clang-format is a tool to format C/C++/... code. The root directory of >> the >> +Valgrind tree contains file .clang-format which is a configuration for >> this tool >> +and specifies a style for Valgrind. This gives you an option to use >> +clang-format to easily format Valgrind code which you are modifying. >> + >> +The Valgrind codebase is not globally formatted with clang-format. It >> means >> +that you should not use the tool to format a complete file after making >> changes >> +in it because that would lead to creating unrelated modifications. >> + >> +The right approach is to format only updated or new code. By using an >> +integration with a text editor, it is possible to reformat arbitrary >> blocks >> +of code with a single keystroke. Refer to the upstream documentation >> which >> +describes integration with various editors and IDEs: >> +https://clang.llvm.org/docs/ClangFormat.html. >> >> >> _______________________________________________ >> Valgrind-developers mailing list >> Val...@li... >> https://lists.sourceforge.net/lists/listinfo/valgrind-developers >> > _______________________________________________ > Valgrind-developers mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-developers > |