On Fri, Oct 26, 2012 at 5:48 PM, Eric Schulte <span dir="ltr"><<a href="mailto:schulte.eric@gmail.com" target="_blank">schulte.eric@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I've written a simple command-line code-mutation tool using the Tooling<br>
infrastructure [1]. The tooling framework handled many of the difficult<br>
portions of this task (handling compilation databases etc...) allowing<br>
me to focus on writing a RecursiveASTVisitor -- my thanks to everyone<br>
who worked on the tooling setup and on clang in general.<br></blockquote><div><br></div><div>:) </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I would now like to expose the functionality of this ASTVisitor as a C<br>
library so that I can call these functions programatically and chain<br>
multiple ASTConsumers without the overhead of multiple shell calls,<br>
repeatedly parsing of the original source, etc...<br>
<br>
Is this possible? Is this difficult? Is there a best practice for<br>
transitioning from a command-line Tooling tool to a library? Should I<br>
just look though the clang/Tooling source? Any pointers or suggestions<br>
would be greatly appreciated.<br></blockquote><div><br></div><div>I think you're the first one to go this route - one thing I notice is that you say "C library". I assume that's a requirement? In general, the way I'd go about this is:</div>
<div>- build a C++ library</div><div>- build a C wrapper that exposes the functionality</div><div><br></div><div>That's pretty much the way libclang does it (minus some stuff that's only in libclang, but we've already noticed some of that stuff would be very nice to have in a C++ layer).</div>
<div><br></div><div>Your tool is also sufficiently narrow focus currently that I think it might make sense to go into clang mainline as a library and be useful from libclang, but Doug might have a different opinion.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks,<br>
<br>
Footnotes:<br>
[1] <a href="https://github.com/eschulte/clang-mutate" target="_blank">https://github.com/eschulte/clang-mutate</a></blockquote><div><br></div><div>Nice! Looks awesome :)</div><div>/me wonders whether it would be a perfect fit for the extra-tools repository...</div>
<div><br></div><div>Cheers,</div><div>/Manuel</div><div><br></div></div></div>