From 1b3430761f6bda43b8187dbd342b34cb5c99df3f Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Mon, 17 Apr 2023 22:05:30 +0200 Subject: [PATCH] Bug 468401 - [PATCH] Add a style file for clang-format Patch submitted by: Petr Pavlu --- .clang-format | 17 +++++++++++++++++ .gitignore | 1 + NEWS | 1 + README_DEVELOPERS | 18 ++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 .clang-format 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. -- 2.47.2