Hi,<br>I'm facing strange bug with Rewriter::InsertText.<br>Here is the code:<br><br>void RewritingPass::Initialize(ASTContext &context)<br>{<br> this->context = &context;<br> SourceLocation L;<br> mainFileId = context.getSourceManager().getMainFileID();<br>
rewriter = new Rewriter(context.getSourceManager(), context.getLangOptions());<br> const llvm::StringRef preamble(getPreamble());<br> if (preamble.size() > 0)<br> rewriter->InsertText(context.getSourceManager().getLocForStartOfFile(mainFileId), preamble, true);<br>
}<br><br>const std::string CastRewritePass::getPreamble() const<br>{ <br> return " /* cast rewrite pass */\n\n";<br>}<br><br>after execution of RewritingPass::Initialize preamble changed it's not /* cast rewrite pass*/, but 0\230\bast rewrite pass*/.<br>
I found a solvation - use not string in getPreamble, but StringRef. If i do so, it works ok.<br><br>Sergey<br>