<div dir="ltr"><div>You'll probably want to take a look at libtooling:</div><a href="https://clang.llvm.org/docs/LibTooling.html">https://clang.llvm.org/docs/LibTooling.html</a><br></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 28, 2017 at 4:54 PM Marcel Schaible via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<p>Hi everyone,</p>
let's consider the example:
<p><font face="Courier New, Courier, monospace">int foo(int p) {</font></p>
<p><font face="Courier New, Courier, monospace"> if ( p)</font></p>
<p><font face="Courier New, Courier, monospace"> /* code
path#1 */<br>
</font></p>
<p><font face="Courier New, Courier, monospace"> return 0;</font></p>
<p><font face="Courier New, Courier, monospace"> else {</font></p>
<p><font face="Courier New, Courier, monospace"> /* code
path#2 */<br>
</font></p>
<p><font face="Courier New, Courier, monospace"> return 1;<br>
</font></p>
<p><font face="Courier New, Courier, monospace"> }</font></p>
<p><font face="Courier New, Courier, monospace">}<br>
</font></p>
<p>1. What is the best solution to get the string representation of
the expression of a return statement?</p>
<p>2. Because I want to perform some transformation with return
statements I have to figure out if they are enclosed in a block? <br>
</p>
<p>The example above should be transformed in something like<br>
</p>
<p><font face="Courier New, Courier, monospace">int foo(int p) {</font></p>
<p><font face="Courier New, Courier, monospace"> if ( p) { /*
<---- */<br>
</font></p>
<p><font face="Courier New, Courier, monospace"> /* do some
processing ... */<br>
</font></p>
<p><font face="Courier New, Courier, monospace"> return 0;</font></p>
<p><font face="Courier New, Courier, monospace"> } /* <--- */<br>
</font></p>
<p><font face="Courier New, Courier, monospace"> else {</font></p>
<p><font face="Courier New, Courier, monospace"> /* do some
processing ... */<br>
</font></p>
<font face="Courier New, Courier, monospace"> return 1;<br>
</font>
<p><font face="Courier New, Courier, monospace"> }</font></p>
<p><font face="Courier New, Courier, monospace">}<br>
</font></p>
Any hints or pointers are welcome.<br>
<p>Thanks</p>
<p>Marcel<br>
</p>
</div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">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/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>