Author: Yitzhak Mandelbaum
Date: 2020-11-30T20:15:26Z
New Revision: fdff677a955730b3e85b870ff1b30d7f8ea5719c

URL: 
https://github.com/llvm/llvm-project/commit/fdff677a955730b3e85b870ff1b30d7f8ea5719c
DIFF: 
https://github.com/llvm/llvm-project/commit/fdff677a955730b3e85b870ff1b30d7f8ea5719c.diff

LOG: [libTooling] Remove deprecated Clang Transformer declarations

A number of declarations were leftover after the move from `clang::tooling` to
`clang::transformer`. This patch removes those declarations and upgrades the
handful of references to the deprecated declarations.

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

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
    clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
    clang/include/clang/Tooling/Transformer/RangeSelector.h
    clang/include/clang/Tooling/Transformer/RewriteRule.h
    clang/lib/Tooling/Transformer/RewriteRule.cpp
    clang/unittests/Tooling/TransformerTest.cpp

Removed: 
    


################################################################################
diff  --git 
a/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
index 87af9ea6cd5a..cd890e4837e0 100644
--- a/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
@@ -29,6 +29,7 @@ using ::clang::transformer::cat;
 using ::clang::transformer::change;
 using ::clang::transformer::makeRule;
 using ::clang::transformer::node;
+using ::clang::transformer::RewriteRule;
 
 static const char DefaultStringLikeClasses[] = "::std::basic_string;"
                                                "::std::basic_string_view;"
@@ -69,7 +70,7 @@ MakeRule(const LangOptions &LangOpts,
             hasArgument(1, cxxDefaultArgExpr())),
       onImplicitObjectArgument(expr().bind("string_being_searched")));
 
-  tooling::RewriteRule rule = applyFirst(
+  RewriteRule rule = applyFirst(
       {makeRule(binaryOperator(hasOperatorName("=="),
                                hasOperands(ignoringParenImpCasts(StringNpos),
                                            ignoringParenImpCasts(StringFind))),

diff  --git 
a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
index 536d6f8ef275..e8df4bb60071 100644
--- a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -23,6 +23,7 @@ using namespace ::clang::ast_matchers;
 using transformer::cat;
 using transformer::change;
 using transformer::IncludeFormat;
+using transformer::makeRule;
 using transformer::node;
 using transformer::RewriteRule;
 using transformer::statement;
@@ -30,14 +31,14 @@ using transformer::statement;
 // Invert the code of an if-statement, while maintaining its semantics.
 RewriteRule invertIf() {
   StringRef C = "C", T = "T", E = "E";
-  RewriteRule Rule = tooling::makeRule(
-      ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
-             hasElse(stmt().bind(E))),
-      change(statement(std::string(RewriteRule::RootID)),
-             cat("if(!(", node(std::string(C)), ")) ",
-                 statement(std::string(E)), " else ",
-                 statement(std::string(T)))),
-      cat("negate condition and reverse `then` and `else` branches"));
+  RewriteRule Rule =
+      makeRule(ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
+                      hasElse(stmt().bind(E))),
+               change(statement(std::string(RewriteRule::RootID)),
+                      cat("if(!(", node(std::string(C)), ")) ",
+                          statement(std::string(E)), " else ",
+                          statement(std::string(T)))),
+               cat("negate condition and reverse `then` and `else` branches"));
   return Rule;
 }
 
@@ -70,10 +71,9 @@ TEST(TransformerClangTidyCheckTest, Basic) {
 class IntLitCheck : public TransformerClangTidyCheck {
 public:
   IntLitCheck(StringRef Name, ClangTidyContext *Context)
-      : TransformerClangTidyCheck(tooling::makeRule(integerLiteral(),
-                                                    change(cat("LIT")),
-                                                    cat("no message")),
-                                  Name, Context) {}
+      : TransformerClangTidyCheck(
+            makeRule(integerLiteral(), change(cat("LIT")), cat("no message")),
+            Name, Context) {}
 };
 
 // Tests that two changes in a single macro expansion do not lead to conflicts
@@ -95,7 +95,7 @@ class BinOpCheck : public TransformerClangTidyCheck {
 public:
   BinOpCheck(StringRef Name, ClangTidyContext *Context)
       : TransformerClangTidyCheck(
-            tooling::makeRule(
+            makeRule(
                 binaryOperator(hasOperatorName("+"), hasRHS(expr().bind("r"))),
                 change(node("r"), cat("RIGHT")), cat("no message")),
             Name, Context) {}
@@ -122,8 +122,8 @@ Optional<RewriteRule> needsObjC(const LangOptions &LangOpts,
                                 const ClangTidyCheck::OptionsView &Options) {
   if (!LangOpts.ObjC)
     return None;
-  return tooling::makeRule(clang::ast_matchers::functionDecl(),
-                           change(cat("void changed() {}")), cat("no 
message"));
+  return makeRule(clang::ast_matchers::functionDecl(),
+                  change(cat("void changed() {}")), cat("no message"));
 }
 
 class NeedsObjCCheck : public TransformerClangTidyCheck {
@@ -147,8 +147,8 @@ Optional<RewriteRule> noSkip(const LangOptions &LangOpts,
                              const ClangTidyCheck::OptionsView &Options) {
   if (Options.get("Skip", "false") == "true")
     return None;
-  return tooling::makeRule(clang::ast_matchers::functionDecl(),
-                           changeTo(cat("void nothing();")), cat("no 
message"));
+  return makeRule(clang::ast_matchers::functionDecl(),
+                  changeTo(cat("void nothing();")), cat("no message"));
 }
 
 class ConfigurableCheck : public TransformerClangTidyCheck {
@@ -174,9 +174,8 @@ TEST(TransformerClangTidyCheckTest, DisableByConfig) {
 
 RewriteRule replaceCall(IncludeFormat Format) {
   using namespace ::clang::ast_matchers;
-  RewriteRule Rule =
-      tooling::makeRule(callExpr(callee(functionDecl(hasName("f")))),
-                        change(cat("other()")), cat("no message"));
+  RewriteRule Rule = makeRule(callExpr(callee(functionDecl(hasName("f")))),
+                              change(cat("other()")), cat("no message"));
   addInclude(Rule, "clang/OtherLib.h", Format);
   return Rule;
 }

diff  --git a/clang/include/clang/Tooling/Transformer/RangeSelector.h 
b/clang/include/clang/Tooling/Transformer/RangeSelector.h
index c6ca193123d1..f17fb8c7b5c6 100644
--- a/clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ b/clang/include/clang/Tooling/Transformer/RangeSelector.h
@@ -103,26 +103,6 @@ RangeSelector elseBranch(std::string ID);
 /// `SourceManager::getExpansionRange`.
 RangeSelector expansion(RangeSelector S);
 } // namespace transformer
-
-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;
-using transformer::charRange;
-using transformer::elseBranch;
-using transformer::expansion;
-using transformer::initListElements;
-using transformer::member;
-using transformer::name;
-using transformer::node;
-using transformer::range;
-using transformer::statement;
-using transformer::statements;
-} // namespace tooling
 } // namespace clang
 
 #endif // LLVM_CLANG_TOOLING_REFACTOR_RANGE_SELECTOR_H_

diff  --git a/clang/include/clang/Tooling/Transformer/RewriteRule.h 
b/clang/include/clang/Tooling/Transformer/RewriteRule.h
index 13d0edaf11b3..355b3249d3bc 100644
--- a/clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ b/clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -446,28 +446,6 @@ findSelectedCase(const 
ast_matchers::MatchFinder::MatchResult &Result,
                  const RewriteRule &Rule);
 } // namespace detail
 } // namespace transformer
-
-namespace tooling {
-// DEPRECATED: These are temporary aliases supporting client migration to the
-// `transformer` namespace.
-/// Wraps a string as a TextGenerator.
-using TextGenerator = transformer::TextGenerator;
-
-TextGenerator text(std::string M);
-
-using transformer::addInclude;
-using transformer::applyFirst;
-using transformer::change;
-using transformer::insertAfter;
-using transformer::insertBefore;
-using transformer::makeRule;
-using transformer::remove;
-using transformer::RewriteRule;
-using transformer::IncludeFormat;
-namespace detail {
-using namespace transformer::detail;
-} // namespace detail
-} // namespace tooling
 } // namespace clang
 
 #endif // LLVM_CLANG_TOOLING_TRANSFORMER_REWRITE_RULE_H_

diff  --git a/clang/lib/Tooling/Transformer/RewriteRule.cpp 
b/clang/lib/Tooling/Transformer/RewriteRule.cpp
index e0467d2149cc..543d014ab1a4 100644
--- a/clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ b/clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -439,7 +439,3 @@ transformer::detail::findSelectedCase(const MatchResult 
&Result,
 }
 
 const llvm::StringRef RewriteRule::RootID = ::clang::transformer::RootID;
-
-TextGenerator tooling::text(std::string M) {
-  return std::make_shared<SimpleTextGenerator>(std::move(M));
-}

diff  --git a/clang/unittests/Tooling/TransformerTest.cpp 
b/clang/unittests/Tooling/TransformerTest.cpp
index e4fcc210782f..9ef1c08a7cfa 100644
--- a/clang/unittests/Tooling/TransformerTest.cpp
+++ b/clang/unittests/Tooling/TransformerTest.cpp
@@ -21,12 +21,21 @@ using namespace clang;
 using namespace tooling;
 using namespace ast_matchers;
 namespace {
+using ::clang::transformer::addInclude;
+using ::clang::transformer::applyFirst;
+using ::clang::transformer::before;
+using ::clang::transformer::cat;
+using ::clang::transformer::changeTo;
+using ::clang::transformer::makeRule;
+using ::clang::transformer::member;
+using ::clang::transformer::name;
+using ::clang::transformer::node;
+using ::clang::transformer::remove;
+using ::clang::transformer::rewriteDescendants;
+using ::clang::transformer::RewriteRule;
+using ::clang::transformer::statement;
 using ::testing::ElementsAre;
 using ::testing::IsEmpty;
-using transformer::cat;
-using transformer::changeTo;
-using transformer::rewriteDescendants;
-using transformer::RewriteRule;
 
 constexpr char KHeaderContents[] = R"cc(
   struct string {
@@ -339,8 +348,9 @@ TEST_F(TransformerTest, NodePartNameDeclRefFailure) {
 
 TEST_F(TransformerTest, NodePartMember) {
   StringRef E = "expr";
-  RewriteRule Rule = makeRule(memberExpr(member(hasName("bad"))).bind(E),
-                              changeTo(member(std::string(E)), cat("good")));
+  RewriteRule Rule =
+      makeRule(memberExpr(clang::ast_matchers::member(hasName("bad"))).bind(E),
+               changeTo(member(std::string(E)), cat("good")));
 
   std::string Input = R"cc(
     struct S {


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to