diff --git a/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp b/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp --- 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::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 @@ 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 --- a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp @@ -23,6 +23,7 @@ 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 @@ // 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 --- a/clang/include/clang/Tooling/Transformer/RangeSelector.h +++ b/clang/include/clang/Tooling/Transformer/RangeSelector.h @@ -103,26 +103,6 @@ /// `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 --- a/clang/include/clang/Tooling/Transformer/RewriteRule.h +++ b/clang/include/clang/Tooling/Transformer/RewriteRule.h @@ -446,28 +446,6 @@ 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 --- a/clang/lib/Tooling/Transformer/RewriteRule.cpp +++ b/clang/lib/Tooling/Transformer/RewriteRule.cpp @@ -439,7 +439,3 @@ } const llvm::StringRef RewriteRule::RootID = ::clang::transformer::RootID; - -TextGenerator tooling::text(std::string M) { - return std::make_shared(std::move(M)); -} diff --git a/clang/unittests/Tooling/TransformerTest.cpp b/clang/unittests/Tooling/TransformerTest.cpp --- a/clang/unittests/Tooling/TransformerTest.cpp +++ b/clang/unittests/Tooling/TransformerTest.cpp @@ -21,12 +21,21 @@ 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, 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 {