-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial .clang-format style and reformat the sources using it #15
Conversation
If there's something that does specifically bothers you, I can take a look if that's configurable: https://releases.llvm.org/14.0.0/tools/clang/docs/ClangFormatStyleOptions.html But I prefer the style to stay consistent across all committers over matching every bit of my preferred style. There's one nit though - I think that even the single line statements should be surrounded by braces - as a defensive programming, I find these:
extremely hard to parse. |
Overall I do not mind formatters, but sometimes they make so me silly choices.
I think adding braces here is just fine, I do not mind. In fact I prefer braces even for sinle line if constructs, I just got a bit lazy in this case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not too bad, but let's see if it can be improved (I know subjective, but style often is).
do you mind if I experiment and rebase your branch ? |
I'll also just one shot the single line braces. I thought that clang-format does have support for it already but seems it does not, but I can do that with clang-tidy, but it's not that easy to wire it in, so it's more one-time only. |
I'll probably continue review after the weekend, I think we can get close enough. |
I absolutely don't mind, go ahead. I absolutely also mind a little about the exact style, although going full K&R would be a little hard ;). Once we nail this, there's also a GitHub Action for clang-format or we can write one. |
f7a10d6
to
adbd349
Compare
Not super-happy about how it monkeys with macros, and the whole bizarre things it does with struct initializers with arrays, unless I manually add a comma after the last initializer. However this comes close enough ... |
539bbce
to
b693ad4
Compare
Ok, this looks reasonably ok. The Makefile part is not stellar but gets the job done. What do you think? |
Obviously it shows a failure because of the commit where I fixed some clang-format "mistakes". |
There's a command you can put in the comment to enable/disable formatting of the part of the code. My experience is that it's simply easier to accept that the tool is not perfect and just let it go... |
Without the commas clang-format messes up struct initializers with odd indentations. Unfortunately we can't solve this by adding InsertTrailingCommas, because it cnflicts with bin-packing. Also fixup some comments as we are going to tell it to leave them alone, but it will still reformat indentation of the opnening /* Signed-off-by: Simo Sorce <[email protected]>
Signed-off-by: Ondřej Surý <[email protected]> Signed-off-by: Simo Sorce <[email protected]>
Signed-off-by: Simo Sorce <[email protected]>
Fixes latchset#14 Signed-off-by: Simo Sorce <[email protected]>
Ok, I guess those macros can live as is ... |
This is an initial example of how .clang-format can be configured. It doesn't precisely match the current style, but no tool can do that.