[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 10 05:47:31 PDT 2017


arphaman created this revision.
Herald added a subscriber: mgorny.

This patch depends on https://reviews.llvm.org/D36075 and https://reviews.llvm.org/D36156.

It introduces the `clang-refactor` tool alongside the `local-rename` action which is uses the existing renaming engine used by `clang-rename`. The tool doesn't actually perform the source transformations yet, it just provides testing support. I've moved one test from `clang-rename` over right now, but will move the others if the general direction of this patch is accepted.

The following options are supported by clang-refactor:

- `-v`: use verbose output
- `-dump`: dump results instead of applying them
- `-no-dbs`: avoid searching/loading databases like compilation database and/or indexer stores/databases
- `-selection`: The source range that corresponds to the portion of the source that's selected (currently only special command `test:<file>` is supported).

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 for `findTestSelectionRangesIn` in TestSupport.h.

Thanks for taking a look!


Repository:
  rL LLVM

https://reviews.llvm.org/D36574

Files:
  include/clang/Basic/DiagnosticRefactoringKinds.td
  include/clang/Tooling/Refactoring/RefactoringAction.h
  include/clang/Tooling/Refactoring/RefactoringActionRegistry.def
  include/clang/Tooling/Refactoring/RefactoringActionRules.h
  include/clang/Tooling/Refactoring/RefactoringEngine.h
  include/clang/Tooling/Refactoring/RefactoringOperationController.h
  include/clang/Tooling/Refactoring/RefactoringResult.h
  include/clang/Tooling/Refactoring/Rename/SymbolOccurrences.h
  include/clang/Tooling/Refactoring/Rename/USRFindingAction.h
  include/clang/Tooling/Refactoring/SourceSelectionConstraints.h
  include/clang/module.modulemap
  lib/Tooling/Refactoring/CMakeLists.txt
  lib/Tooling/Refactoring/RefactoringEngine.cpp
  lib/Tooling/Refactoring/Rename/RenamingAction.cpp
  lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
  test/Refactor/LocalRename/Field.cpp
  test/Refactor/tool-common-options.c
  test/Refactor/tool-test-support.c
  test/clang-rename/Field.cpp
  tools/CMakeLists.txt
  tools/clang-refactor/CMakeLists.txt
  tools/clang-refactor/ClangRefactor.cpp
  tools/clang-refactor/TestSupport.cpp
  tools/clang-refactor/TestSupport.h
  unittests/Tooling/RefactoringActionRulesTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36574.110560.patch
Type: text/x-patch
Size: 58161 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170810/e85e4ee7/attachment-0001.bin>


More information about the cfe-commits mailing list