]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 468401 - [PATCH] Add a style file for clang-format
authorPaul Floyd <pjfloyd@wanadoo.fr>
Mon, 17 Apr 2023 20:05:30 +0000 (22:05 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Mon, 17 Apr 2023 20:05:30 +0000 (22:05 +0200)
Patch submitted by:
Petr Pavlu <petr.pavlu@dagobah.cz>

.clang-format [new file with mode: 0644]
.gitignore
NEWS
README_DEVELOPERS

diff --git a/.clang-format b/.clang-format
new file mode 100644 (file)
index 0000000..4450e73
--- /dev/null
@@ -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_]
+...
index a88ab4dd43b5f9c60fb954721e2d352a0e254db7..6622e7c59e75e2e9479dc798bd11d924d2b4c2d9 100644 (file)
@@ -3,6 +3,7 @@
 # /
 /.in_place
 /.vs
+/.clang-format
 /acinclude.m4
 /aclocal.m4
 /autom4te-*.cache
diff --git a/NEWS b/NEWS
index 43ff9766bdc15be19aff40e18a9d2cef4363a9b1..696720e97e16131ee1ebdd699b808285e8385376 100644 (file)
--- 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)
 
index 9c04763d476670801de17b5cbc8d631df988baed..979ee13b4a3fbb06be663c20e097811bb45e07f8 100644 (file)
@@ -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.