Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Issue 2669263003: Let clang-format sort includes. (Closed)

Created:
3 years, 10 months ago by Nico
Modified:
3 years, 10 months ago
Reviewers:
brettw, sky
CC:
chromium-reviews
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Let 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 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+4 lines, -0 lines) Patch
M .clang-format View 1 chunk +4 lines, -0 lines 0 comments Download

Messages

Total messages: 16 (11 generated)
Nico
See CL description for tradeoffs. If we land this (I think we should), I'll send ...
3 years, 10 months ago (2017-02-02 22:41:18 UTC) #5
sky
That was fast. LGTM!
3 years, 10 months ago (2017-02-02 22:43:40 UTC) #6
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2669263003/1
3 years, 10 months ago (2017-02-02 23:20:41 UTC) #10
Nico
tbr brettw for toplevel owners. I should probably make myself and dcheng per-file owners of ...
3 years, 10 months ago (2017-02-02 23:26:08 UTC) #13
commit-bot: I haz the power
3 years, 10 months ago (2017-02-02 23:35:13 UTC) #16
Message was sent while issue was closed.
Committed patchset #1 (id:1) as
https://chromium.googlesource.com/chromium/src/+/6b08b5d1106a7faa33f2dbb8c07a...

Powered by Google App Engine
This is Rietveld 408576698