<div dir="ltr">Taddeus,<br><br>Maybe you will find this thread useful: [<span style="color:rgb(0,0,0);font-family:arial,helvetica,sans-serif">cfe-dev] AST modifications that apply to the binary</span><br><a href="http://lists.llvm.org/pipermail/cfe-dev/2016-November/051668.html">http://lists.llvm.org/pipermail/cfe-dev/2016-November/051668.html</a><br><br>~Jakub</div><div class="gmail_extra"><br><div class="gmail_quote">On 4 May 2017 at 13:58, Taddeus via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<div><br></div><div>I want to annotate malloc(sizeof(ty)) calls with the type in the sizeof so that I can use the information in the IR later on (in a transformation plugin). My current approach is to do a somewhat hacky source transformation, replacing the call with:</div><div>  malloc(({ ty * volatile ptr = NULL; (size_t)(ptr + 1); }))</div><div>so that I can take the pointer type and replace the size back with a constant in the IR.</div><div><br></div><div>If someone can think of a better way to do this inside a clang frontend plugin, I'm open to that, but currently I'm having issues just getting this to work. I have a working plugin that finds the sizeof expressions and a Rewriter instance that replaces them. However, I don't know how to apply the changes to the input file so that the input with be parsed again before being passed on to the codegen. There is a Reparse function in ASTUnit, but I cannot find (in the docs or online) how this is supposed to be used.</div><div>Does anyone know how to correctly use this?</div><div><br></div><div>Cheers,</div><div>Taddeüs</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><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div>Jakub Kuderski</div></div>
</div>