<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hello,</p>
<p><br>
I am doing source-to-source transformation using Clang tools. I
use a custom `ASTFrontendAction` to refactor a few things such as
the variable name by implementing visitors like `VisitVarDecl`. It
is fairly simple to save the modified buffers as new files. I can
do this by calling the proper rewriter functions at the end of the
`ASTFrontendAction::EndSourceFileAction`. More or less like this
(this one prints to the standard output):<br>
</p>
<p><br>
<blockquote type="cite"> void EndSourceFileAction() override {<br>
SourceManager &sm = rewriter.getSourceMgr();<br>
rewriter.InsertTextBefore(sm.getLocForStartOfFile(sm.getMainFileID()),
"// This file has been modified");<br>
rewriter.getEditBuffer(sm.getMainFileID()).write(llvm::outs());<br>
}</blockquote>
</p>
<p><br>
</p>
<p>My question is, how can I emit the preprocessor output (similar
behavior as clang++ -E main.cpp) at the end of my refactoring with
the modified files? Basically, I am trying to find a code that
does roughly the following:</p>
<br>
<blockquote type="cite">// For every modified file add file to
CI.getPreprocessorOpts().addRemappedFile()<br>
// Call CI.getPreprocessor().emitPreprocessorOutput();</blockquote>
<br>
<p>I am struggling to implement this. Does anybody know the right
approach to re-invoke the preprocessor to emit the preprocessor
output at the end of my `FrontEndActions`? Any suggestions of
tutorials?</p>
Thanks,<br>
rphwrck<br>
</body>
</html>