DescriptionLet clang-format sort includes.
After this, `git cl format` will reorder includes in blocks of #includes
that are not separated by newlines.
This works in almost all cases, but it can break some code e.g.
#include <windows.h>
#include <shellapi.h>
clang-format will reorder these now, but shellapi.h only compiles if
windows.h was included first. Relying on this is brittle, so replace
code like this with
#include <windows.h>
// Must be after windows.h:
#include <shellapi.h>
Since clang-format doesn't reorder across blocks, this will do the right
thing.
This also means you're still on the hook of putting blocks with user headers,
C++ headers, and C headers in the right order.
This will hopefully replace src/tools/sort-headers.py which contains
some hacky heuristics -- but just inserting newlines between includes
when needed (with a comment) seems like a better tradeoff anyhow.
And the automatic integration with `git cl format` is nice.
(clang-format has IncludeIsMainRegex and IncludeCategories for adding
heuristics, but we shouldn't use these, they're too complicated.)
BUG=688155
TBR=brettw
Review-Url: https://codereview.chromium.org/2669263003
Cr-Commit-Position: refs/heads/master@{#447875}
Committed: https://chromium.googlesource.com/chromium/src/+/6b08b5d1106a7faa33f2dbb8c07ac9ba67058e16
Patch Set 1 #
Messages
Total messages: 16 (11 generated)
|