I’m in the process of finalizing haiku-format 17.0.1 which is based on the same version of clang-format. Before I can do that, a few haiku-format 10.0.1 issues not mentioned in the Haiku coding guidelines should be decided on by the Haiku developers:
Another issue is about inserting/removing braces. My impression is that Haiku’s is closely aligned with LLVM’s and can take advantage of the InsertBraces and RemoveBracesLLVM options, with only minor customizations to the latter.
The two changes proposed by nielx were not discussed with other members of the team.
I think the BeforeCatch one makes sense.
However, I think removing the space in range-based for loops is strange, because we always have space after the other control structure keywords (if, while, non-range for, …). What is the reasonig for introducing a special case here?
As for IntegerLiteralSeparator: using it would break gcc2, so I think it should not be enabled.
Finally for the space between new and std::nothrow: that is indeed not in the current guidelines, but is what’s mostly used in Haiku (2596 instances). The version with space is used 300 times, so, some people do like it. There is also a further variant now that I look at the result:
new (std::nothrow) type();
and also sometimes the final parentheses are omitted when the constructor doesn’t need parameters.
Personally I’m fine with either the first or second, but for haiku-format I think we have to make a choice. Any opinions either way? I can add it to the coding guidelines once there is an agreement.
I was really just trying to confirm whether Haiku wanted to convert all line endings to \n or to leave them alone. This is no more obvious to me than whether to insert the missing \n before EOF, which is mentioned in the guidelines.
I think there is a distinction between multiple statements (simple or compound) and a multiline statement. Inserting/removing braces only applies to a single statement (either simple or compound), whether this single statement is split into multiple lines.
For example, braces should be inserted for the if (but not the while) statement below even though the inserted braces would only enclose a single line:
Thanks for updating haiku-format. I have used it previously on my libnetservices2 (and I don’t think anyone had any comments on the style, so that’s good ;-))
I wonder for longer term how many patches for individual style choices we can upstream, as well as if it is worth trying to submit the Haiku style as a default style.
And for the other way around: if there are particular parts of the Haiku style that are too controversial for the maintainers of clang-format, or if we think they might be a bit exotic, what are the chances that we are willing to change our coding style?
I think it would be interesting to start using the tool as part of our automated checks when patches get uploaded to Gerrit. It would save a lot of comments about formatting, and automate checking a decent part of our style guide.