Hi,<div><br></div><div>I'm working in an optimization tool that does some source-to-source rewritings over OpenCL kernels written in C. In former versions of my tool, I could use the Rewriter class with no problem (I was using the ReplaceText method in order to replace the text of a single Stmt with a new string specifically composed for it).</div>

<div><br></div><div>A couple of days ago, and with no apparent reason since I've not changed anything related with the replacement of source code lines (of course I have already checked that both the Stmt's I'm passing into the ReplaceText method and the replacing string are OK), some invocations to ReplaceText result in the following assertion violation:</div>

<div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="courier new, monospace">Application: <<path to LLVM>>/tools/clang/lib/Rewrite/RewriteRope.cpp:382: void<unnamed>::RopePieceBTreeLeaf::erase(unsigned int, unsigned int): Assertion `getPiece(StartPiece).size() > NumBytes' failed.<br>

Stack dump:<br>0.<span class="Apple-tab-span" style="white-space:pre">  </span><eof> parser at end of file<br>Aborted</font></blockquote></div><div><br></div><div>I'm talking about "some" invocations because not all the invocations to ReplaceText are leading to that violation. Obviously, when it appears the program is forced to abort, and there is no clue of the rewritten version of the OpenCL kernel. I've skimmed the RewriteRope.cpp file available in Clang Doxygen pages but I've not arrived at any clear conclusion, I'm not a very experienced C++ programmer and for me it's just a bunch of strange code, :(</div>

<div><br></div><div>I've tried also using InsertTextAfter instead of ReplaceText in failed invocations. In this case there is no assertion violation, the program seems to finish properly and a file with another version of the OpenCL kernel is generated, but this new version only reflects the changes made with ReplaceText that not were leading to the violation before. About all the changes that InsertTextAfter were suppose to make, there is no clue.</div>

<div><br></div><div>I'm a bit worried about this because this problem is the last hurdle I must jump in order to finish my tool...</div><div><br></div><div>Thank you so much in advance for your answers.</div><div><br>

</div><div>P.S.: Sorry for my bad English, ;)</div><div><br></div><div><br></div>