[PATCH] D69613: [libTooling] Simplify type structure of `Stencil`s.
Yitzhak Mandelbaum via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 30 05:46:14 PDT 2019
ymandel created this revision.
ymandel added a reviewer: gribozavr.
Herald added a project: clang.
Currently, stencils are defined as a sequence of `StencilParts`. This
differentiation adds an unneeded layer of complexity to the definition of
Stencils. This change significantly simplifies the type structure: a stencil is
now conceptually any object implementing `StencilInterface` and `Stencil` is
just an alias for pointers to this interface.
To account for the sequencing that was supported by the old `Stencil` type, we
introduce a sequencing class that implements `StencilInterface`. That is,
sequences are just another kind of Stencil and no longer have any special
status.
Corresponding to this change in the type structure, we change the way `cat` is
used (and defined). `cat` bundles multiple features: it builds a stencil from a
sequence of subcomponents and admits multiple different types for its arguments,
while coercing them into the right type. Previously, `cat` was also used to
coerce a single `StencilPart` into a `Stencil`. With that distinction gone, many
uses of `cat` (e.g. in the tests) are unnecessary and have, therefore, been
removed.
Finally, we expose the "coercion" functionality with the first-class function
`makeStencil`, which was, previously, the private method `wrap`. This way, other
functions with Stencil-typed arguments can leverage `makeStencil`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D69613
Files:
clang/include/clang/Tooling/Transformer/Stencil.h
clang/lib/Tooling/Transformer/Stencil.cpp
clang/unittests/Tooling/StencilTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69613.227071.patch
Type: text/x-patch
Size: 30437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191030/f8e45885/attachment-0001.bin>
More information about the cfe-commits
mailing list