From b54ef6a2a4c84293f64f90ea344b129eabbb0cd1 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Thu, 14 Sep 2017 10:06:52 +0000 Subject: [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: 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: 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 --- .../lib/Tooling/Refactoring/RefactoringActions.cpp | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 clang/lib/Tooling/Refactoring/RefactoringActions.cpp (limited to 'clang/lib/Tooling/Refactoring/RefactoringActions.cpp') diff --git a/clang/lib/Tooling/Refactoring/RefactoringActions.cpp b/clang/lib/Tooling/Refactoring/RefactoringActions.cpp new file mode 100644 index 00000000000..25f055b7270 --- /dev/null +++ b/clang/lib/Tooling/Refactoring/RefactoringActions.cpp @@ -0,0 +1,35 @@ +//===--- RefactoringActions.cpp - Constructs refactoring actions ----------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "clang/Tooling/Refactoring/RefactoringAction.h" + +namespace clang { +namespace tooling { + +// Forward declare the individual create*Action functions. +#define REFACTORING_ACTION(Name) \ + std::unique_ptr create##Name##Action(); +#include "clang/Tooling/Refactoring/RefactoringActionRegistry.def" + +std::vector> createRefactoringActions() { + std::vector> Actions; + +#define REFACTORING_ACTION(Name) Actions.push_back(create##Name##Action()); +#include "clang/Tooling/Refactoring/RefactoringActionRegistry.def" + + return Actions; +} + +RefactoringActionRules RefactoringAction::createActiveActionRules() { + // FIXME: Filter out rules that are not supported by a particular client. + return createActionRules(); +} + +} // end namespace tooling +} // end namespace clang -- cgit v1.2.3