[PATCH] D46180: [clang-format] Refactor #include insertion/deletion functionality into a class.

Eric Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 27 01:50:03 PDT 2018


ioeric created this revision.
ioeric added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, klimek.

The class will be moved into libToolingCore as followup.

The new behaviors in this patch:

- New #include is inserted in the right position in a #include block to

preserver sorted #includes. This is best effort - only works when the
block is already sorted.

- When inserting multiple #includes to the end of a file which doesn't

end with a "\n" character, a "\n" will be prepended to each #include.
This is a special and rare case that was previously handled. This is now
relaxed to avoid complexity as it's rare in practice.


Repository:
  rC Clang

https://reviews.llvm.org/D46180

Files:
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46180.144296.patch
Type: text/x-patch
Size: 22776 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180427/84f1e1ea/attachment-0001.bin>


More information about the cfe-commits mailing list