ymandel created this revision.
ymandel added a reviewer: gribozavr.
Herald added a subscriber: mgorny.
Herald added a project: clang.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68637

Files:
  clang-tools-extra/clang-tidy/utils/CMakeLists.txt
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
  clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
  clang/include/clang/Tooling/Refactoring/MatchConsumer.h
  clang/include/clang/Tooling/Refactoring/RangeSelector.h
  clang/include/clang/Tooling/Refactoring/SourceCode.h
  clang/include/clang/Tooling/Refactoring/SourceCodeBuilders.h
  clang/include/clang/Tooling/Refactoring/Stencil.h
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/include/clang/Tooling/Transformer/MatchConsumer.h
  clang/include/clang/Tooling/Transformer/RangeSelector.h
  clang/include/clang/Tooling/Transformer/SourceCode.h
  clang/include/clang/Tooling/Transformer/SourceCodeBuilders.h
  clang/include/clang/Tooling/Transformer/Stencil.h
  clang/include/clang/Tooling/Transformer/Transformer.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Refactoring/RangeSelector.cpp
  clang/lib/Tooling/Refactoring/SourceCode.cpp
  clang/lib/Tooling/Refactoring/SourceCodeBuilders.cpp
  clang/lib/Tooling/Refactoring/Stencil.cpp
  clang/lib/Tooling/Refactoring/Transformer.cpp
  clang/lib/Tooling/Transformer/CMakeLists.txt
  clang/lib/Tooling/Transformer/RangeSelector.cpp
  clang/lib/Tooling/Transformer/SourceCode.cpp
  clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/lib/Tooling/Transformer/Transformer.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/RangeSelectorTest.cpp
  clang/unittests/Tooling/SourceCodeBuildersTest.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp
  clang/unittests/Tooling/StencilTest.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===================================================================
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/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"
Index: clang/unittests/Tooling/StencilTest.cpp
===================================================================
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/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"
Index: clang/unittests/Tooling/SourceCodeTest.cpp
===================================================================
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/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"
Index: clang/unittests/Tooling/SourceCodeBuildersTest.cpp
===================================================================
--- clang/unittests/Tooling/SourceCodeBuildersTest.cpp
+++ clang/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"
Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===================================================================
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/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"
Index: clang/unittests/Tooling/CMakeLists.txt
===================================================================
--- clang/unittests/Tooling/CMakeLists.txt
+++ clang/unittests/Tooling/CMakeLists.txt
@@ -75,6 +75,7 @@
   clangToolingCore
   clangToolingInclusions
   clangToolingRefactoring
+  clangTransformer
   )
 
 target_link_libraries(ToolingTests
Index: clang/lib/Tooling/Transformer/Transformer.cpp
===================================================================
--- clang/lib/Tooling/Transformer/Transformer.cpp
+++ clang/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 <map>
 #include <string>
 #include <utility>
 #include <vector>
-#include <map>
 
 using namespace clang;
 using namespace tooling;
Index: clang/lib/Tooling/Transformer/Stencil.cpp
===================================================================
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/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 <atomic>
Index: clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
===================================================================
--- clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
+++ clang/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 <string>
 
Index: clang/lib/Tooling/Transformer/SourceCode.cpp
===================================================================
--- clang/lib/Tooling/Transformer/SourceCode.cpp
+++ clang/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;
Index: clang/lib/Tooling/Transformer/RangeSelector.cpp
===================================================================
--- clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ clang/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"
Index: clang/lib/Tooling/Transformer/CMakeLists.txt
===================================================================
--- /dev/null
+++ clang/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
+  )
Index: clang/lib/Tooling/Refactoring/CMakeLists.txt
===================================================================
--- clang/lib/Tooling/Refactoring/CMakeLists.txt
+++ clang/lib/Tooling/Refactoring/CMakeLists.txt
@@ -6,17 +6,12 @@
   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
Index: clang/lib/Tooling/CMakeLists.txt
===================================================================
--- clang/lib/Tooling/CMakeLists.txt
+++ clang/lib/Tooling/CMakeLists.txt
@@ -9,6 +9,7 @@
 add_subdirectory(ASTDiff)
 add_subdirectory(Syntax)
 add_subdirectory(DependencyScanning)
+add_subdirectory(Transformer)
 
 add_clang_library(clangTooling
   AllTUsExecution.cpp
Index: clang/include/clang/Tooling/Transformer/Transformer.h
===================================================================
--- clang/include/clang/Tooling/Transformer/Transformer.h
+++ clang/include/clang/Tooling/Transformer/Transformer.h
@@ -19,8 +19,8 @@
 #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"
Index: clang/include/clang/Tooling/Transformer/Stencil.h
===================================================================
--- clang/include/clang/Tooling/Transformer/Stencil.h
+++ clang/include/clang/Tooling/Transformer/Stencil.h
@@ -23,8 +23,8 @@
 #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 <string>
Index: clang/include/clang/Tooling/Refactoring/SourceCodeBuilders.h
===================================================================
--- /dev/null
+++ clang/include/clang/Tooling/Refactoring/SourceCodeBuilders.h
@@ -1,86 +0,0 @@
-//===--- SourceCodeBuilders.h - Source-code building facilities -*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file
-/// This file collects facilities for generating source code strings.
-///
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_TOOLING_REFACTOR_SOURCE_CODE_BUILDERS_H_
-#define LLVM_CLANG_TOOLING_REFACTOR_SOURCE_CODE_BUILDERS_H_
-
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/Expr.h"
-#include <string>
-
-namespace clang {
-namespace tooling {
-
-/// \name Code analysis utilities.
-/// @{
-/// Ignores implicit object-construction expressions in addition to the normal
-/// implicit expressions that are ignored.
-const Expr *reallyIgnoreImplicit(const Expr &E);
-
-/// Determines whether printing this expression in *any* expression requires
-/// parentheses to preserve its meaning. This analyses is necessarily
-/// conservative because it lacks information about the target context.
-bool mayEverNeedParens(const Expr &E);
-
-/// Determines whether printing this expression to the left of a dot or arrow
-/// operator requires a parentheses to preserve its meaning. Given that
-/// dot/arrow are (effectively) the highest precedence, this is equivalent to
-/// asking whether it ever needs parens.
-inline bool needParensBeforeDotOrArrow(const Expr &E) {
-  return mayEverNeedParens(E);
-}
-
-/// Determines whether printing this expression to the right of a unary operator
-/// requires a parentheses to preserve its meaning.
-bool needParensAfterUnaryOperator(const Expr &E);
-/// @}
-
-/// \name Basic code-string generation utilities.
-/// @{
-
-/// Builds source for an expression, adding parens if needed for unambiguous
-/// parsing.
-llvm::Optional<std::string> buildParens(const Expr &E,
-                                        const ASTContext &Context);
-
-/// Builds idiomatic source for the dereferencing of `E`: prefix with `*` but
-/// simplify when it already begins with `&`.  \returns empty string on failure.
-llvm::Optional<std::string> buildDereference(const Expr &E,
-                                             const ASTContext &Context);
-
-/// Builds idiomatic source for taking the address of `E`: prefix with `&` but
-/// simplify when it already begins with `*`.  \returns empty string on failure.
-llvm::Optional<std::string> buildAddressOf(const Expr &E,
-                                           const ASTContext &Context);
-
-/// Adds a dot to the end of the given expression, but adds parentheses when
-/// needed by the syntax, and simplifies to `->` when possible, e.g.:
-///
-///  `x` becomes `x.`
-///  `*a` becomes `a->`
-///  `a+b` becomes `(a+b).`
-llvm::Optional<std::string> buildDot(const Expr &E, const ASTContext &Context);
-
-/// Adds an arrow to the end of the given expression, but adds parentheses
-/// when needed by the syntax, and simplifies to `.` when possible, e.g.:
-///
-///  `x` becomes `x->`
-///  `&a` becomes `a.`
-///  `a+b` becomes `(a+b)->`
-llvm::Optional<std::string> buildArrow(const Expr &E,
-                                       const ASTContext &Context);
-/// @}
-
-} // namespace tooling
-} // namespace clang
-#endif // LLVM_CLANG_TOOLING_REFACTOR_SOURCE_CODE_BUILDERS_H_
Index: clang/include/clang/Tooling/Refactoring/SourceCode.h
===================================================================
--- /dev/null
+++ clang/include/clang/Tooling/Refactoring/SourceCode.h
@@ -1,90 +0,0 @@
-//===--- SourceCode.h - Source code manipulation routines -------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-//  This file provides functions that simplify extraction of source code.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_TOOLING_REFACTOR_SOURCE_CODE_H
-#define LLVM_CLANG_TOOLING_REFACTOR_SOURCE_CODE_H
-
-#include "clang/AST/ASTContext.h"
-#include "clang/Basic/SourceLocation.h"
-#include "clang/Basic/TokenKinds.h"
-
-namespace clang {
-namespace tooling {
-
-/// Extends \p Range to include the token \p Next, if it immediately follows the
-/// end of the range. Otherwise, returns \p Range unchanged.
-CharSourceRange maybeExtendRange(CharSourceRange Range, tok::TokenKind Next,
-                                 ASTContext &Context);
-
-/// Returns the source range spanning the node, extended to include \p Next, if
-/// it immediately follows \p Node. Otherwise, returns the normal range of \p
-/// Node.  See comments on `getExtendedText()` for examples.
-template <typename T>
-CharSourceRange getExtendedRange(const T &Node, tok::TokenKind Next,
-                                 ASTContext &Context) {
-  return maybeExtendRange(CharSourceRange::getTokenRange(Node.getSourceRange()),
-                          Next, Context);
-}
-
-/// Returns the source-code text in the specified range.
-StringRef getText(CharSourceRange Range, const ASTContext &Context);
-
-/// Returns the source-code text corresponding to \p Node.
-template <typename T>
-StringRef getText(const T &Node, const ASTContext &Context) {
-  return getText(CharSourceRange::getTokenRange(Node.getSourceRange()),
-                 Context);
-}
-
-/// Returns the source text of the node, extended to include \p Next, if it
-/// immediately follows the node. Otherwise, returns the text of just \p Node.
-///
-/// For example, given statements S1 and S2 below:
-/// \code
-///   {
-///     // S1:
-///     if (!x) return foo();
-///     // S2:
-///     if (!x) { return 3; }
-///   }
-/// \endcode
-/// then
-/// \code
-///   getText(S1, Context) = "if (!x) return foo()"
-///   getExtendedText(S1, tok::TokenKind::semi, Context)
-///     = "if (!x) return foo();"
-///   getExtendedText(*S1.getThen(), tok::TokenKind::semi, Context)
-///     = "return foo();"
-///   getExtendedText(*S2.getThen(), tok::TokenKind::semi, Context)
-///     = getText(S2, Context) = "{ return 3; }"
-/// \endcode
-template <typename T>
-StringRef getExtendedText(const T &Node, tok::TokenKind Next,
-                          ASTContext &Context) {
-  return getText(getExtendedRange(Node, Next, Context), Context);
-}
-
-// Attempts to resolve the given range to one that can be edited by a rewrite;
-// generally, one that starts and ends within a particular file. It supports
-// a limited set of cases involving source locations in macro expansions.
-llvm::Optional<CharSourceRange>
-getRangeForEdit(const CharSourceRange &EditRange, const SourceManager &SM,
-                const LangOptions &LangOpts);
-
-inline llvm::Optional<CharSourceRange>
-getRangeForEdit(const CharSourceRange &EditRange, const ASTContext &Context) {
-  return getRangeForEdit(EditRange, Context.getSourceManager(),
-                         Context.getLangOpts());
-}
-} // namespace tooling
-} // namespace clang
-#endif // LLVM_CLANG_TOOLING_REFACTOR_SOURCE_CODE_H
Index: clang/include/clang/Tooling/Transformer/RangeSelector.h
===================================================================
--- clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ clang/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 <functional>
 #include <string>
Index: clang/include/clang/Tooling/Refactoring/MatchConsumer.h
===================================================================
--- /dev/null
+++ clang/include/clang/Tooling/Refactoring/MatchConsumer.h
@@ -1,58 +0,0 @@
-//===--- MatchConsumer.h - MatchConsumer abstraction ------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file This file defines the *MatchConsumer* abstraction: a computation over
-/// match results, specifically the `ast_matchers::MatchFinder::MatchResult`
-/// class.
-///
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_TOOLING_REFACTOR_MATCH_CONSUMER_H_
-#define LLVM_CLANG_TOOLING_REFACTOR_MATCH_CONSUMER_H_
-
-#include "clang/AST/ASTTypeTraits.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Errc.h"
-#include "llvm/Support/Error.h"
-
-namespace clang {
-namespace tooling {
-
-/// A failable computation over nodes bound by AST matchers.
-///
-/// The computation should report any errors though its return value (rather
-/// than terminating the program) to enable usage in interactive scenarios like
-/// clang-query.
-///
-/// This is a central abstraction of the Transformer framework.
-template <typename T>
-using MatchConsumer =
-    std::function<Expected<T>(const ast_matchers::MatchFinder::MatchResult &)>;
-
-/// Creates an error that signals that a `MatchConsumer` expected a certain node
-/// to be bound by AST matchers, but it was not actually bound.
-inline llvm::Error notBoundError(llvm::StringRef Id) {
-  return llvm::make_error<llvm::StringError>(llvm::errc::invalid_argument,
-                                             "Id not bound: " + Id);
-}
-
-/// Chooses between the two consumers, based on whether \p ID is bound in the
-/// match.
-template <typename T>
-MatchConsumer<T> ifBound(std::string ID, MatchConsumer<T> TrueC,
-                         MatchConsumer<T> FalseC) {
-  return [=](const ast_matchers::MatchFinder::MatchResult &Result) {
-    auto &Map = Result.Nodes.getMap();
-    return (Map.find(ID) != Map.end() ? TrueC : FalseC)(Result);
-  };
-}
-
-} // namespace tooling
-} // namespace clang
-#endif // LLVM_CLANG_TOOLING_REFACTOR_MATCH_CONSUMER_H_
Index: clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
===================================================================
--- clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -9,9 +9,9 @@
 #include "../clang-tidy/utils/TransformerClangTidyCheck.h"
 #include "ClangTidyTest.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
-#include "clang/Tooling/Refactoring/RangeSelector.h"
-#include "clang/Tooling/Refactoring/Stencil.h"
-#include "clang/Tooling/Refactoring/Transformer.h"
+#include "clang/Tooling/Transformer/RangeSelector.h"
+#include "clang/Tooling/Transformer/Stencil.h"
+#include "clang/Tooling/Transformer/Transformer.h"
 #include "gtest/gtest.h"
 
 namespace clang {
Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
===================================================================
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
@@ -13,7 +13,7 @@
 #include "../utils/IncludeInserter.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Frontend/CompilerInstance.h"
-#include "clang/Tooling/Refactoring/Transformer.h"
+#include "clang/Tooling/Transformer/Transformer.h"
 #include <deque>
 #include <vector>
 
Index: clang-tools-extra/clang-tidy/utils/CMakeLists.txt
===================================================================
--- clang-tools-extra/clang-tidy/utils/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/utils/CMakeLists.txt
@@ -23,5 +23,5 @@
   clangBasic
   clangLex
   clangTidy
-  clangToolingRefactoring
+  clangTransformer
   )
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to