This is an archive of the discontinued LLVM Phabricator instance.

[SemaCodeComplete] Make sure visited contexts are passed to completion results handler.
ClosedPublic

Authored by ioeric on Jul 4 2018, 1:06 AM.

Diff Detail

Event Timeline

ioeric created this revision.Jul 4 2018, 1:06 AM

Generally LG, just one comment.

lib/Sema/SemaCodeComplete.cpp
3744

ResultsBuilder's constructor accepts a CodeCompletionContext. Can we pass in the context with PreferedType there instead of reconstructing it later?
To make sure we don't miss other things (incl. any future additions) that ResultsBuilder puts into the context.

ioeric added inline comments.Jul 4 2018, 2:20 AM
lib/Sema/SemaCodeComplete.cpp
3744

The PreferedType should actually already be set in the ResultsBuilder (line 3715). In thoery, Results.getCompletionContext() should work fine here as well, but it would break some Index tests - it introduced some inconsistency in sema scoring when running with and without result caching (https://github.com/llvm-mirror/clang/blob/master/test/Index/complete-exprs.c#L35). This is probably a bug, but I'm not sure if I'm the right person to chase it :(

ilya-biryukov added inline comments.Jul 4 2018, 2:31 AM
lib/Sema/SemaCodeComplete.cpp
3744

What kind of inconsistencies? Maybe we should just update the CHECKS in the test?

ilya-biryukov added inline comments.Jul 4 2018, 2:43 AM
lib/Sema/SemaCodeComplete.cpp
3744

After chatting offline: it seems passing in the context that has the preferred type set into ResultsBuilder saves us from check failures.
The fact that ResultsBuilder also has setPreferrredType, which can be different from the one in the CodeCompletionContext is still confusing, but that's unrelated to the problem at hand.

ioeric updated this revision to Diff 154077.Jul 4 2018, 2:45 AM
  • Addressed review comment.
ioeric added inline comments.Jul 4 2018, 2:46 AM
lib/Sema/SemaCodeComplete.cpp
3744

Sounds good. Thanks!

This revision is now accepted and ready to land.Jul 4 2018, 3:02 AM
This revision was automatically updated to reflect the committed changes.