This is an archive of the discontinued LLVM Phabricator instance.

[clang-move] Add header guard for the new header.
ClosedPublic

Authored by hokein on Oct 14 2016, 5:22 AM.

Details

Summary

The header guard generated by clang-move isn't always a perfect
style, just avoid getting the header included multiple times during
compiling period.

Also, we can use llvm-Header-guard clang-tidy check to correct the guard
automatically.

Diff Detail

Repository
rL LLVM

Event Timeline

hokein updated this revision to Diff 74663.Oct 14 2016, 5:22 AM
hokein retitled this revision from to [clang-move] Add header guard for the new header..
hokein updated this object.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.
ioeric accepted this revision.Oct 14 2016, 5:32 AM
ioeric edited edge metadata.

Lg

clang-move/ClangMove.cpp
264 ↗(On Diff #74663)

Might not quite related to this patch:

Considering how tooling::Replacements::add(...) is implemented now, it's quite inefficient to use addOrMergeReplacement in you case since almost all replacements will conflict, which would require expensive conflict-resolving merge. I think it would be cleaner and easier if you just concatenate all Decls and create a single insertion replacement instead of keeping merging replacements at offset 0.

This revision is now accepted and ready to land.Oct 14 2016, 5:32 AM
hokein added inline comments.Oct 14 2016, 6:03 AM
clang-move/ClangMove.cpp
264 ↗(On Diff #74663)

Good point. Yeah, the function only inserts new code to the new file. Make sense to only construct a single Replacement of the concatenated string. Will do in a follow-up.

This revision was automatically updated to reflect the committed changes.