This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Add option to group multiple #include blocks when sorting includes
ClosedPublic

Authored by KrzysztofKapusta on Nov 21 2017, 1:42 AM.

Details

Summary

This patch allows grouping multiple #include blocks together and sort all includes as one big block.
Additionally, sorted includes can be regrouped after sorting based on configured categories.

Diff Detail

Event Timeline

KrzysztofKapusta removed rCTE Clang Tools Extra as the repository for this revision.Nov 21 2017, 6:55 AM
KrzysztofKapusta removed a reviewer: Restricted Project.Nov 21 2017, 7:02 AM
KrzysztofKapusta removed a project: Restricted Project.
KrzysztofKapusta set the repository for this revision to rL LLVM.
djasper edited reviewers, added: krasimir; removed: djasper.Nov 21 2017, 7:21 AM
krasimir edited edge metadata.Nov 22 2017, 2:47 AM

Looks good! Just a few nits:

lib/Format/Format.cpp
1570

Please replace this with two explicit checks for the expected styles. Plus, an else if with an empty body is super awkward.

unittests/Format/SortIncludesTest.cpp
357

What is this testing?

Addressed all comments. Changed one testcase to better reflect the desired effect.

unittests/Format/SortIncludesTest.cpp
357

I changed this to better reflect what I was trying to test. Now the expected order is not sorted from a..c

krasimir accepted this revision.Nov 24 2017, 6:48 AM
krasimir removed a reviewer: krasimir.

Thank you! Do you have commit access?

This revision is now accepted and ready to land.Nov 24 2017, 6:48 AM

@krasimir thanks for the review! I don't have commit rights. Would you push this for me?

This revision was automatically updated to reflect the committed changes.