* Add <winternl.h> to the list of must-be-early Windows headers.
* Add "windows_h_disallowed.h" as "must be last".
* Minor comment/regex typo fixes.
* Alphabetize .clang-format list (cosmetic change; that was already the
actual behavior).
* Alphabetize add_header.py change (behavior change; this order is
the sort key). This matches the .clang-format behavior so they
don't fight each other.
Bug: 364987728
Change-Id: Ic8560ab1cf476918c8dd9454dc7ef5ccb5aecd8f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5913362
Reviewed-by: Nico Weber <thakis@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1365712}
The rules for include-file ordering requirements that this script
encapsulates (enforces?) were obtained from data from the legacy
sort-headers.py script [1] and grepping for comments in C++ source files
that mention "must be before" or "must be after".
[1] 142d14ca7b/tools/sort-headers.py
Change-Id: Ib68f0ce3c15fdc7497caf02c654f7ae1bee87593
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3491258
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#975411}
This CL fixes a corner case which isn't handled correctly by
add_header.py. When there are two includes with the same file
name but in different paths, the current script may choose
the wrong one as the primary header since it passed all the
fuzzy testing.
To fix it, we add a first pass to do exact matching. Since
exact matching would work for most of the times, this change
should also improve the performance of this script.
Bug: 1234043
Change-Id: I7036fd703c77159e7303cda71777bce97f0e4d4a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3405134
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Xiaohan Wang <xhwang@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Cr-Commit-Position: refs/heads/main@{#961684}
In addition to add a header, also support removing a header in
add_header.py. Since a lot of operations are the same, this is better
than adding a new file doing the remove.
Bug: 3311983
Change-Id: Ia358780d82ceb069bb91c2a898d3966bd8a361d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3318619
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#949172}
This is useful for IWYU fixes. Unfortunately, clang-format is not quite
sufficient here: clang-format does not reorder between blocks of
includes that are bracketed by newlines, so any helper script still
needs to find the approximately correct insertion point first.
Since this script actually predates clang-format's header sorting
functionality, it goes a bit further and also reorders includes between
blocks, including heuristics for matching a 'related header' in a .cc
file. It does /not/ currently include any heuristics for header ordering
requirements for system headers, e.g. Windows headers, though that
wouldn't be hard to add simply be extending the sort key.
As cleanup, remove sort-headers.py in favor of using clang-format
directly.
Change-Id: I204e4a98c96591b86986dffe133017bec23a9a5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3133743
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#917459}