On Tue, 25 Mar 2025 20:27:21 GMT, Stefan Karlsson <stef...@openjdk.org> wrote:

>> This PR adds `bin/sort_includes.py`, a python3 script to check that blocks 
>> of include statements in C++ files are sorted alphabetically and that 
>> there's at least one blank line between user and sys includes (as per the 
>> [style 
>> guide](https://github.com/openjdk/jdk/blob/master/doc/hotspot-style.md#source-files)).
>> This script can also update files with unsorted includes. The second commit 
>> in this PR shows the result of running:
>> 
>> python3 ./bin/sort_includes.py ./src/hotspot
>> 
>> To prevent an include being reordered, put at least one non-space character 
>> after the closing `"` or `>`. See `src/hotspot/share/adlc/archDesc.cpp` for 
>> an example.
>> 
>> Assuming this PR is integrated, jcheck could be updated to use it to ensure 
>> include statements remain sorted.
>
> src/hotspot/share/opto/output.cpp line 39:
> 
>> 37: #include "opto/block.hpp"
>> 38: #include "opto/c2_MacroAssembler.hpp"
>> 39: #include "opto/c2compiler.hpp"
> 
> Hmm.
> 
> #include "opto/c2_MacroAssembler.hpp"
> #include "opto/c2compiler.hpp"
> 
> Here _ comes before lower-case letters. From other places I see that _ comes 
> after upper-case letters. I realize that this is caused by the ASCII value, 
> but it is a bit unfortunate (IMHO). OTOH, maybe this will be consistent (the 
> way I would like it, at least) if the sorting was done on lower-cased strings.

I think it's simplest to follow ASCII sorting but don't have a strong opinion 
if others would prefer for strings to be lower-cased before sorting. The 
important thing is that the same order is used everywhere.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24180#discussion_r2013015247

Reply via email to