Solving the clang-format conundrum
Summary
The formatting tool we use to ensure unified coding style, clang-format
, does not produce consistent formatting across its major versions, even with the same style settings. This means, developers running a different version run into failed pipelines where the formatting check failed and need to manually rework that part of the code.
Possible solutions
According to a thread on the LLVM mailing list there is no real solution to this, as clang-format
cannot be forced to produce a consistent formatting with different versions.
Here is a list of possible roads forward:
- Ship the clang-format version to be used in the repository itself (
3rdparty
) and invoke it from there. - Use CMake to ensure we are always using the same version (via
${CLANG_MAJOR_VERSION} EQUAL "4"
). This would need to be adapted for the git pre-commit hook. - Fence off the changes manually in the code using
//clang-format off
tags. This is what's being done at a few places already.
Additional ideas, opinions, preferences?
@kwolters @pschutze