summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYitzhak Mandelbaum <yitzhakm@google.com>2019-10-30 14:57:52 -0400
committerYitzhak Mandelbaum <yitzhakm@google.com>2019-11-01 11:53:14 -0400
commit6e759daf2ea891fdd624d68690cdafdadcca11c9 (patch)
tree188c855c30492a01a2777e5e0facdca44bfdb538
parent94c59ea8ddab9bd7dd241a56c67f98c90397b732 (diff)
downloadbcm5719-llvm-6e759daf2ea891fdd624d68690cdafdadcca11c9.tar.gz
bcm5719-llvm-6e759daf2ea891fdd624d68690cdafdadcca11c9.zip
[libTooling] Add Stencil constructor.
Summary: Adds a constructor that takes a vector with which to initialize the `Parts` field and a corresponding free function that forwards to the constructor. These definitions are needed to assist in transitioning away from `Stencil` as a class to defining it as a type alias. Reviewers: ilya-biryukov Subscribers: cfe-commits, gribozavr Tags: #clang Differential Revision: https://reviews.llvm.org/D69632
-rw-r--r--clang/include/clang/Tooling/Transformer/Stencil.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/include/clang/Tooling/Transformer/Stencil.h b/clang/include/clang/Tooling/Transformer/Stencil.h
index 66d1388f971..6ef44e5ce7b 100644
--- a/clang/include/clang/Tooling/Transformer/Stencil.h
+++ b/clang/include/clang/Tooling/Transformer/Stencil.h
@@ -90,6 +90,7 @@ private:
class Stencil {
public:
Stencil() = default;
+ Stencil(std::vector<StencilPart> Parts) : Parts(std::move(Parts)) {}
/// Composes a stencil from a series of parts.
template <typename... Ts> static Stencil cat(Ts &&... Parts) {
@@ -140,6 +141,12 @@ private:
template <typename... Ts> Stencil cat(Ts &&... Parts) {
return Stencil::cat(std::forward<Ts>(Parts)...);
}
+/// Convenience wrapper for Stencil constructor of the same type. Declaration
+/// outside of the class supports transition of `Stencil` type to an alias
+/// rather than a class.
+inline Stencil catVector(std::vector<StencilPart> Parts) {
+ return Stencil(std::move(Parts));
+}
/// \returns exactly the text provided.
StencilPart text(llvm::StringRef Text);
OpenPOWER on IntegriCloud