This is an archive of the discontinued LLVM Phabricator instance.

[CodeComplete] Fix assertion failure
ClosedPublic

Authored by ilya-biryukov on Dec 5 2018, 8:31 AM.

Details

Summary

...that fires when running completion inside an argument of
UnresolvedMemberExpr (see the added test).

The assertion that fires is from Sema::TryObjectArgumentInitialization:

assert(FromClassification.isLValue());

This happens because Sema::AddFunctionCandidates does not account for
object types which are pointers. It ends up classifying them incorrectly.
All usages of the function outside code completion are used to run
overload resolution for operators. In those cases the object type being
passed is always a non-pointer type, so it's not surprising the function
did not expect a pointer in the object argument.

However, code completion reuses the same function and calls it with the
object argument coming from UnresolvedMemberExpr, which can be a pointer
if the member expr is an arrow ('->') access.

Extending AddFunctionCandidates to allow pointer object types does not
seem too crazy since all the functions down the call chain can properly
handle pointer object types if we properly classify the object argument
as an l-value, i.e. the classification of the implicitly dereferenced
pointer.

Diff Detail

Repository
rL LLVM

Event Timeline

ilya-biryukov created this revision.Dec 5 2018, 8:31 AM
kadircet accepted this revision.Dec 6 2018, 2:19 AM

LGTM

This revision is now accepted and ready to land.Dec 6 2018, 2:19 AM
This revision was automatically updated to reflect the committed changes.