<div dir="ltr">Thanks for response!<div>Yes, this was my impression that I will have to track dependencies and merge them myself.   </div><div><br></div><div>So I will start with simplest option of running a tool multiple times.  And If it works will later look on single-pass solution.</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">2017-09-28 1:10 GMT-07:00 Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><span class=""><div dir="ltr">On Wed, Sep 27, 2017 at 8:06 PM Roman Popov via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">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 dir="ltr">Hi all,<div>I need to write a tool that will convert stackful coroutine to stackless. One of the required refactorings is inlining all functions that call yield into a coroutine body. </div><div><br></div><div>Here is an example of required refactoring:</div><div><br></div><div>Input source code:</div><div><br></div><div><font face="monospace, monospace">void foo() { /*foo*/ yield(); }</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">void bar() { /*bar*/  foo(); }</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">void coroutine_body() { </font></div><div><font face="monospace, monospace">  bar();</font></div><div><font face="monospace, monospace">}</font></div><div><br></div><div>Expected output code from tool:</div><div><br></div><div><div><font face="monospace, monospace">void coroutine_body() {</font></div><div><font face="monospace, monospace">   </font><span style="font-family:monospace,monospace">/*bar*/ </span></div><div><span style="font-family:monospace,monospace">   /*foo*/</span></div><div><span style="font-family:monospace,monospace">   yield();</span></div><div><span style="font-family:monospace,monospace">}</span><br></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><div>So when I run the tool it will create two conflicting replacements:  </div><div><ul><li>inline foo into bar<br></li><li>inline bar into coroutine_body</li></ul><div><br></div></div></div><div>Is it possible to apply them one after another using current Clang libraries?  Or it is not supported out-of-the-box and I should better run tool N times to inline all functions one-by-one without generating conflicting replacements? </div></div></blockquote><div><br></div></span><div>We do have Replacements::merge(), but the merged replacements need to be relative to the new code after applying the original replacements, so that's not fully helping.</div><div>I think running the tool multiple times is probably simplest, but it's also possible to build up the dependency chain of your replacements yourself, and then creating one large replacement in the end from the dep tree.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Thanks,</div><div>Roman</div></div>
______________________________<wbr>_________________<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/<wbr>mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div>
</blockquote></div><br></div></div>