Closed Others closed 7 years ago
Limitations:
Broken things:
;
s in for loopsfree = lower = m->id_boundary;
format strangely (although, again, consistently)One more thing it breaks: assembly strings in macros. Perhaps we can manually surround these with /* clang-format off */
assembly bs /* clang-format */
You should also add documentation for this. Likely:
I'm sorry this is a pain, but there isn't much reason to do all of this if we don't integrate it into the process to some degree. I agree that the build system can be later, but some documentation is required.
Also, add an issue to update the style guide with the style as determined by llvm. I can do that later.
Possible changes:
BinPackParameters: true Cpp11BracedListStyle: true MaxEmptyLinesToKeep: 1 SpacesInSquareBrackets:false
Last comment: format
should be format.sh
and should likely be in tools/
@gparmer: Okay, pushed some changes, but still have a few remaining comments:
MaxEmptyLinesToKeep
at 2, so you can have two spaces between functions (which is current style I think)./format
, I think the .sh
postfix is against bash convention in this casetools
for now as well, since I want to save that sort of change until we do the build system integration
Of course all three of these notes are negotiable. I'd like to get this merged now, but I'm happy to change more things :)@Others
./tools/format.sh
Did you remove ck
from the formatting? Doesn't look like it; not sure?
Did you add the comments to avoid formatting around assembly definitions? Looks like no? At least add documentation to the autoformatter file for how to do this, and note that it might be required around defines that include assembly.
@gparmer I fixed the assembly by excluding them in the script. Is that fine or do you want them specifically excluded with comment pragmas?
I'll fix the rest of your notes ASAP
Are we talking about the same thing. You obviously didn't apply this to assembly files.
But you did apply it to C files that have #defines
that include and generate assembly. And for the assembly contents of those defines, the indentation gets messed up. I noted this in my original comments.
@gparmer yes I know. I specifically excluded the .h
files that had the assembly in question. But this is probably the wrong thing to do now that I think about it. I'll switch to using comment pragmas instead.
(Also ck was never formatted as far as I can tell by diffing against upstream/ppos.)
This is brilliant! Thanks @Others for automating this important aspect of our development. Very very much appreciated.
Summary of this Pull Request (PR)
This commit adds an auto formatter script to composite
format
in the root directory. It is based on clang format, and uses the rules in the.clang-format
file. This might need a little bikeshedding to get right, and perhaps even some style guide changes. However I think it will be super valuable to get this merged, so we can start automatically formatting our composite code.For the purposes of reviewing this, looking at
.clang-format
andformat
are absolutely key. And it might be a good idea to scan through some code to see if anything looks weird/not stylistically correct.Intent for your PR
Choose one (Mandatory):
Reviewers (Mandatory):
(Specify @<github.com username(s)> of the reviewers. Ex: @user1, @user2) @gparmer
Code Quality
As part of this pull request, I've considered the following:
Style:
Code Craftsmanship:
Testing
N/A. I just ran the current runscripts to verify everything still is semantically correct.