This is an archive of the discontinued LLVM Phabricator instance.

clang-format: Teach --sort-includes that #include and #import mean the same thing.
ClosedPublic

Authored by thakis on Oct 18 2015, 7:01 PM.

Details

Reviewers
djasper
Summary

clang accepts both #include and #import for includes (the latter having an implicit header guard). Let clang-format interleave both types if --sort-includes is passed. #import is used frequently in Objective-C code.

Diff Detail

Event Timeline

thakis updated this revision to Diff 37714.Oct 18 2015, 7:01 PM
thakis retitled this revision from to clang-format: Treat --sort-includes that #include and #import mean the same thing..
thakis updated this object.
thakis added a reviewer: djasper.
thakis added a subscriber: cfe-commits.
thakis added inline comments.Oct 18 2015, 7:02 PM
lib/Format/Format.cpp
1735

llvm's Regex class doesn't support non-capturing groups ((?:foo|bar)) as far as I can tell, so I changed Matches[1] to Matches[2] below.

thakis retitled this revision from clang-format: Treat --sort-includes that #include and #import mean the same thing. to clang-format: Teach --sort-includes that #include and #import mean the same thing..Oct 19 2015, 9:02 AM

djasper: Ping :-)

djasper accepted this revision.Oct 21 2015, 9:50 AM
djasper edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Oct 21 2015, 9:50 AM
thakis closed this revision.Oct 21 2015, 10:15 AM

r250909, thanks!