[PATCH] D20844: FixIt: correctly set DeclSpec's range end for a type name annotation.
Manman Ren via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 1 15:50:12 PDT 2016
> On Jun 1, 2016, at 1:18 PM, Richard Smith via cfe-commits <cfe-commits at lists.llvm.org> wrote:
>
> On Wed, Jun 1, 2016 at 12:42 PM, Manman Ren via cfe-commits <cfe-commits at lists.llvm.org <mailto:cfe-commits at lists.llvm.org>> wrote:
> manmanren added a comment.
>
> In http://reviews.llvm.org/D20844#445762 <http://reviews.llvm.org/D20844#445762>, @rjmccall wrote:
>
> > 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.
>
>
> We currently insert the fix-it here
> SourceLocation TypeEndLoc = TSInfo->getTypeLoc().getLocEnd();
>
> Yep, that's the bug. That source location refers to the start of the last token in the source range.
Thanks for the clarification!
>
> And we call "TL.setNameEndLoc(DS.getLocEnd());" for ObjCInterfaceTypeLoc.
>
> 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.
>
> Is there a way to get the real end of the annotation token, since getAnnotationEndLoc returns the start location?
>
> 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.)
I will update the patch with your suggestion.
Thanks,
Manman
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160601/9a5601e3/attachment.html>
More information about the cfe-commits
mailing list