Commit Graph

19 Commits

Author SHA1 Message Date
Alex Lorenz cc55754a79 [refactor][extract] avoid extracting expressions from types in functions
llvm-svn: 318169
2017-11-14 18:59:01 +00:00
Haojian Wu 200458f342 [clang-refactor] Introduce a new rename rule for qualified symbols
Summary: Prototype of a new rename rule for renaming qualified symbol.

Reviewers: arphaman, ioeric, sammccall

Reviewed By: arphaman, sammccall

Subscribers: jklaehn, cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D39332

llvm-svn: 317672
2017-11-08 08:56:56 +00:00
Alex Lorenz f4bf4227b7 [refactor] rename field references in __builtin_offsetof
rdar://33875453

llvm-svn: 317599
2017-11-07 18:30:23 +00:00
Alex Lorenz 3cee7cfb30 Add -fcxx-exceptions for ExtractionSemicolonPolicy.cpp to appease PS4 bots
llvm-svn: 317372
2017-11-03 21:31:10 +00:00
Alex Lorenz ebbbb81266 [refactor][extract] insert semicolons into extracted/inserted code
when needed

This commit implements the semicolon insertion logic into the extract
refactoring. The following rules are used:

- 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.

Differential Revision: https://reviews.llvm.org/D39441

llvm-svn: 317343
2017-11-03 18:11:22 +00:00
Alex Lorenz 61f2c3f58c [refactor][extract] code extracted from inline method should be placed
in a function defined before the outer class

llvm-svn: 317062
2017-11-01 01:12:56 +00:00
Alex Lorenz 1e416fe23d [refactor][extract] prohibit extraction of ObjC property setters
llvm-svn: 317056
2017-11-01 00:20:55 +00:00
Alex Lorenz 7fe441b20d [refactor] Initial outline of implementation of "extract function" refactoring
This commit adds an initial, skeleton outline of the "extract function"
refactoring. The extracted function doesn't capture variables / rewrite code
yet, it just basically does a simple copy-paste.
The following initiation rules are specified:

- extraction can only be done for executable code in a function/method/block.
  This means that you can't extract a global variable initialize into a function
  right now.
- simple literals and references are not extractable.

This commit also adds support for full source ranges to clang-refactor's test
mode.

Differential Revision: https://reviews.llvm.org/D38982

llvm-svn: 316465
2017-10-24 17:18:45 +00:00
Haojian Wu 55186786a9 [clang-refactor] Add "-Inplace" option to the commandline tool.
Summary:
Change clang-refactor default behavior to print the new code after refactoring
(instead of editing the source files), which would make it easier to use
and debug the refactoring action.

Reviewers: arphaman, ioeric

Reviewed By: arphaman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D39092

llvm-svn: 316212
2017-10-20 12:37:16 +00:00
Alex Lorenz f5ca27cc37 [refactor] allow the use of refactoring diagnostics
This commit allows the refactoring library to use its own set of
refactoring-specific diagnostics to reports things like initiation errors.

Differential Revision: https://reviews.llvm.org/D38772

llvm-svn: 315924
2017-10-16 18:28:26 +00:00
Alex Lorenz e1b7b95901 Recommit r315738 "[clang-refactor] Apply source replacements"
The fixed commit ensures that ParsedSourceRange works correctly
with Windows paths.

Original message:

This commit actually brings clang-refactor to a usable state as it can now
apply the refactoring changes to source files.
The -selection option is now also fully supported.

Differential Revision: https://reviews.llvm.org/D38402

llvm-svn: 315918
2017-10-16 17:31:16 +00:00
Alex Lorenz 9ce566fc18 Revert r315738
The ParsedSourceRange class does not work correctly on Windows with the ':'
drive separators

llvm-svn: 315774
2017-10-13 22:47:44 +00:00
Alex Lorenz 57e060b309 [clang-refactor] Apply source replacements
This commit actually brings clang-refactor to a usable state as it can now
apply the refactoring changes to source files.
The -selection option is now also fully supported.

Differential Revision: https://reviews.llvm.org/D38402

llvm-svn: 315738
2017-10-13 19:42:05 +00:00
Alex Lorenz ad38fbffad Recommit r315087 "[refactor] add support for refactoring options"
The recommit fixes a UB bug that occurred only on a small number of bots.

Original message:

This commit adds initial support for refactoring options. One can now use
optional and required std::string options.

This commit also adds a NewNameOption for the local-rename refactoring action to
allow rename to work with custom names.

Differential Revision: https://reviews.llvm.org/D37856

llvm-svn: 315661
2017-10-13 01:53:13 +00:00
Alex Lorenz cdb9a05a81 Revert r315087
clang-refactor crashes on some bots after this commit

llvm-svn: 315095
2017-10-06 19:49:29 +00:00
Alex Lorenz 15da33480b [refactor] add support for refactoring options
This commit adds initial support for refactoring options. One can now use
optional and required std::string options.

This commit also adds a NewNameOption for the local-rename refactoring action to
allow rename to work with custom names.

Differential Revision: https://reviews.llvm.org/D37856

llvm-svn: 315087
2017-10-06 18:12:29 +00:00
Alex Lorenz 18633071a3 Fix Refactor/tool-test-support.c test on Windows by avoiding
the STDERR redirect

llvm-svn: 313266
2017-09-14 15:10:39 +00:00
Alex Lorenz 3d712c46e6 [refactor] Use CommonOptionsParser in clang-refactor
This commit ensures that CommonOptionsParser works with subcommands. This allows
clang-refactor to use the CommonOptionsParser.

Differential Revision: https://reviews.llvm.org/D37618

llvm-svn: 313260
2017-09-14 13:16:14 +00:00
Alex Lorenz b54ef6a2a4 [refactor] add clang-refactor tool with initial testing support and
local-rename action

This commit introduces the clang-refactor tool alongside the local-rename action
which uses the existing renaming engine used by clang-rename. The tool
doesn't actually perform the source transformations yet, it just provides
testing support. This commit also moves only one test from clang-rename over to
test/Refactor. I will continue to move the other tests throughout
development of clang-refactor.

The following options are supported by clang-refactor:

-v: use verbose output
-selection: The source range that corresponds to the portion of the source
 that's selected (currently only special command test:<file> is supported).

Please note that a follow-up commit will migrate clang-refactor to
libTooling's common option parser, so clang-refactor will be able to use
the common interface with compilation database and options like -p, -extra-arg,
etc.

The testing support provided by clang-refactor is described below:

When -selection=test:<file> is given, clang-refactor will parse the selection
commands from that file. The selection commands are grouped and the specified
refactoring action invoked by the tool. Each command in a group is expected to
produce an identical result. The precise syntax for the selection commands is
described in a comment in TestSupport.h.

Differential Revision: https://reviews.llvm.org/D36574

llvm-svn: 313244
2017-09-14 10:06:52 +00:00