id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking	branch_state	votes
4592	Migrate formatter from indent to clang-format	zaytsev	zaytsev	"Currently, we use GNU Indent as our formatter. Unfortunately, it has several problems that make it almost unusable:

1. It requires tons of `/* *INDENT-OFF* */` directives to avoid breaking complex formatting.
2. It randomly adds `/*` at the beginning and `NUL` at the end of source files.
3. It fails to parse complex source files (see #4524):

{{{
indent: lib/util.c:522: Error:Stmt nesting error.
...
}}}

As I started trying to fix these errors, it turned out that half of our source tree is unformatted, because the formatting loop breaks on a non-zero exit code, and all files after that are simply not processed.

This makes it impossible to add formatting checks to the CI and automatically maintain proper formatting.

I have investigated possible formatting options, and the only viable candidate in my opinion is `clang-format`:

1. It uses the `clang` compiler frontend for parsing, so it is able to process any valid code.
2. It is also actively developed and mostly stable.
3. It comes with a preset for GNU style.

As with any formatter change, it is not possible to make the style match 100%, and there will be one big diff, but hopefully life will get better after that."	enhancement	closed	major	4.8.34	compilation	master	fixed					merged	committed-master
