<div dir="auto">Hi Andrew,<div dir="auto"><br></div><div dir="auto">white space is a job for clang-format. You can do your rewriting and apply it afterwards to get nice looking code.</div></div><div class="gmail_extra"><br><div class="gmail_quote">Am 13.12.2017 6:32 vorm. schrieb "Andrew Gozillon via cfe-dev" <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>>:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div id="m_-2833966386067616039divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">I am currently playing around with a Clang Libtool and I was wondering if there was a way to make the Clang Rewriter remove white space or if there is another utility class that can do this? For example I have an arbitrary
set of template parameters:</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">template <typename X, typename Y></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">And I wish to remove the first template parameter using the Rewriter in this case to modify the source code. To do this I remove the typename X and the comma. However, the result ends up like:</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">template < typename Y></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Which contains some unsightly white space! This persists even if I increase the SourceRange to just before the t of typename Y. So it seems to be ignoring the space.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">So in essence is there a way to make the Rewriter consider white space for removal or is there an alternative tool or method (like using a function of Clangs AST) to avoid this? At the moment I work around this by injecting
an arbitrary character in the empty space and then I delete it. Which works, but doesn't seem like the ideal solution. </p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Sorry if this is a silly question and t<span style="font-size:12pt">hank you very much for everyone's time. </span></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Best Regards,</p>
<p style="margin-top:0;margin-bottom:0">Andrew </p>
</div>
</div>
<br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div></div>