<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"></div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Jonas,</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I've updated the revision (<a href="https://reviews.llvm.org/D56933" target="_blank">https://reviews.llvm.org/D56933</a>) with two example clang tidies ported to Transformer. These are not ideal checks, because they are very particular in their handling of whitespace, but I think they're good demonstrations both of Transformers strengths and its (current) limitations. Additionally, below are to versions of simple example that isn't a tidy check yet. Please let me know what you think. </div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><div class="gmail_default"><br></div><div class="gmail_default">Also, what are the next steps towards considering these libraries for acceptance to clang? Should I put together a diff(s) for review, or is that still premature?</div></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace"> // Simplify `e.emplace_back(std::make_pair(e1, e2))` to `e.emplace_back(e1, e2)`.</font></div><div class="gmail_default"><font face="monospace, monospace"> // We elide the extra matching required to check that `e` is in a container like std::vector and that </font></div><div class="gmail_default"><font face="monospace, monospace"> // the element type is the same as that constructed by the call to make_pair. </font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace"> </font><span style="font-family:monospace,monospace">using extra_matchers::isFunctionNamed;</span></div><div class="gmail_default"><font face="monospace, monospace"> using extra_matchers::isMethodNamed; </font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace"> // Version 1</font></div><div class="gmail_default"><font face="monospace, monospace"> // This version has three metavariables -- one for the container and two for the</font></div><div class="gmail_default"><font face="monospace, monospace"> // arguments to `make_pair`.</font></div><div class="gmail_default"><font face="monospace, monospace"> ExprId Call, Arg0, Arg1;</font></div><div class="gmail_default"><span style="font-family:monospace,monospace"> auto MakePairCall =</span><br></div><div class="gmail_default"><font face="monospace, monospace"> callExpr(callee(isFunctionNamed("::std::make_pair")),</font></div><div class="gmail_default"><font face="monospace, monospace"> argumentCountIs(2), hasArgument(0, Arg0.bind()),</font></div><div class="gmail_default"><font face="monospace, monospace"> hasArgument(1, Arg1.bind()));</font></div><div class="gmail_default"><font face="monospace, monospace"> auto Rule1 = </font><span style="font-family:monospace,monospace">RewriteRule()</span></div><div class="gmail_default"><font face="monospace, monospace"> .matching(cxxMemberCallExpr(</font></div><div class="gmail_default"><font face="monospace, monospace"> callee(isMethodNamed("emplace_back")),</font></div><div class="gmail_default"><span style="font-family:monospace,monospace"> argumentCountIs(1), hasArgument(0, bind(Call, make_pair_call))))</span><br></div><div class="gmail_default"><font face="monospace, monospace"> .change(Call)</font></div><div class="gmail_default"><font face="monospace, monospace"> .replaceWith(Arg0, ",", Arg1));</font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace"> // Version 2</font></div><div class="gmail_default"><font face="monospace, monospace"> // In this version, we extract the source code of the arguments using the `arg()`</font></div><div class="gmail_default"><font face="monospace, monospace"> // stencil operator on the node bound to `Call`.</font></div><div class="gmail_default"><font face="monospace, monospace"> auto Rule2 =</font><span style="font-family:monospace,monospace"> RewriteRule()</span></div><div class="gmail_default"><font face="monospace, monospace"> .matching(cxxMemberCallExpr(</font></div><div class="gmail_default"><font face="monospace, monospace"> callee(isMethodNamed("emplace_back")), argumentCountIs(1),</font></div><div class="gmail_default"><font face="monospace, monospace"> hasArgument(0, bind(Call, callExpr(callee(isFunctionNamed(</font></div><div class="gmail_default"><font face="monospace, monospace"> "::std::make_tuple")))))))</font></div><div class="gmail_default"><font face="monospace, monospace"> .change(Call)</font></div><div class="gmail_default"><font face="monospace, monospace"> .replaceWith(tooling::stencil_generators::args(Call)));</font></div></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Thanks!</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Yitzhak</div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 18, 2019 at 4:43 PM Yitzhak Mandelbaum <<a href="mailto:yitzhakm@google.com">yitzhakm@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><div dir="ltr" style="font-family:Arial,Helvetica,sans-serif"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Thanks! I've added it to a revision (<a href="https://reviews.llvm.org/D56933" target="_blank">https://reviews.llvm.org/D56933</a>), but I wasn't sure what lists to subscribe it to (if any) given that I don't intend it yet for proper review.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I haven't ported check, but do have a demo check (using Transformer as a whole) that I can add. I'll ping the thread when that's done.</div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jan 18, 2019 at 3:19 PM Jonas Toth <<a href="mailto:development@jonas-toth.eu" target="_blank">development@jonas-toth.eu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p>Hi Yitzhak,</p>
<p>your code looks very interesting.</p>
<p>It might be a good fit for uitlity that clang-refactor can use,
too. (not sure about the state of clang-refactor though)<br>
I would be interested how your framework integrates into
clang-tidy, do you have a reference check that you ported to your
approach (i have seen some references to clang-tidy code)?</p>
<p>P.S. It might be a good idea to make your diff a full revision,
as right now the discussion feature can not be used.</p>
<p>Best, Jonas<br>
</p>
<div class="gmail-m_7143118796014398919gmail-m_5125166849334550517moz-cite-prefix">Am 18.01.19 um 19:29 schrieb Yitzhak
Mandelbaum via cfe-dev:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div dir="ltr">
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif">After some
delay, I've created a diff to accompany the doc. In
particular, here's the Stencil library, which provides for
generating code in a format-string style:</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br>
</div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif"><a href="https://reviews.llvm.org/differential/diff/182553/" target="_blank">https://reviews.llvm.org/differential/diff/182553/</a></font><br>
</div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif"><br>
</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif">Please see the tests for various examples and
the doc for more explanation.</font></div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Fri, Nov 16, 2018 at 10:22 AM Yitzhak
Mandelbaum <<a href="mailto:yitzhakm@google.com" target="_blank">yitzhakm@google.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div class="gmail_default"><font face="arial, helvetica,
sans-serif">Hi all,</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif"><br>
</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif">I have a proposal for a framework that
makes it easier to write source to source
transformations with the clang::Tooling libraries,
including clang-tidy checks.</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif"><br>
</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif">The full proposal is in this doc:</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif"><br>
</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif"><a href="https://docs.google.com/document/d/1ppw0RhjwsrbBcHYhI85pe6ISDbA6r5d00ot3N8cQWeQ/edit?usp=sharing" target="_blank">https://docs.google.com/document/d/1ppw0RhjwsrbBcHYhI85pe6ISDbA6r5d00ot3N8cQWeQ/edit?usp=sharing</a></font><br>
</div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif"><br>
</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif">From the doc:</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif">Transformer is a framework that aims to
simplify development of clang-based source-to-source
transformations. It focuses on the particular class
of transformations that act only locally — that is,
use local information about the code and make local
changes (like a syntax-aware “find-and-replace”);
and at scale — that is, will be carried out on many
source files. The target audience is users that are
comfortable with, or willing to become comfortable
with, the clang AST matchers library.<br>
</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif"><br>
</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif">I have a working prototype of this
library which I've used on small examples inside
Google. I plan to put together a patch for
reference next week, although the doc should stand
on its own.</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif"><br>
</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif">Thanks!</font></div>
<div class="gmail_default"><font face="arial, helvetica,
sans-serif">Yitzhak Mandelbaum</font></div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
<fieldset class="gmail-m_7143118796014398919gmail-m_5125166849334550517mimeAttachmentHeader"></fieldset>
<pre class="gmail-m_7143118796014398919gmail-m_5125166849334550517moz-quote-pre">_______________________________________________
cfe-dev mailing list
<a class="gmail-m_7143118796014398919gmail-m_5125166849334550517moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>
<a class="gmail-m_7143118796014398919gmail-m_5125166849334550517moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
</div>
</blockquote></div>
</blockquote></div>