This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] support header deletion in cleanupAroundReplacemnts.
ClosedPublic

Authored by ioeric on Sep 22 2016, 8:19 AM.

Details

Summary
  • If a replacement has offset UINT_MAX, length 0, and a replacement text that is an #include directive, this will insert the #include into the correct block in the \p Code.
  • If a replacement has offset UINT_MAX, length 1, and a replacement text that is the name of the header to be removed, the header will be removed from \p Code if it exists.

Diff Detail

Repository
rL LLVM

Event Timeline

ioeric updated this revision to Diff 72175.Sep 22 2016, 8:19 AM
ioeric retitled this revision from to [clang-format] support header deletion in cleanupAroundReplacemnts..
ioeric updated this object.
ioeric added a reviewer: djasper.
ioeric added subscribers: klimek, cfe-commits.
djasper accepted this revision.Sep 23 2016, 5:22 AM
djasper edited edge metadata.

Looks good.

lib/Format/Format.cpp
1557 ↗(On Diff #72175)
return HeaderToDelete.find(HeaderName) != HeadersToDelete.end() ||
       HeaderToDelete.find(HeaderName.trim("\"<>")) != HeadersToDelete.end()
1623 ↗(On Diff #72175)

quotes.

1634 ↗(On Diff #72175)

Maybe:

unsigned Length = std::min(Line.size(), Code.size() - Offset - 1);
This revision is now accepted and ready to land.Sep 23 2016, 5:22 AM
ioeric updated this revision to Diff 72285.Sep 23 2016, 8:16 AM
ioeric marked 2 inline comments as done.
ioeric edited edge metadata.
  • Addressed comments.
This revision was automatically updated to reflect the committed changes.