-
Notifications
You must be signed in to change notification settings - Fork 901
clang-format: tweaks #8655
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
clang-format: tweaks #8655
Conversation
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.
All looks good. I actually like the operator to start the new lines, I agree it improves the readability. The breaking between the function name and the list of argument I think it's just weird, and we should try avoid if possible.
@hjelmn Can you please document how to run clang format and the new clang-tidy tools in the ompi-wiki? I see some instructions here: #8551, but since then there's been mention of this other clang-tidy tool. |
@gpaulsen Sure. I intend to upload a script and set of configuration files for clang-tidy shortly. clang-tidy has some bugs with some of the checkers (duplicate branch detection screws up the code) so I am testing them out one-by-one now. Adding single-statement conditional braces works well. |
I did find more errors in OMPI BTW. I plan to patch those in the clang-format ompi branch. |
Once you settle on a final |
85b9b75
to
4d6bf07
Compare
I think I resolved the remaining formatting issues (to the degree possible). Made one additional tweak. clang-format was putting all the arguments to a function/macro on the next line if it couldn't fit them on the same line as the function or macro. This could lead to breaking before the first argument which is undesirable. |
What version of clang-format are you using? When I try this locally, I get:
|
When I was testing the GitHub Action with |
@jsquyres Which options? They might be ones we only use the defaults for. |
@awlauria Ok, I see. llvm 9 is a bit long in the tooth (~1.5 years old) now but that is still relatively fresh. I want at least v10 to work if possible. The homebrew version is v11.0.0. Let me see if I can get v9 and v10 installed to at least evaluate. |
Homebrew has v8 and v11. Let me look at what v8 has. I am actively working on getting patches in for the next version of clang-format (v13). If there is anything we want in particular let me know. |
The only one I recall offhand was "Align", where our value was "Align", and the only allowable options (IIRC) were true and false. After I ran into 2-3 cases like this, I realized that I must be doing it wrong, and checked the versions, noticed that I was running v10 and v11 was available, ... yadda yadda yadda. |
@hjelmn that's probably fine. We can figure out how to upgrade it on our systems with the decided version, I wouldn't spend too many cycles on that. Thanks. |
@awlauria, @jsquyres I can set
|
This commit makes the following changes: - Disallow single-line functions. This matches the dominant style used in Open MPI. - Increase the penalty for breaking on assigment slightly lower than breaking before first argument. That will ensure that long assignments of the form foo = bar(baz) will break after the = before trying to break after the open-paren. - Break before binary operators. This is a change in style that I will revert if there is any push back. This causes long statements to break before the binary operator not after it. This is the currently recommended practice. - Don't allow all arguments on the next line. This may cause a break after an open paren which is not desired. - Change AlignOperands to true (synonym for Align in v11+) to support clang-format v10. Signed-off-by: Nathan Hjelm <[email protected]>
4d6bf07
to
8c72920
Compare
Done. Should work with clang-format v10 now. |
@awlauria I would recommend the latest version you can install of either 10 or 11. That way we get the newest set of bug fixes. Once 13 is out I would like to switch to that but it will be awhile. |
@hjelmn thanks! I'll look into getting v11 installed on our machines. |
The IBM CI (PGI) build failed! Please review the log, linked below. Gist: https://gist.github.com/e546e2c4d86b82f7d1e43f5dd26f81c2 |
bot:ibm:pgi:retest |
The IBM CI (PGI) build failed! Please review the log, linked below. Gist: https://gist.github.com/aaefe9301fca2874253bacabd1f67f63 |
Lets not hit CI again for this :). It is hurting enough already. |
Yeah, seems the ibm ci is having a bad day. this ready to merge? |
This commit makes the following changes:
Disallow single-line functions. This matches the dominant style used
in Open MPI.
Increase the penalty for breaking on assigment slightly higher than
breaking before first argument. That will ensure that long assignments
of the form foo = bar(baz) will break after the = before trying to
break after the open-paren.
Break before binary operators. This is a change in style that I will
revert if there is any push back. This causes long statements to break
before the binary operator not after it. This is the currently
recommended practice.
Signed-off-by: Nathan Hjelm [email protected]