]> granicus.if.org Git - clang/commitdiff
[libTooling] Fix r374962: add more Transformer forwarding decls.
authorYitzhak Mandelbaum <yitzhakm@google.com>
Wed, 16 Oct 2019 14:26:20 +0000 (14:26 +0000)
committerYitzhak Mandelbaum <yitzhakm@google.com>
Wed, 16 Oct 2019 14:26:20 +0000 (14:26 +0000)
Summary:
The move to a new, single namespace in r374962 left out some type definitions
from the old namespace and resulted in one naming conflict (`text`).  This
revision adds aliases for those definitions and removes one of the `text`
functions from the new namespace.

Reviewers: alexfh

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69036

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375003 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Tooling/Transformer/RangeSelector.h
include/clang/Tooling/Transformer/RewriteRule.h
include/clang/Tooling/Transformer/Stencil.h
unittests/Tooling/TransformerTest.cpp

index 00f1f84d0f826a2a9cac1fa3067361d2f0cec940..9f556d206321c6578d554179e3b06957bdfacec1 100644 (file)
@@ -92,6 +92,8 @@ RangeSelector expansion(RangeSelector S);
 namespace tooling {
 // DEPRECATED: These are temporary aliases supporting client migration to the
 // `transformer` namespace.
+using RangeSelector = transformer::RangeSelector;
+
 using transformer::after;
 using transformer::before;
 using transformer::callArgs;
index 058ef3f23d7e4332ea0d0a2626c47051ef92c87b..6e99151c1c7f52efa5674f5b03d5f98df4ecdbc4 100644 (file)
 namespace clang {
 namespace transformer {
 using TextGenerator = MatchConsumer<std::string>;
-/// Wraps a string as a TextGenerator.
-inline TextGenerator text(std::string M) {
-  return [M](const ast_matchers::MatchFinder::MatchResult &)
-             -> Expected<std::string> { return M; };
-}
 
 // Description of a source-code edit, expressed in terms of an AST node.
 // Includes: an ID for the (bound) node, a selector for source related to the
@@ -221,7 +216,9 @@ inline ASTEdit insertAfter(RangeSelector S, TextGenerator Replacement) {
 
 /// Removes the source selected by \p S.
 inline ASTEdit remove(RangeSelector S) {
-  return change(std::move(S), text(""));
+  return change(std::move(S),
+                [](const ast_matchers::MatchFinder::MatchResult &)
+                    -> Expected<std::string> { return ""; });
 }
 
 /// The following three functions are a low-level part of the RewriteRule
@@ -286,6 +283,14 @@ translateEdits(const ast_matchers::MatchFinder::MatchResult &Result,
 namespace tooling {
 // DEPRECATED: These are temporary aliases supporting client migration to the
 // `transformer` namespace.
+/// Wraps a string as a TextGenerator.
+using TextGenerator = transformer::TextGenerator;
+
+inline TextGenerator text(std::string M) {
+  return [M](const ast_matchers::MatchFinder::MatchResult &)
+             -> Expected<std::string> { return M; };
+}
+
 using transformer::addInclude;
 using transformer::applyFirst;
 using transformer::change;
@@ -293,7 +298,6 @@ using transformer::insertAfter;
 using transformer::insertBefore;
 using transformer::makeRule;
 using transformer::remove;
-using transformer::text;
 using transformer::RewriteRule;
 using transformer::IncludeFormat;
 namespace detail {
index feb3ac88531daa996d7ae1863e586ae7171bfb8b..66d1388f97106a45ad8a147887e0a866c1498315 100644 (file)
@@ -195,9 +195,11 @@ StencilPart dPrint(llvm::StringRef Id);
 } // namespace transformer
 
 namespace tooling {
-namespace stencil {
 // DEPRECATED: These are temporary aliases supporting client migration to the
 // `transformer` namespace.
+using Stencil = transformer::Stencil;
+using StencilPart = transformer::StencilPart;
+namespace stencil {
 using transformer::access;
 using transformer::addressOf;
 using transformer::cat;
index c42976a71c317ca3ff5791054e18a7e5a4ff4fdb..ee05b74c1a20eca62f2f15b0a7e199a9b34c5fcb 100644 (file)
@@ -21,7 +21,6 @@ using namespace ast_matchers;
 namespace {
 using ::testing::IsEmpty;
 using transformer::RewriteRule;
-using transformer::text;
 
 constexpr char KHeaderContents[] = R"cc(
   struct string {