[PATCH] D37856: [refactor] add support for refactoring options

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 14 11:06:22 PDT 2017


arphaman created this revision.

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

The options are implemented in the following manner:

- A base interface `RefactoringOption` declares methods that describe the option's name, description and whether or not it's required. It also declares a method that takes in a `RefactoringOptionConsumer` that will visit the option and its typed value.
- A visitor interface `RefactoringOptionConsumer` declares the `handle` methods that provide an overload for each valid option type (std::string, etc).
- Classes `OptionalRequiredOption` and `RequiredRefactoringOption` partially implement the `RefactoringOption` interface, store the value and provide a getter for the value. The individual options then just have to implement `getName` and `getDescription`.
- The `RefactoringOptionsRequirement` is a base requirement class the declares a method that can returns all of the options used in a single requirement.
- The `OptionRequirement` class is a helper class that implements a refactoring action rule requirement for a particular option.

`clang-refactor` now creates command-line arguments for each unique option used by all rules in an action.

This patch also adds a `NewNameOption` for the local-rename refactoring action to ensure that options work.


Repository:
  rL LLVM

https://reviews.llvm.org/D37856

Files:
  include/clang/Tooling/Refactoring/RefactoringActionRule.h
  include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
  include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
  include/clang/Tooling/Refactoring/RefactoringOption.h
  include/clang/Tooling/Refactoring/RefactoringOptionConsumer.h
  include/clang/Tooling/Refactoring/RefactoringOptions.h
  include/clang/Tooling/Refactoring/Rename/RenamingAction.h
  lib/Tooling/Refactoring/Rename/RenamingAction.cpp
  test/Refactor/LocalRename/Field.cpp
  test/Refactor/tool-test-support.c
  tools/clang-refactor/ClangRefactor.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37856.115248.patch
Type: text/x-patch
Size: 25633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170914/e08f6337/attachment-0001.bin>


More information about the cfe-commits mailing list