Propose to use clang-format to enforce hotspot codestyle
John Rose
john.r.rose at oracle.com
Fri Mar 13 08:42:12 UTC 2020
On Mar 13, 2020, at 1:30 AM, Liu, Xin <xxinliu at amazon.com> wrote:
>
> First of all, I have to admit that using a huge patch to correct all inconsistencies is a bad idea. I take it back. It would devastate annotation information which is more important than styles.
> Thanks John to share his rationale and a bit history behind the blog. I really fell the trap you left. The reason Jesper criticized my very long code comes from “There is no hard line length limit” in the wiki. I thought it means unlimited. Now we know it’s deliberately ambiguous and developers are at their discretion. It’s also very hard to determine AlignConsecutiveAlignments.
>
> I will step back and try to use a .clang-format to format my new code locally. I got it. It’s a distributed effort to maintain hotspot codestyle instead of authoritarian rules. I really appreciate the inputs, which are very valuable for me.
>
> Finally, I would like share my discover about clang-format as a trick. I think you can deploy clang-format in emacs as well.
> I was told to maintain include headers in alphabetical order. It’s mechanical. I found it’s pretty handy to get it done by IncludeCategories.
> https://cr.openjdk.java.net/~xliu/8240834/webrev/src/hotspot/.clang-format.html
Thank you, Liu! You probably noticed that I admitted it could possibly
be helpful to have some sort of automatic detection of style variations,
perhaps as reports on the source code base as a whole (kind of like
coverage data, but less useful?). Or, more likely, automatic flagging
of style variations during the review of a pull request; we have a place
for robots like this, but they only do the most basic style checks,
and those are mandatory. (Yes we have a tiny number of mandatory
format rules, under jcheck.) But flagging a richer set of style variations,
when there is a chance to fix it, might help reviewers. Or maybe not;
the overall problem with such robots is they interrupt the humans
when they are trying to talk. But I would welcome something that
would occasionally flag a questionable indentation or identifier spelling,
as long as it avoided false positives, and as long is it didn’t prevent
the humans from deciding whether the rule should be broken or not.
— John
More information about the hotspot-dev
mailing list