From c7e637b329eacf8dcd270b8d4fd9f429b72aa3f8 Mon Sep 17 00:00:00 2001 From: Yitzhak Mandelbaum Date: Thu, 10 Oct 2019 02:34:47 +0000 Subject: [PATCH] [libTooling] Move Transformer files to their own directory/library. Summary: The Transformer library has been growing inside of lib/Tooling/Refactoring. However, it's not really related to anything else in that directory. This revision moves all Transformer-related files into their own include & lib directories. A followup revision will (temporarily) add forwarding headers to help any users migrate their code to the new location. Reviewers: gribozavr Subscribers: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68637 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374271 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../MatchConsumer.h | 6 +++--- .../RangeSelector.h | 2 +- .../{Refactoring => Transformer}/SourceCode.h | 6 +++--- .../SourceCodeBuilders.h | 6 +++--- .../{Refactoring => Transformer}/Stencil.h | 10 +++++----- .../{Refactoring => Transformer}/Transformer.h | 10 +++++----- lib/Tooling/CMakeLists.txt | 1 + lib/Tooling/Refactoring/CMakeLists.txt | 5 ----- lib/Tooling/Transformer/CMakeLists.txt | 17 +++++++++++++++++ .../RangeSelector.cpp | 4 ++-- .../{Refactoring => Transformer}/SourceCode.cpp | 2 +- .../SourceCodeBuilders.cpp | 4 ++-- .../{Refactoring => Transformer}/Stencil.cpp | 6 +++--- .../Transformer.cpp | 6 +++--- unittests/Tooling/CMakeLists.txt | 1 + unittests/Tooling/RangeSelectorTest.cpp | 2 +- unittests/Tooling/SourceCodeBuildersTest.cpp | 2 +- unittests/Tooling/SourceCodeTest.cpp | 2 +- unittests/Tooling/StencilTest.cpp | 2 +- unittests/Tooling/TransformerTest.cpp | 4 ++-- 20 files changed, 56 insertions(+), 42 deletions(-) rename include/clang/Tooling/{Refactoring => Transformer}/MatchConsumer.h (92%) rename include/clang/Tooling/{Refactoring => Transformer}/RangeSelector.h (98%) rename include/clang/Tooling/{Refactoring => Transformer}/SourceCode.h (95%) rename include/clang/Tooling/{Refactoring => Transformer}/SourceCodeBuilders.h (94%) rename include/clang/Tooling/{Refactoring => Transformer}/Stencil.h (96%) rename include/clang/Tooling/{Refactoring => Transformer}/Transformer.h (98%) create mode 100644 lib/Tooling/Transformer/CMakeLists.txt rename lib/Tooling/{Refactoring => Transformer}/RangeSelector.cpp (99%) rename lib/Tooling/{Refactoring => Transformer}/SourceCode.cpp (98%) rename lib/Tooling/{Refactoring => Transformer}/SourceCodeBuilders.cpp (98%) rename lib/Tooling/{Refactoring => Transformer}/Stencil.cpp (98%) rename lib/Tooling/{Refactoring => Transformer}/Transformer.cpp (98%) diff --git a/include/clang/Tooling/Refactoring/MatchConsumer.h b/include/clang/Tooling/Transformer/MatchConsumer.h similarity index 92% rename from include/clang/Tooling/Refactoring/MatchConsumer.h rename to include/clang/Tooling/Transformer/MatchConsumer.h index d516550d0f..51eb6af25a 100644 --- a/include/clang/Tooling/Refactoring/MatchConsumer.h +++ b/include/clang/Tooling/Transformer/MatchConsumer.h @@ -12,8 +12,8 @@ /// //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLING_REFACTOR_MATCH_CONSUMER_H_ -#define LLVM_CLANG_TOOLING_REFACTOR_MATCH_CONSUMER_H_ +#ifndef LLVM_CLANG_TOOLING_TRANSFORMER_MATCH_CONSUMER_H_ +#define LLVM_CLANG_TOOLING_TRANSFORMER_MATCH_CONSUMER_H_ #include "clang/AST/ASTTypeTraits.h" #include "clang/ASTMatchers/ASTMatchFinder.h" @@ -55,4 +55,4 @@ MatchConsumer ifBound(std::string ID, MatchConsumer TrueC, } // namespace tooling } // namespace clang -#endif // LLVM_CLANG_TOOLING_REFACTOR_MATCH_CONSUMER_H_ +#endif // LLVM_CLANG_TOOLING_TRANSFORMER_MATCH_CONSUMER_H_ diff --git a/include/clang/Tooling/Refactoring/RangeSelector.h b/include/clang/Tooling/Transformer/RangeSelector.h similarity index 98% rename from include/clang/Tooling/Refactoring/RangeSelector.h rename to include/clang/Tooling/Transformer/RangeSelector.h index d5b5c8fbd8..e178fb36a8 100644 --- a/include/clang/Tooling/Refactoring/RangeSelector.h +++ b/include/clang/Tooling/Transformer/RangeSelector.h @@ -17,7 +17,7 @@ #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Basic/SourceLocation.h" -#include "clang/Tooling/Refactoring/MatchConsumer.h" +#include "clang/Tooling/Transformer/MatchConsumer.h" #include "llvm/Support/Error.h" #include #include diff --git a/include/clang/Tooling/Refactoring/SourceCode.h b/include/clang/Tooling/Transformer/SourceCode.h similarity index 95% rename from include/clang/Tooling/Refactoring/SourceCode.h rename to include/clang/Tooling/Transformer/SourceCode.h index 72dbee4a43..bc9cc3d2a2 100644 --- a/include/clang/Tooling/Refactoring/SourceCode.h +++ b/include/clang/Tooling/Transformer/SourceCode.h @@ -10,8 +10,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLING_REFACTOR_SOURCE_CODE_H -#define LLVM_CLANG_TOOLING_REFACTOR_SOURCE_CODE_H +#ifndef LLVM_CLANG_TOOLING_TRANSFORMER_SOURCE_CODE_H +#define LLVM_CLANG_TOOLING_TRANSFORMER_SOURCE_CODE_H #include "clang/AST/ASTContext.h" #include "clang/Basic/SourceLocation.h" @@ -87,4 +87,4 @@ getRangeForEdit(const CharSourceRange &EditRange, const ASTContext &Context) { } } // namespace tooling } // namespace clang -#endif // LLVM_CLANG_TOOLING_REFACTOR_SOURCE_CODE_H +#endif // LLVM_CLANG_TOOLING_TRANSFORMER_SOURCE_CODE_H diff --git a/include/clang/Tooling/Refactoring/SourceCodeBuilders.h b/include/clang/Tooling/Transformer/SourceCodeBuilders.h similarity index 94% rename from include/clang/Tooling/Refactoring/SourceCodeBuilders.h rename to include/clang/Tooling/Transformer/SourceCodeBuilders.h index 797046f3ec..6c79a7588f 100644 --- a/include/clang/Tooling/Refactoring/SourceCodeBuilders.h +++ b/include/clang/Tooling/Transformer/SourceCodeBuilders.h @@ -11,8 +11,8 @@ /// //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLING_REFACTOR_SOURCE_CODE_BUILDERS_H_ -#define LLVM_CLANG_TOOLING_REFACTOR_SOURCE_CODE_BUILDERS_H_ +#ifndef LLVM_CLANG_TOOLING_TRANSFORMER_SOURCE_CODE_BUILDERS_H_ +#define LLVM_CLANG_TOOLING_TRANSFORMER_SOURCE_CODE_BUILDERS_H_ #include "clang/AST/ASTContext.h" #include "clang/AST/Expr.h" @@ -83,4 +83,4 @@ llvm::Optional buildArrow(const Expr &E, } // namespace tooling } // namespace clang -#endif // LLVM_CLANG_TOOLING_REFACTOR_SOURCE_CODE_BUILDERS_H_ +#endif // LLVM_CLANG_TOOLING_TRANSFORMER_SOURCE_CODE_BUILDERS_H_ diff --git a/include/clang/Tooling/Refactoring/Stencil.h b/include/clang/Tooling/Transformer/Stencil.h similarity index 96% rename from include/clang/Tooling/Refactoring/Stencil.h rename to include/clang/Tooling/Transformer/Stencil.h index b80320d409..617585cacd 100644 --- a/include/clang/Tooling/Refactoring/Stencil.h +++ b/include/clang/Tooling/Transformer/Stencil.h @@ -17,14 +17,14 @@ /// //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLING_REFACTOR_STENCIL_H_ -#define LLVM_CLANG_TOOLING_REFACTOR_STENCIL_H_ +#ifndef LLVM_CLANG_TOOLING_TRANSFORMER_STENCIL_H_ +#define LLVM_CLANG_TOOLING_TRANSFORMER_STENCIL_H_ #include "clang/AST/ASTContext.h" #include "clang/AST/ASTTypeTraits.h" #include "clang/ASTMatchers/ASTMatchFinder.h" -#include "clang/Tooling/Refactoring/MatchConsumer.h" -#include "clang/Tooling/Refactoring/RangeSelector.h" +#include "clang/Tooling/Transformer/MatchConsumer.h" +#include "clang/Tooling/Transformer/RangeSelector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include @@ -223,4 +223,4 @@ StencilPart dPrint(llvm::StringRef Id); } // namespace stencil } // namespace tooling } // namespace clang -#endif // LLVM_CLANG_TOOLING_REFACTOR_STENCIL_H_ +#endif // LLVM_CLANG_TOOLING_TRANSFORMER_STENCIL_H_ diff --git a/include/clang/Tooling/Refactoring/Transformer.h b/include/clang/Tooling/Transformer/Transformer.h similarity index 98% rename from include/clang/Tooling/Refactoring/Transformer.h rename to include/clang/Tooling/Transformer/Transformer.h index 0971cc3e66..0dc1e820e2 100644 --- a/include/clang/Tooling/Refactoring/Transformer.h +++ b/include/clang/Tooling/Transformer/Transformer.h @@ -12,15 +12,15 @@ /// //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLING_REFACTOR_TRANSFORMER_H_ -#define LLVM_CLANG_TOOLING_REFACTOR_TRANSFORMER_H_ +#ifndef LLVM_CLANG_TOOLING_TRANSFORMER_TRANSFORMER_H_ +#define LLVM_CLANG_TOOLING_TRANSFORMER_TRANSFORMER_H_ #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchers.h" #include "clang/ASTMatchers/ASTMatchersInternal.h" #include "clang/Tooling/Refactoring/AtomicChange.h" -#include "clang/Tooling/Refactoring/MatchConsumer.h" -#include "clang/Tooling/Refactoring/RangeSelector.h" +#include "clang/Tooling/Transformer/MatchConsumer.h" +#include "clang/Tooling/Transformer/RangeSelector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Error.h" @@ -317,4 +317,4 @@ private: } // namespace tooling } // namespace clang -#endif // LLVM_CLANG_TOOLING_REFACTOR_TRANSFORMER_H_ +#endif // LLVM_CLANG_TOOLING_TRANSFORMER_TRANSFORMER_H_ diff --git a/lib/Tooling/CMakeLists.txt b/lib/Tooling/CMakeLists.txt index 81185d7417..05061f0a10 100644 --- a/lib/Tooling/CMakeLists.txt +++ b/lib/Tooling/CMakeLists.txt @@ -9,6 +9,7 @@ add_subdirectory(Refactoring) add_subdirectory(ASTDiff) add_subdirectory(Syntax) add_subdirectory(DependencyScanning) +add_subdirectory(Transformer) add_clang_library(clangTooling AllTUsExecution.cpp diff --git a/lib/Tooling/Refactoring/CMakeLists.txt b/lib/Tooling/Refactoring/CMakeLists.txt index e3961db284..db889d2a06 100644 --- a/lib/Tooling/Refactoring/CMakeLists.txt +++ b/lib/Tooling/Refactoring/CMakeLists.txt @@ -6,17 +6,12 @@ add_clang_library(clangToolingRefactoring AtomicChange.cpp Extract/Extract.cpp Extract/SourceExtraction.cpp - RangeSelector.cpp RefactoringActions.cpp Rename/RenamingAction.cpp Rename/SymbolOccurrences.cpp Rename/USRFinder.cpp Rename/USRFindingAction.cpp Rename/USRLocFinder.cpp - SourceCode.cpp - SourceCodeBuilders.cpp - Stencil.cpp - Transformer.cpp LINK_LIBS clangAST diff --git a/lib/Tooling/Transformer/CMakeLists.txt b/lib/Tooling/Transformer/CMakeLists.txt new file mode 100644 index 0000000000..2e9ba58862 --- /dev/null +++ b/lib/Tooling/Transformer/CMakeLists.txt @@ -0,0 +1,17 @@ +set(LLVM_LINK_COMPONENTS Support) + +add_clang_library(clangTransformer + RangeSelector.cpp + SourceCode.cpp + SourceCodeBuilders.cpp + Stencil.cpp + Transformer.cpp + + LINK_LIBS + clangAST + clangASTMatchers + clangBasic + clangLex + clangToolingCore + clangToolingRefactoring + ) diff --git a/lib/Tooling/Refactoring/RangeSelector.cpp b/lib/Tooling/Transformer/RangeSelector.cpp similarity index 99% rename from lib/Tooling/Refactoring/RangeSelector.cpp rename to lib/Tooling/Transformer/RangeSelector.cpp index 972c7e6554..496c2d987c 100644 --- a/lib/Tooling/Refactoring/RangeSelector.cpp +++ b/lib/Tooling/Transformer/RangeSelector.cpp @@ -6,12 +6,12 @@ // //===----------------------------------------------------------------------===// -#include "clang/Tooling/Refactoring/RangeSelector.h" +#include "clang/Tooling/Transformer/RangeSelector.h" #include "clang/AST/Expr.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Basic/SourceLocation.h" #include "clang/Lex/Lexer.h" -#include "clang/Tooling/Refactoring/SourceCode.h" +#include "clang/Tooling/Transformer/SourceCode.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Errc.h" #include "llvm/Support/Error.h" diff --git a/lib/Tooling/Refactoring/SourceCode.cpp b/lib/Tooling/Transformer/SourceCode.cpp similarity index 98% rename from lib/Tooling/Refactoring/SourceCode.cpp rename to lib/Tooling/Transformer/SourceCode.cpp index cee8f43f3e..836401d1e6 100644 --- a/lib/Tooling/Refactoring/SourceCode.cpp +++ b/lib/Tooling/Transformer/SourceCode.cpp @@ -9,7 +9,7 @@ // This file provides functions that simplify extraction of source code. // //===----------------------------------------------------------------------===// -#include "clang/Tooling/Refactoring/SourceCode.h" +#include "clang/Tooling/Transformer/SourceCode.h" #include "clang/Lex/Lexer.h" using namespace clang; diff --git a/lib/Tooling/Refactoring/SourceCodeBuilders.cpp b/lib/Tooling/Transformer/SourceCodeBuilders.cpp similarity index 98% rename from lib/Tooling/Refactoring/SourceCodeBuilders.cpp rename to lib/Tooling/Transformer/SourceCodeBuilders.cpp index 2499c0f1eb..56ec45e8fd 100644 --- a/lib/Tooling/Refactoring/SourceCodeBuilders.cpp +++ b/lib/Tooling/Transformer/SourceCodeBuilders.cpp @@ -6,11 +6,11 @@ // //===----------------------------------------------------------------------===// -#include "clang/Tooling/Refactoring/SourceCodeBuilders.h" +#include "clang/Tooling/Transformer/SourceCodeBuilders.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" -#include "clang/Tooling/Refactoring/SourceCode.h" +#include "clang/Tooling/Transformer/SourceCode.h" #include "llvm/ADT/Twine.h" #include diff --git a/lib/Tooling/Refactoring/Stencil.cpp b/lib/Tooling/Transformer/Stencil.cpp similarity index 98% rename from lib/Tooling/Refactoring/Stencil.cpp rename to lib/Tooling/Transformer/Stencil.cpp index ebfe78099d..82fde2bc4d 100644 --- a/lib/Tooling/Refactoring/Stencil.cpp +++ b/lib/Tooling/Transformer/Stencil.cpp @@ -6,15 +6,15 @@ // //===----------------------------------------------------------------------===// -#include "clang/Tooling/Refactoring/Stencil.h" +#include "clang/Tooling/Transformer/Stencil.h" #include "clang/AST/ASTContext.h" #include "clang/AST/ASTTypeTraits.h" #include "clang/AST/Expr.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Lex/Lexer.h" -#include "clang/Tooling/Refactoring/SourceCode.h" -#include "clang/Tooling/Refactoring/SourceCodeBuilders.h" +#include "clang/Tooling/Transformer/SourceCode.h" +#include "clang/Tooling/Transformer/SourceCodeBuilders.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/Errc.h" #include diff --git a/lib/Tooling/Refactoring/Transformer.cpp b/lib/Tooling/Transformer/Transformer.cpp similarity index 98% rename from lib/Tooling/Refactoring/Transformer.cpp rename to lib/Tooling/Transformer/Transformer.cpp index 905d594444..1aecf6ab8e 100644 --- a/lib/Tooling/Refactoring/Transformer.cpp +++ b/lib/Tooling/Transformer/Transformer.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "clang/Tooling/Refactoring/Transformer.h" +#include "clang/Tooling/Transformer/Transformer.h" #include "clang/AST/Expr.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchers.h" @@ -14,15 +14,15 @@ #include "clang/Basic/SourceLocation.h" #include "clang/Rewrite/Core/Rewriter.h" #include "clang/Tooling/Refactoring/AtomicChange.h" -#include "clang/Tooling/Refactoring/SourceCode.h" +#include "clang/Tooling/Transformer/SourceCode.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Errc.h" #include "llvm/Support/Error.h" +#include #include #include #include -#include using namespace clang; using namespace tooling; diff --git a/unittests/Tooling/CMakeLists.txt b/unittests/Tooling/CMakeLists.txt index 2b35302c7b..5cef154926 100644 --- a/unittests/Tooling/CMakeLists.txt +++ b/unittests/Tooling/CMakeLists.txt @@ -75,6 +75,7 @@ clang_target_link_libraries(ToolingTests clangToolingCore clangToolingInclusions clangToolingRefactoring + clangTransformer ) target_link_libraries(ToolingTests diff --git a/unittests/Tooling/RangeSelectorTest.cpp b/unittests/Tooling/RangeSelectorTest.cpp index 58ce63cbd7..29a20a9f18 100644 --- a/unittests/Tooling/RangeSelectorTest.cpp +++ b/unittests/Tooling/RangeSelectorTest.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "clang/Tooling/Refactoring/RangeSelector.h" +#include "clang/Tooling/Transformer/RangeSelector.h" #include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Frontend/ASTUnit.h" #include "clang/Tooling/FixIt.h" diff --git a/unittests/Tooling/SourceCodeBuildersTest.cpp b/unittests/Tooling/SourceCodeBuildersTest.cpp index 2bf50ffad5..9b5e7bf3ba 100644 --- a/unittests/Tooling/SourceCodeBuildersTest.cpp +++ b/unittests/Tooling/SourceCodeBuildersTest.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "clang/Tooling/Refactoring/SourceCodeBuilders.h" +#include "clang/Tooling/Transformer/SourceCodeBuilders.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Tooling/Tooling.h" diff --git a/unittests/Tooling/SourceCodeTest.cpp b/unittests/Tooling/SourceCodeTest.cpp index e3da9bf14b..eb28d7cf27 100644 --- a/unittests/Tooling/SourceCodeTest.cpp +++ b/unittests/Tooling/SourceCodeTest.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "clang/Tooling/Refactoring/SourceCode.h" +#include "clang/Tooling/Transformer/SourceCode.h" #include "TestVisitor.h" #include "clang/Basic/Diagnostic.h" #include "llvm/Testing/Support/Annotations.h" diff --git a/unittests/Tooling/StencilTest.cpp b/unittests/Tooling/StencilTest.cpp index 0bd3d90f83..2b9aa68e34 100644 --- a/unittests/Tooling/StencilTest.cpp +++ b/unittests/Tooling/StencilTest.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "clang/Tooling/Refactoring/Stencil.h" +#include "clang/Tooling/Transformer/Stencil.h" #include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Tooling/FixIt.h" #include "clang/Tooling/Tooling.h" diff --git a/unittests/Tooling/TransformerTest.cpp b/unittests/Tooling/TransformerTest.cpp index 5d55182f82..feae0c649a 100644 --- a/unittests/Tooling/TransformerTest.cpp +++ b/unittests/Tooling/TransformerTest.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// -#include "clang/Tooling/Refactoring/Transformer.h" +#include "clang/Tooling/Transformer/Transformer.h" #include "clang/ASTMatchers/ASTMatchers.h" -#include "clang/Tooling/Refactoring/RangeSelector.h" +#include "clang/Tooling/Transformer/RangeSelector.h" #include "clang/Tooling/Tooling.h" #include "llvm/Support/Errc.h" #include "llvm/Support/Error.h" -- 2.40.0