ymandel created this revision. ymandel added a reviewer: gribozavr. Herald added a project: clang. ymandel added a parent revision: D69613: [libTooling] Simplify type structure of `Stencil`s..
Changes `clang::transformer::access` to also support `RangeSelector` as the second argument. This change makes `access` consistent with `cat` in that it will accept text, `RangeSelector` or `Stencil`. The plan is for all Stencil arguments to be supported in this way to provide a uniform user experience for Stencil arguments. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D69625 Files: clang/include/clang/Tooling/Transformer/Stencil.h clang/unittests/Tooling/StencilTest.cpp Index: clang/unittests/Tooling/StencilTest.cpp =================================================================== --- clang/unittests/Tooling/StencilTest.cpp +++ clang/unittests/Tooling/StencilTest.cpp @@ -396,7 +396,7 @@ } TEST(StencilToStringTest, AccessOpSelector) { - auto S = access("Id", selection(name("otherId"))); + auto S = access("Id", name("otherId")); StringRef Expected = R"repr(access("Id", selection(...)))repr"; EXPECT_EQ(S->toString(), Expected); } Index: clang/include/clang/Tooling/Transformer/Stencil.h =================================================================== --- clang/include/clang/Tooling/Transformer/Stencil.h +++ clang/include/clang/Tooling/Transformer/Stencil.h @@ -112,8 +112,8 @@ /// `e->m`, when e is a pointer, `e2->m` when e = `*e2` and `e.m` otherwise. /// Additionally, `e` is wrapped in parentheses, if needed. Stencil access(llvm::StringRef BaseId, Stencil Member); -inline Stencil access(llvm::StringRef BaseId, llvm::StringRef Member) { - return access(BaseId, text(Member)); +template <typename T> Stencil access(llvm::StringRef BaseId, T &&Member) { + return access(BaseId, makeStencil(std::forward<T>(Member))); } /// Chooses between the two stencil parts, based on whether \p ID is bound in
Index: clang/unittests/Tooling/StencilTest.cpp =================================================================== --- clang/unittests/Tooling/StencilTest.cpp +++ clang/unittests/Tooling/StencilTest.cpp @@ -396,7 +396,7 @@ } TEST(StencilToStringTest, AccessOpSelector) { - auto S = access("Id", selection(name("otherId"))); + auto S = access("Id", name("otherId")); StringRef Expected = R"repr(access("Id", selection(...)))repr"; EXPECT_EQ(S->toString(), Expected); } Index: clang/include/clang/Tooling/Transformer/Stencil.h =================================================================== --- clang/include/clang/Tooling/Transformer/Stencil.h +++ clang/include/clang/Tooling/Transformer/Stencil.h @@ -112,8 +112,8 @@ /// `e->m`, when e is a pointer, `e2->m` when e = `*e2` and `e.m` otherwise. /// Additionally, `e` is wrapped in parentheses, if needed. Stencil access(llvm::StringRef BaseId, Stencil Member); -inline Stencil access(llvm::StringRef BaseId, llvm::StringRef Member) { - return access(BaseId, text(Member)); +template <typename T> Stencil access(llvm::StringRef BaseId, T &&Member) { + return access(BaseId, makeStencil(std::forward<T>(Member))); } /// Chooses between the two stencil parts, based on whether \p ID is bound in
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits