This is an archive of the discontinued LLVM Phabricator instance.

[refactor][extract] insert semicolons into extracted/inserted code when needed
ClosedPublic

Authored by arphaman on Oct 30 2017, 6:36 PM.

Details

Summary

This patch implements the semicolon insertion logic into the extract refactoring.
The following rules are taken:

  • extracting expression: add terminating ';' to the extracted function.
  • extracting statements that don't require terminating ';' (e.g. switch): add terminating ';' to the callee.
  • extracting statements with ';': move (if possible) the original ';' from the callee and add terminating ';'.
  • otherwise, add ';' to both places.

Diff Detail

Repository
rL LLVM

Event Timeline

arphaman created this revision.Oct 30 2017, 6:36 PM
ioeric edited edge metadata.Nov 2 2017, 1:25 AM

Code looks good with some nits.

lib/Tooling/Refactoring/CMakeLists.txt
7

Shall we move function extraction sources into a sub-directory? Like what you did for headers.

lib/Tooling/Refactoring/SourceExtraction.h
25

I think this should be a class with accessors if the members are not expected to be changed by users.

36

Either move these helpers into the cpp file or simply make them public.

arphaman updated this revision to Diff 121339.Nov 2 2017, 11:19 AM
arphaman marked 3 inline comments as done.

Address review comments

ioeric accepted this revision.Nov 3 2017, 1:08 AM

lgtm

This revision is now accepted and ready to land.Nov 3 2017, 1:08 AM
This revision was automatically updated to reflect the committed changes.