This is an archive of the discontinued LLVM Phabricator instance.

FixIt: use getLocForEndOfToken to insert fix-it after a type name.
ClosedPublic

Authored by manmanren on May 31 2016, 4:44 PM.

Details

Summary

Before this fix, we will add the FixIt before the type name:
^(NSView view) to ^(*NSView view)

After this commit, fixit will change it to ^(NSView* view).

Diff Detail

Repository
rL LLVM

Event Timeline

manmanren updated this revision to Diff 59150.May 31 2016, 4:44 PM
manmanren retitled this revision from to FixIt: correctly set DeclSpec's range end for a type name annotation..
manmanren updated this object.
manmanren added a reviewer: rjmccall.
manmanren added a subscriber: cfe-commits.
compnerd accepted this revision.May 31 2016, 8:10 PM
compnerd added a reviewer: compnerd.
This revision is now accepted and ready to land.May 31 2016, 8:10 PM
rjmccall edited edge metadata.Jun 1 2016, 8:48 AM

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.

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();

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?

Thanks,
Manman

manmanren updated this revision to Diff 59296.Jun 1 2016, 3:54 PM
manmanren retitled this revision from FixIt: correctly set DeclSpec's range end for a type name annotation. to FixIt: use getLocForEndOfToken to insert fix-it after a type name..
manmanren updated this object.
manmanren edited edge metadata.

Use getLocForEndOfToken to insert fix-it after a type name instead of setting DeclSpec's range end.

This revision was automatically updated to reflect the committed changes.