<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Feb 21, 2011, at 12:35 PM, Gabriel Martinez wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">I have been working on a source-to-source translator using Clang. I have created a Clang plugin with my own ASTConsumer that mainly uses the Rewriter class for performing code transformations. Just had a quick question.<br>
<br>I am trying to insert some code at the top of the main method, before any other statements. To do this I start by getting the location of the left brace using CompoundStmts getLBracLoc method. This works fine, but when I then try to insert text after that location with Rewriter's InsertTextAfter, it inserts it <i>before</i> the brace. Is this an expected behavior? </blockquote><div><br></div><div>Yes, insertion inserts before the beginning of the source location.</div><br><blockquote type="cite">If so, any recommendations on how to accomplish what I'm trying to do?<br></blockquote></div><div><br></div>You want Preprocessor::getLocForEndOfToken().<div><br><div><span class="Apple-tab-span" style="white-space:pre">       </span>- Doug</div></div></body></html>