Bug 468401 - [PATCH] Add a style file for clang-format

Patch submitted by:
	Petr Pavlu <petr.pavlu@dagobah.cz>
This commit is contained in:
Paul Floyd
2023-04-17 22:05:30 +02:00
parent 41a7f59a88
commit 1b3430761f
4 changed files with 37 additions and 0 deletions

17
.clang-format Normal file
View File

@@ -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_]
...

1
.gitignore vendored
View File

@@ -3,6 +3,7 @@
# /
/.in_place
/.vs
/.clang-format
/acinclude.m4
/aclocal.m4
/autom4te-*.cache

1
NEWS
View File

@@ -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)

View 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.