[clang] 6e759da - [libTooling] Add Stencil constructor.

Yitzhak Mandelbaum via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 1 09:05:32 PDT 2019


Author: Yitzhak Mandelbaum
Date: 2019-11-01T11:53:14-04:00
New Revision: 6e759daf2ea891fdd624d68690cdafdadcca11c9

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

LOG: [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

Added: 
    

Modified: 
    clang/include/clang/Tooling/Transformer/Stencil.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Tooling/Transformer/Stencil.h b/clang/include/clang/Tooling/Transformer/Stencil.h
index 66d1388f9710..6ef44e5ce7ba 100644
--- a/clang/include/clang/Tooling/Transformer/Stencil.h
+++ b/clang/include/clang/Tooling/Transformer/Stencil.h
@@ -90,6 +90,7 @@ class StencilPart {
 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 @@ class Stencil {
 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);


        


More information about the cfe-commits mailing list