This is an archive of the discontinued LLVM Phabricator instance.

[CodeComplete] Fix completion in the middle of ident in ctor lists.
ClosedPublic

Authored by ilya-biryukov on Mar 27 2018, 7:21 AM.

Details

Summary

The example that was broken before (^ designate completion points):

class Foo {
  Foo() : fie^ld^() {} // no completions were provided here.
  int field;
};

To fix it we don't cut off lexing after an identifier followed by code
completion token is lexed. Instead we skip the rest of identifier and
continue lexing.
This is consistent with behavior of completion when completion token is
right before the identifier.

Diff Detail

Event Timeline

ilya-biryukov created this revision.Mar 27 2018, 7:21 AM

+Alex, in case he might know someone who can review it.

aaron.ballman added inline comments.
lib/Lex/Lexer.cpp
1667–1668

You should continue to assert that CurPtr < BufferEnd in this loop, no?

  • Fixed failing assert on the end of file. Added a test for that.
ilya-biryukov added inline comments.Apr 21 2018, 1:44 AM
lib/Lex/Lexer.cpp
1667–1668

AFAIK, all buffers end with '\0', so lexer usually loops without doing bound checking, e.g. a similar loop is at Lexer.cpp:1623.

It turned out the completion token is not added when completion point is at the end of the buffer, though, fixed that.

aaron.ballman accepted this revision.Apr 23 2018, 4:26 AM

LGTM, modulo a tiny commenting nit.

lib/Lex/Lexer.cpp
1667

when completion -> when the completion

This revision is now accepted and ready to land.Apr 23 2018, 4:26 AM
ilya-biryukov marked an inline comment as done.
  • Fix the comment
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.