<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>Le 2013/02/02 à 2:28, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Feb 1, 2013, at 1:02 , Manuel Klimek <<a href="mailto:klimek@google.com">klimek@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">On Fri, Feb 1, 2013 at 9:25 AM, Antoine Trouve <span dir="ltr"><<a href="mailto:trouve@isit.or.jp" target="_blank">trouve@isit.or.jp</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi everybody,<br>
<br>
I am now using LibTooling with the RefactoringTool to add some comments in some C codes.<br>
<br>
I am now trying to add comments after a given statement (the body of a for to say the truth);<br>
in order to detect the location of the end of a statement I use "Stmt.getLocEnd()", but I seems that its output is often inaccurate.<br>
<br>
Here are two examples, if I insert "/* HERE */" at the end location:<br>
<br>
        for(i=0; i<N/2; i++) res +=mand(i,N/4/* HERE */);<br>
        for(i=0; i<mand(N,N); i++) res /* HERE */++;<br>
<br>
I would expect the following output:<br>
<br>
        for(i=0; i<N/2; i++) res +=mand(i,N/4);/* HERE */<br>
        for(i=0; i<mand(N,N); i++) res ++;/* HERE */<br>
<br>
It looks like a bug. Am I right or did I miss something ?<br>
<br>
I found a previous recent discussion about this matter (<a href="http://clang-developers.42468.n3.nabble.com/Statements-that-end-with-td4028311.html" target="_blank">http://clang-developers.42468.n3.nabble.com/Statements-that-end-with-td4028311.html</a>), but It looks like nothing has been done.<br>
</blockquote><div><br></div><div style="">Yes, this is a known issue, and as far as I'm aware nothing has been done. We're usually working around this by looking for the next ';' token.</div><div style=""><br></div>
<div style="">I guess it's the good old "patches welcome" answer - or wait until it becomes important enough for somebody else to solve.</div></div></div></div></blockquote><br></div><div>The other issue here is that (by design) getLocEnd() doesn't actually return the SourceLocation just past the end of the statement, but the SourceLocation of the <i>start</i> of the <i>last token</i> in the statement. If you actually want the SourceLocation following the statement, you'll have to use Lexer::getLocForEndOfToken.</div><div><br></div></div></blockquote><div><br></div><div>Thank you both of you for your answer. The last token thing makes perfect sense !</div><div>Let me try that one by monday and come back to you.</div><div><br></div><div>- Antoine</div></div></body></html>