diff --git a/clang/include/clang/Tooling/Transformer/MatchConsumer.h b/clang/include/clang/Tooling/Transformer/MatchConsumer.h --- a/clang/include/clang/Tooling/Transformer/MatchConsumer.h +++ b/clang/include/clang/Tooling/Transformer/MatchConsumer.h @@ -22,8 +22,7 @@ #include "llvm/Support/Error.h" namespace clang { -namespace tooling { - +namespace transformer { /// A failable computation over nodes bound by AST matchers. /// /// The computation should report any errors though its return value (rather @@ -52,7 +51,12 @@ return (Map.find(ID) != Map.end() ? TrueC : FalseC)(Result); }; } +} // namespace transformer +namespace tooling { +// DEPRECATED: Temporary alias supporting client migration to the `transformer` +// namespace. +using transformer::ifBound; } // namespace tooling } // namespace clang #endif // LLVM_CLANG_TOOLING_TRANSFORMER_MATCH_CONSUMER_H_ 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 @@ -23,7 +23,7 @@ #include namespace clang { -namespace tooling { +namespace transformer { using RangeSelector = MatchConsumer; inline RangeSelector charRange(CharSourceRange R) { @@ -87,6 +87,25 @@ /// source), if `S` is an expansion, and `S` itself, otherwise. Corresponds to /// `SourceManager::getExpansionRange`. RangeSelector expansion(RangeSelector S); +} // namespace transformer + +namespace tooling { +// DEPRECATED: These are temporary aliases supporting client migration to the +// `transformer` namespace. +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 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 @@ -29,9 +29,8 @@ #include namespace clang { -namespace tooling { +namespace transformer { using TextGenerator = MatchConsumer; - /// Wraps a string as a TextGenerator. inline TextGenerator text(std::string M) { return [M](const ast_matchers::MatchFinder::MatchResult &) @@ -282,6 +281,24 @@ translateEdits(const ast_matchers::MatchFinder::MatchResult &Result, llvm::ArrayRef Edits); } // namespace detail +} // namespace transformer + +namespace tooling { +// DEPRECATED: These are temporary aliases supporting client migration to the +// `transformer` namespace. +using transformer::addInclude; +using transformer::applyFirst; +using transformer::change; +using transformer::insertAfter; +using transformer::insertBefore; +using transformer::makeRule; +using transformer::remove; +using transformer::text; +using transformer::RewriteRule; +using transformer::IncludeFormat; +namespace detail { +using namespace transformer::detail; +} // namespace detail } // namespace tooling } // namespace clang diff --git a/clang/include/clang/Tooling/Transformer/Stencil.h b/clang/include/clang/Tooling/Transformer/Stencil.h --- a/clang/include/clang/Tooling/Transformer/Stencil.h +++ b/clang/include/clang/Tooling/Transformer/Stencil.h @@ -31,8 +31,7 @@ #include namespace clang { -namespace tooling { - +namespace transformer { /// A stencil is represented as a sequence of "parts" that can each individually /// generate a code string based on a match result. The different kinds of /// parts include (raw) text, references to bound nodes and assorted operations @@ -133,8 +132,10 @@ std::vector Parts; }; +// // Functions for conveniently building stencils. -namespace stencil { +// + /// Convenience wrapper for Stencil::cat that can be imported with a using decl. template Stencil cat(Ts &&... Parts) { return Stencil::cat(std::forward(Parts)...); @@ -146,12 +147,6 @@ /// \returns the source corresponding to the selected range. StencilPart selection(RangeSelector Selector); -/// \returns the source corresponding to the identified node. -/// FIXME: Deprecated. Write `selection(node(Id))` instead. -inline StencilPart node(llvm::StringRef Id) { - return selection(tooling::node(Id)); -} - /// Generates the source of the expression bound to \p Id, wrapping it in /// parentheses if it may parse differently depending on context. For example, a /// binary operation is always wrapped, while a variable reference is never @@ -197,6 +192,27 @@ /// /// \returns the string resulting from calling the node's print() method. StencilPart dPrint(llvm::StringRef Id); +} // namespace transformer + +namespace tooling { +namespace stencil { +// DEPRECATED: These are temporary aliases supporting client migration to the +// `transformer` namespace. +using transformer::access; +using transformer::addressOf; +using transformer::cat; +using transformer::deref; +using transformer::dPrint; +using transformer::expression; +using transformer::ifBound; +using transformer::run; +using transformer::selection; +using transformer::text; +/// \returns the source corresponding to the identified node. +/// FIXME: Deprecated. Write `selection(node(Id))` instead. +inline transformer::StencilPart node(llvm::StringRef Id) { + return selection(tooling::node(Id)); +} } // namespace stencil } // namespace tooling } // namespace clang diff --git a/clang/include/clang/Tooling/Transformer/Transformer.h b/clang/include/clang/Tooling/Transformer/Transformer.h --- a/clang/include/clang/Tooling/Transformer/Transformer.h +++ b/clang/include/clang/Tooling/Transformer/Transformer.h @@ -30,7 +30,7 @@ /// because of macros, but doesn't fail. Note that clients are responsible /// for handling the case that independent \c AtomicChanges conflict with each /// other. - Transformer(RewriteRule Rule, ChangeConsumer Consumer) + Transformer(transformer::RewriteRule Rule, ChangeConsumer Consumer) : Rule(std::move(Rule)), Consumer(std::move(Consumer)) {} /// N.B. Passes `this` pointer to `MatchFinder`. So, this object should not @@ -42,7 +42,7 @@ void run(const ast_matchers::MatchFinder::MatchResult &Result) override; private: - RewriteRule Rule; + transformer::RewriteRule Rule; /// Receives each successful rewrites as an \c AtomicChange. ChangeConsumer Consumer; }; diff --git a/clang/lib/Tooling/Transformer/RangeSelector.cpp b/clang/lib/Tooling/Transformer/RangeSelector.cpp --- a/clang/lib/Tooling/Transformer/RangeSelector.cpp +++ b/clang/lib/Tooling/Transformer/RangeSelector.cpp @@ -20,7 +20,7 @@ #include using namespace clang; -using namespace tooling; +using namespace transformer; using ast_matchers::MatchFinder; using ast_type_traits::ASTNodeKind; @@ -104,7 +104,7 @@ return findPreviousTokenKind(EndLoc, SM, LangOpts, tok::TokenKind::l_paren); } -RangeSelector tooling::before(RangeSelector Selector) { +RangeSelector transformer::before(RangeSelector Selector) { return [Selector](const MatchResult &Result) -> Expected { Expected SelectedRange = Selector(Result); if (!SelectedRange) @@ -113,7 +113,7 @@ }; } -RangeSelector tooling::after(RangeSelector Selector) { +RangeSelector transformer::after(RangeSelector Selector) { return [Selector](const MatchResult &Result) -> Expected { Expected SelectedRange = Selector(Result); if (!SelectedRange) @@ -126,27 +126,29 @@ }; } -RangeSelector tooling::node(std::string ID) { +RangeSelector transformer::node(std::string ID) { return [ID](const MatchResult &Result) -> Expected { Expected Node = getNode(Result.Nodes, ID); if (!Node) return Node.takeError(); return Node->get() != nullptr && Node->get() == nullptr - ? getExtendedRange(*Node, tok::TokenKind::semi, *Result.Context) + ? tooling::getExtendedRange(*Node, tok::TokenKind::semi, + *Result.Context) : CharSourceRange::getTokenRange(Node->getSourceRange()); }; } -RangeSelector tooling::statement(std::string ID) { +RangeSelector transformer::statement(std::string ID) { return [ID](const MatchResult &Result) -> Expected { Expected Node = getNode(Result.Nodes, ID); if (!Node) return Node.takeError(); - return getExtendedRange(*Node, tok::TokenKind::semi, *Result.Context); + return tooling::getExtendedRange(*Node, tok::TokenKind::semi, + *Result.Context); }; } -RangeSelector tooling::range(RangeSelector Begin, RangeSelector End) { +RangeSelector transformer::range(RangeSelector Begin, RangeSelector End) { return [Begin, End](const MatchResult &Result) -> Expected { Expected BeginRange = Begin(Result); if (!BeginRange) @@ -165,11 +167,11 @@ }; } -RangeSelector tooling::range(std::string BeginID, std::string EndID) { - return tooling::range(node(std::move(BeginID)), node(std::move(EndID))); +RangeSelector transformer::range(std::string BeginID, std::string EndID) { + return transformer::range(node(std::move(BeginID)), node(std::move(EndID))); } -RangeSelector tooling::member(std::string ID) { +RangeSelector transformer::member(std::string ID) { return [ID](const MatchResult &Result) -> Expected { Expected Node = getNode(Result.Nodes, ID); if (!Node) @@ -181,7 +183,7 @@ }; } -RangeSelector tooling::name(std::string ID) { +RangeSelector transformer::name(std::string ID) { return [ID](const MatchResult &Result) -> Expected { Expected N = getNode(Result.Nodes, ID); if (!N) @@ -197,7 +199,7 @@ // `foo` for which this range will be too short. Doing so will // require subcasing `NamedDecl`, because it doesn't provide virtual // access to the \c DeclarationNameInfo. - if (getText(R, *Result.Context) != D->getName()) + if (tooling::getText(R, *Result.Context) != D->getName()) return CharSourceRange(); return R; } @@ -256,7 +258,7 @@ } } // namespace -RangeSelector tooling::statements(std::string ID) { +RangeSelector transformer::statements(std::string ID) { return RelativeSelector(std::move(ID)); } @@ -271,7 +273,7 @@ } } // namespace -RangeSelector tooling::callArgs(std::string ID) { +RangeSelector transformer::callArgs(std::string ID) { return RelativeSelector(std::move(ID)); } @@ -285,24 +287,24 @@ } } // namespace -RangeSelector tooling::initListElements(std::string ID) { +RangeSelector transformer::initListElements(std::string ID) { return RelativeSelector(std::move(ID)); } namespace { // Returns the range of the else branch, including the `else` keyword. CharSourceRange getElseRange(const MatchResult &Result, const IfStmt &S) { - return maybeExtendRange( + return tooling::maybeExtendRange( CharSourceRange::getTokenRange(S.getElseLoc(), S.getEndLoc()), tok::TokenKind::semi, *Result.Context); } } // namespace -RangeSelector tooling::elseBranch(std::string ID) { +RangeSelector transformer::elseBranch(std::string ID) { return RelativeSelector(std::move(ID)); } -RangeSelector tooling::expansion(RangeSelector S) { +RangeSelector transformer::expansion(RangeSelector S) { return [S](const MatchResult &Result) -> Expected { Expected SRange = S(Result); if (!SRange) 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 @@ -21,7 +21,7 @@ #include using namespace clang; -using namespace tooling; +using namespace transformer; using ast_matchers::MatchFinder; using ast_matchers::internal::DynTypedMatcher; @@ -29,16 +29,16 @@ using MatchResult = MatchFinder::MatchResult; -Expected> -tooling::detail::translateEdits(const MatchResult &Result, +Expected> +transformer::detail::translateEdits(const MatchResult &Result, llvm::ArrayRef Edits) { - SmallVector Transformations; + SmallVector Transformations; for (const auto &Edit : Edits) { Expected Range = Edit.TargetRange(Result); if (!Range) return Range.takeError(); llvm::Optional EditRange = - getRangeForEdit(*Range, *Result.Context); + tooling::getRangeForEdit(*Range, *Result.Context); // FIXME: let user specify whether to treat this case as an error or ignore // it as is currently done. if (!EditRange) @@ -46,7 +46,7 @@ auto Replacement = Edit.Replacement(Result); if (!Replacement) return Replacement.takeError(); - tooling::detail::Transformation T; + transformer::detail::Transformation T; T.Range = *EditRange; T.Replacement = std::move(*Replacement); Transformations.push_back(std::move(T)); @@ -54,20 +54,20 @@ return Transformations; } -ASTEdit tooling::change(RangeSelector S, TextGenerator Replacement) { +ASTEdit transformer::change(RangeSelector S, TextGenerator Replacement) { ASTEdit E; E.TargetRange = std::move(S); E.Replacement = std::move(Replacement); return E; } -RewriteRule tooling::makeRule(DynTypedMatcher M, SmallVector Edits, +RewriteRule transformer::makeRule(DynTypedMatcher M, SmallVector Edits, TextGenerator Explanation) { return RewriteRule{{RewriteRule::Case{ std::move(M), std::move(Edits), std::move(Explanation), {}}}}; } -void tooling::addInclude(RewriteRule &Rule, StringRef Header, +void transformer::addInclude(RewriteRule &Rule, StringRef Header, IncludeFormat Format) { for (auto &Case : Rule.Cases) Case.AddedIncludes.emplace_back(Header.str(), Format); @@ -103,7 +103,7 @@ // Simply gathers the contents of the various rules into a single rule. The // actual work to combine these into an ordered choice is deferred to matcher // registration. -RewriteRule tooling::applyFirst(ArrayRef Rules) { +RewriteRule transformer::applyFirst(ArrayRef Rules) { RewriteRule R; for (auto &Rule : Rules) R.Cases.append(Rule.Cases.begin(), Rule.Cases.end()); @@ -111,7 +111,7 @@ } std::vector -tooling::detail::buildMatchers(const RewriteRule &Rule) { +transformer::detail::buildMatchers(const RewriteRule &Rule) { // Map the cases into buckets of matchers -- one for each "root" AST kind, // which guarantees that they can be combined in a single anyOf matcher. Each // case is paired with an identifying number that is converted to a string id @@ -137,17 +137,17 @@ return Matchers; } -DynTypedMatcher tooling::detail::buildMatcher(const RewriteRule &Rule) { +DynTypedMatcher transformer::detail::buildMatcher(const RewriteRule &Rule) { std::vector Ms = buildMatchers(Rule); assert(Ms.size() == 1 && "Cases must have compatible matchers."); return Ms[0]; } -SourceLocation tooling::detail::getRuleMatchLoc(const MatchResult &Result) { +SourceLocation transformer::detail::getRuleMatchLoc(const MatchResult &Result) { auto &NodesMap = Result.Nodes.getMap(); auto Root = NodesMap.find(RewriteRule::RootID); assert(Root != NodesMap.end() && "Transformation failed: missing root node."); - llvm::Optional RootRange = getRangeForEdit( + llvm::Optional RootRange = tooling::getRangeForEdit( CharSourceRange::getTokenRange(Root->second.getSourceRange()), *Result.Context); if (RootRange) @@ -161,7 +161,7 @@ // Finds the case that was "selected" -- that is, whose matcher triggered the // `MatchResult`. const RewriteRule::Case & -tooling::detail::findSelectedCase(const MatchResult &Result, +transformer::detail::findSelectedCase(const MatchResult &Result, const RewriteRule &Rule) { if (Rule.Cases.size() == 1) return Rule.Cases[0]; diff --git a/clang/lib/Tooling/Transformer/Stencil.cpp b/clang/lib/Tooling/Transformer/Stencil.cpp --- a/clang/lib/Tooling/Transformer/Stencil.cpp +++ b/clang/lib/Tooling/Transformer/Stencil.cpp @@ -22,7 +22,7 @@ #include using namespace clang; -using namespace tooling; +using namespace transformer; using ast_matchers::MatchFinder; using ast_type_traits::DynTypedNode; @@ -171,13 +171,13 @@ llvm::Optional Source; switch (Data.Op) { case UnaryNodeOperator::Parens: - Source = buildParens(*E, *Match.Context); + Source = tooling::buildParens(*E, *Match.Context); break; case UnaryNodeOperator::Deref: - Source = buildDereference(*E, *Match.Context); + Source = tooling::buildDereference(*E, *Match.Context); break; case UnaryNodeOperator::Address: - Source = buildAddressOf(*E, *Match.Context); + Source = tooling::buildAddressOf(*E, *Match.Context); break; } if (!Source) @@ -193,7 +193,7 @@ auto Range = Data.Selector(Match); if (!Range) return Range.takeError(); - *Result += getText(*Range, *Match.Context); + *Result += tooling::getText(*Range, *Match.Context); return Error::success(); } @@ -204,9 +204,10 @@ return llvm::make_error(errc::invalid_argument, "Id not bound: " + Data.BaseId); if (!E->isImplicitCXXThis()) { - if (llvm::Optional S = E->getType()->isAnyPointerType() - ? buildArrow(*E, *Match.Context) - : buildDot(*E, *Match.Context)) + if (llvm::Optional S = + E->getType()->isAnyPointerType() + ? tooling::buildArrow(*E, *Match.Context) + : tooling::buildDot(*E, *Match.Context)) *Result += *S; else return llvm::make_error( @@ -250,11 +251,11 @@ } // namespace StencilPart Stencil::wrap(StringRef Text) { - return stencil::text(Text); + return transformer::text(Text); } StencilPart Stencil::wrap(RangeSelector Selector) { - return stencil::selection(std::move(Selector)); + return transformer::selection(std::move(Selector)); } void Stencil::append(Stencil OtherStencil) { @@ -271,46 +272,46 @@ return Result; } -StencilPart stencil::text(StringRef Text) { +StencilPart transformer::text(StringRef Text) { return StencilPart(std::make_shared>(Text)); } -StencilPart stencil::selection(RangeSelector Selector) { +StencilPart transformer::selection(RangeSelector Selector) { return StencilPart( std::make_shared>(std::move(Selector))); } -StencilPart stencil::dPrint(StringRef Id) { +StencilPart transformer::dPrint(StringRef Id) { return StencilPart(std::make_shared>(Id)); } -StencilPart stencil::expression(llvm::StringRef Id) { +StencilPart transformer::expression(llvm::StringRef Id) { return StencilPart(std::make_shared>( UnaryNodeOperator::Parens, Id)); } -StencilPart stencil::deref(llvm::StringRef ExprId) { +StencilPart transformer::deref(llvm::StringRef ExprId) { return StencilPart(std::make_shared>( UnaryNodeOperator::Deref, ExprId)); } -StencilPart stencil::addressOf(llvm::StringRef ExprId) { +StencilPart transformer::addressOf(llvm::StringRef ExprId) { return StencilPart(std::make_shared>( UnaryNodeOperator::Address, ExprId)); } -StencilPart stencil::access(StringRef BaseId, StencilPart Member) { +StencilPart transformer::access(StringRef BaseId, StencilPart Member) { return StencilPart( std::make_shared>(BaseId, std::move(Member))); } -StencilPart stencil::ifBound(StringRef Id, StencilPart TruePart, +StencilPart transformer::ifBound(StringRef Id, StencilPart TruePart, StencilPart FalsePart) { return StencilPart(std::make_shared>( Id, std::move(TruePart), std::move(FalsePart))); } -StencilPart stencil::run(MatchConsumer Fn) { +StencilPart transformer::run(MatchConsumer Fn) { return StencilPart( std::make_shared>>( std::move(Fn))); diff --git a/clang/lib/Tooling/Transformer/Transformer.cpp b/clang/lib/Tooling/Transformer/Transformer.cpp --- a/clang/lib/Tooling/Transformer/Transformer.cpp +++ b/clang/lib/Tooling/Transformer/Transformer.cpp @@ -21,7 +21,7 @@ using ast_matchers::MatchFinder; void Transformer::registerMatchers(MatchFinder *MatchFinder) { - for (auto &Matcher : tooling::detail::buildMatchers(Rule)) + for (auto &Matcher : transformer::detail::buildMatchers(Rule)) MatchFinder->addDynamicMatcher(Matcher, this); } @@ -29,8 +29,9 @@ if (Result.Context->getDiagnostics().hasErrorOccurred()) return; - RewriteRule::Case Case = tooling::detail::findSelectedCase(Result, Rule); - auto Transformations = tooling::detail::translateEdits(Result, Case.Edits); + transformer::RewriteRule::Case Case = + transformer::detail::findSelectedCase(Result, Rule); + auto Transformations = transformer::detail::translateEdits(Result, Case.Edits); if (!Transformations) { Consumer(Transformations.takeError()); return; @@ -38,7 +39,7 @@ if (Transformations->empty()) { // No rewrite applied (but no error encountered either). - tooling::detail::getRuleMatchLoc(Result).print( + transformer::detail::getRuleMatchLoc(Result).print( llvm::errs() << "note: skipping match at loc ", *Result.SourceManager); llvm::errs() << "\n"; return; @@ -58,10 +59,10 @@ for (const auto &I : Case.AddedIncludes) { auto &Header = I.first; switch (I.second) { - case IncludeFormat::Quoted: + case transformer::IncludeFormat::Quoted: AC.addHeader(Header); break; - case IncludeFormat::Angled: + case transformer::IncludeFormat::Angled: AC.addHeader((llvm::Twine("<") + Header + ">").str()); break; } diff --git a/clang/unittests/Tooling/RangeSelectorTest.cpp b/clang/unittests/Tooling/RangeSelectorTest.cpp --- a/clang/unittests/Tooling/RangeSelectorTest.cpp +++ b/clang/unittests/Tooling/RangeSelectorTest.cpp @@ -11,13 +11,14 @@ #include "clang/Frontend/ASTUnit.h" #include "clang/Tooling/FixIt.h" #include "clang/Tooling/Tooling.h" +#include "clang/Tooling/Transformer/SourceCode.h" #include "llvm/Support/Error.h" #include "llvm/Testing/Support/Error.h" #include "gmock/gmock.h" #include "gtest/gtest.h" using namespace clang; -using namespace tooling; +using namespace transformer; using namespace ast_matchers; namespace { @@ -40,7 +41,7 @@ }; template TestMatch matchCode(StringRef Code, M Matcher) { - auto ASTUnit = buildASTFromCode(Code); + auto ASTUnit = tooling::buildASTFromCode(Code); assert(ASTUnit != nullptr && "AST construction failed"); ASTContext &Context = ASTUnit->getASTContext(); @@ -59,7 +60,7 @@ Expected Range = Selector(Match.Result); if (!Range) return Range.takeError(); - return fixit::internal::getText(*Range, *Match.Result.Context); + return tooling::getText(*Range, *Match.Result.Context); } // Applies \p Selector to a trivial match with only a single bound node with id diff --git a/clang/unittests/Tooling/StencilTest.cpp b/clang/unittests/Tooling/StencilTest.cpp --- a/clang/unittests/Tooling/StencilTest.cpp +++ b/clang/unittests/Tooling/StencilTest.cpp @@ -16,7 +16,7 @@ #include "gtest/gtest.h" using namespace clang; -using namespace tooling; +using namespace transformer; using namespace ast_matchers; namespace { @@ -27,15 +27,6 @@ using ::testing::Eq; using ::testing::HasSubstr; using MatchResult = MatchFinder::MatchResult; -using stencil::access; -using stencil::addressOf; -using stencil::cat; -using stencil::deref; -using stencil::dPrint; -using stencil::expression; -using stencil::ifBound; -using stencil::run; -using stencil::text; // Create a valid translation-unit from a statement. static std::string wrapSnippet(StringRef StatementCode) { @@ -64,7 +55,7 @@ // `StatementCode` may contain other statements not described by `Matcher`. static llvm::Optional matchStmt(StringRef StatementCode, StatementMatcher Matcher) { - auto AstUnit = buildASTFromCode(wrapSnippet(StatementCode)); + auto AstUnit = tooling::buildASTFromCode(wrapSnippet(StatementCode)); if (AstUnit == nullptr) { ADD_FAILURE() << "AST construction failed"; return llvm::None; 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 @@ -18,9 +18,10 @@ using namespace clang; using namespace tooling; using namespace ast_matchers; - namespace { using ::testing::IsEmpty; +using transformer::RewriteRule; +using transformer::value; constexpr char KHeaderContents[] = R"cc( struct string { @@ -208,7 +209,7 @@ TEST_F(TransformerTest, AddIncludeAngled) { RewriteRule Rule = makeRule(callExpr(callee(functionDecl(hasName("f")))), change(text("other()"))); - addInclude(Rule, "clang/OtherLib.h", IncludeFormat::Angled); + addInclude(Rule, "clang/OtherLib.h", transformer::IncludeFormat::Angled); std::string Input = R"cc( int f(int x); @@ -559,7 +560,7 @@ change(name("fun"), text("DECL_RULE"))); RewriteRule Rule = applyFirst({ReplaceF1, DeclRule, ReplaceF1OrF2}); - EXPECT_EQ(tooling::detail::buildMatchers(Rule).size(), 2UL); + EXPECT_EQ(transformer::detail::buildMatchers(Rule).size(), 2UL); testRule(Rule, Input, Expected); } @@ -795,11 +796,11 @@ // rules. TEST(TransformerDeathTest, OrderedRuleTypes) { RewriteRule QualTypeRule = makeRule(qualType(), change(text("Q"))); - EXPECT_DEATH(tooling::detail::buildMatchers(QualTypeRule), + EXPECT_DEATH(transformer::detail::buildMatchers(QualTypeRule), "Matcher must be.*node matcher"); RewriteRule TypeRule = makeRule(arrayType(), change(text("T"))); - EXPECT_DEATH(tooling::detail::buildMatchers(TypeRule), + EXPECT_DEATH(transformer::detail::buildMatchers(TypeRule), "Matcher must be.*node matcher"); } #endif