<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>After digging around I came to the following solution:</p>
<p><font face="Courier New">class MyFrontendAction : public
ASTFrontendAction {<br>
public:<br>
MyFrontendAction() {}<br>
void EndSourceFileAction() override {<br>
SourceManager &SM = TheRewriter.getSourceMgr();<br>
TheRewriter.getEditBuffer(SM.getMainFileID()).write(llvm::errs());<br>
<br>
clang::SourceLocation loc =
SM.getLocForStartOfFile(SM.getMainFileID());<br>
std::stringstream SSBefore;<br>
SSBefore << "#include \"myinclude.h\"\n";<br>
TheRewriter.InsertTextBefore(loc, SSBefore.str());<br>
...<br>
}<br>
</font></p>
Thanks<br>
Marcel<br>
<br>
<div class="moz-cite-prefix">Am 05.09.2017 um 13:15 schrieb Marcel
Schaible via cfe-dev:<br>
</div>
<blockquote type="cite"
cite="mid:30fad5d0-b613-cda2-bbb0-544bf7009411@schaible-consulting.de">
<pre wrap="">Hi everyone,
I am trying to add an user defined include file at the top level of q
compilation unit with a RecursiveAstVisitor and a Rewriter. Is there
something like VisitModule?
Any hints are welcome!
Thanks
Marcel
_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>