<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 1, 2016 at 12:42 PM, Manman Ren via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">manmanren added a comment.<br>
<span class=""><br>
In <a href="http://reviews.llvm.org/D20844#445762" rel="noreferrer" target="_blank">http://reviews.llvm.org/D20844#445762</a>, @rjmccall wrote:<br>
<br>
> Hmm.  No, I think the original code is correct here — RangeEnd is a token range, and those are generally inclusive rather than exclusive.  The fix-it needs to be inserting at the end of the token.<br>
<br>
<br>
</span>We currently insert the fix-it here<br>
SourceLocation TypeEndLoc = TSInfo->getTypeLoc().getLocEnd();<br></blockquote><div><br></div><div>Yep, that's the bug. That source location refers to the start of the last token in the source range.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
And we call "TL.setNameEndLoc(DS.getLocEnd());" for ObjCInterfaceTypeLoc.<br>
<br>
The problem is that for annotation token, both the start and the end point to the same location. With "DS.SetRangeEnd(Tok.getAnnotationEndLoc());", the DeclSpec has the same start and end location.<br>
<br>
Is there a way to get the real end of the annotation token, since getAnnotationEndLoc returns the start location?<br></blockquote><div><br></div><div>You can use Preprocessor::getLocForEndOfToken to get the character location past the end of the token. (If you want the * to be after the space in your example, you'll need to also skip that whitespace.)<br></div></div></div></div>