0
Commit Graph

6 Commits

Author SHA1 Message Date
Peter Kasting
b9d8d6aeee Tweak Windows header-sorting in .clang-format and add_header.py.
* 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}
2024-10-08 18:33:10 +00:00
Avi Drissman
dfd8808526 Update copyright headers in testing/, tools/
The methodology used to generate this CL is documented in
https://crbug.com/1098010#c95.

No-Try: true
No-Presubmit: true
Bug: 1098010
Change-Id: I3a8a7b150e7bd64690534727150646081df50439
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3900697
Reviewed-by: Mark Mentovai <mark@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1047644}
2022-09-15 20:11:09 +00:00
Daniel Cheng
f1f311f585 Account for platform header idiosyncrasies in add_header.py.
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}
2022-02-26 04:09:22 +00:00
Xiaohan Wang
3b5e94fb29 tools: Fix primary header marking in add_header.py
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}
2022-01-21 00:05:31 +00:00
Xiaohan Wang
6080a06be9 tools: Support removing header in add_header.py
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}
2021-12-07 21:34:34 +00:00
Daniel Cheng
11c06e0e26 Add a helper script to insert new includes.
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}
2021-09-01 23:51:29 +00:00