<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 24, 2019 at 11:56 AM Jonas Toth <<a href="mailto:development@jonas-toth.eu">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,</p>
<p>one question that came to my mind because of Joel's Mail:</p>
<p>Is it possible to run in multiple passes?<br>
My use-case is adding `const` to variables that could be 'const'
but aren't. If you declare multiple variables like `int not_const,
const_variable;`<br>
the transformation requires splitting these up, first -> `int
not_const; int const_variable;` and then do the `const`
transformation -> `int not_const; const int const_variable;`.</p>
<p>I have implemented both transformations in clang-tidy (only
partially landed yet) but there is no easy way I can run them in
one check. The current workflow<br>
pretty much forces us to run clang-tidy multiple times and
converge to the final solution.</p>
<p>If your framework could give an improvement in this place, would
be awesome! And I think worth to consider anyway If we change the
way<br>
we do transformations.</p></div></blockquote><div><br></div><div>Generally, you can already do this, but it'd be outside clang-tidy. You can write a clang tool that</div><div>a) runs over the codebase and stores the "const graph"</div><div>b) load the "const graph" into memory and generate all the replacements (there's a way to create yaml replacements)</div><div>c) apply all the replacements</div><div><br></div><div> </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>Best, Jonas<br>
</p>
<div class="gmail-m_-7548564849762917817moz-cite-prefix">Am 16.11.18 um 16:22 schrieb Yitzhak
Mandelbaum via cfe-dev:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div><font face="arial, helvetica,
sans-serif">Hi all,</font></div>
<div><font face="arial, helvetica,
sans-serif"><br>
</font></div>
<div><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><font face="arial, helvetica,
sans-serif"><br>
</font></div>
<div><font face="arial, helvetica,
sans-serif">The full proposal is in this doc:</font></div>
<div><font face="arial, helvetica,
sans-serif"><br>
</font></div>
<div><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><font face="arial, helvetica,
sans-serif"><br>
</font></div>
<div><font face="arial, helvetica,
sans-serif">From the doc:</font></div>
<div><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><font face="arial, helvetica,
sans-serif"><br>
</font></div>
<div><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><font face="arial, helvetica,
sans-serif"><br>
</font></div>
<div><font face="arial, helvetica,
sans-serif">Thanks!</font></div>
<div><font face="arial, helvetica,
sans-serif">Yitzhak Mandelbaum</font></div>
</div>
</div>
</div>
<br>
<fieldset class="gmail-m_-7548564849762917817mimeAttachmentHeader"></fieldset>
<pre class="gmail-m_-7548564849762917817moz-quote-pre">_______________________________________________
cfe-dev mailing list
<a class="gmail-m_-7548564849762917817moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>
<a class="gmail-m_-7548564849762917817moz-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></div>