RFR: 8352645: Add tool support to check order of includes
Doug Simon
dnsimon at openjdk.org
Tue Mar 25 12:13:03 UTC 2025
On Tue, 25 Mar 2025 09:16:15 GMT, Doug Simon <dnsimon at 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/cpu/aarch64/immediate_aarch64.cpp line 26:
>
>> 24: */
>> 25:
>> 26: #include <stdlib.h>
>
> Moving these sys includes causes a build failure: https://github.com/dougxc/jdk/actions/runs/14054959680/job/39352322113#step:12:537
>
> In file included from /home/runner/work/jdk/jdk/src/hotspot/cpu/aarch64/immediate_aarch64.cpp:26:
> /home/runner/work/jdk/jdk/src/hotspot/cpu/aarch64/immediate_aarch64.hpp:49:1: error: ‘uint64_t’ does not name a type; did you mean ‘u_int64_t’?
> 49 | uint64_t logical_immediate_for_encoding(uint32_t encoding);
> | ^~~~~~~~
> | u_int64_t
>
> The question is whether they should not be re-ordered or whether `immediate_aarch64.hpp` should add the sys includes it apparently needs.
I pushed a commit that prevents the re-ordering: https://github.com/openjdk/jdk/pull/24180/commits/c0f202d2a7e7b8788719fe8cd2a4c7a095ecd3bb
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24180#discussion_r2011951143
More information about the build-dev
mailing list