<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style='font-size:10pt;font-family:Verdana,Arial,Helvetica,sans-serif;'><div>Hello<br></div><div><br></div><div>There was an email on this list about my question earlier in January:<br></div><div><br></div><div>http://lists.llvm.org/pipermail/cfe-dev/2015-January/040760.html<br></div><div><br></div><div>But it contained no specific information about how to do it, and I couldn't figure it out based on the docs.<br></div><div><br></div><div>My problem is:<br><br>I have a source-to-source transformation tool, built using AstMatchers/Rewriter. It's perfect when I want to compile something with gcc (I can transform the source with it, and run gcc on the modified source), and also works with clang, but I thought it could be integrated with it even better: a clang plugin, which rewrites the source, but instead of saving it to a file, clang just could reparse the modifications from the memory buffer and compile it...<br><br>So I have a PluginASTAction, and a Rewriter member, containing everything I modified. <br><br> * I tried the solution used by tracer (link found in the same conversation), saving the modification to the DefaultOutputFile. That overwrites the original file on the disk, and doesn't reload it - the modification will be only visible during the next execution<br> * I also found ASTUnit::Reparse, which is accessible from any FrontendAction, but I only succeeded in causing segmentation faults with it - the function itself isn't used by clang itself, and I found no plugins / projects using it with google<br> * I could write a standalone program which transforms the source, saves it to a temporary file, runs clang with it, and deletes the temporary file... but I hope it can be solved in a better way.<br><br>(I read that the recommended way is just adding attributes to the AST and changing the IR, but that would require creating and maintaining two version of my tool)<br><br>My questions:<br> * is this possible at all, with a plugin?<br> * If it is, the solution is Reparse and I'm just doing something wrong, or something entirely different?</div><div><br></div></div></body></html>