]> granicus.if.org Git - clang/commit
[CodeComplete] Fix assertion failure
authorIlya Biryukov <ibiryukov@google.com>
Fri, 7 Dec 2018 13:17:52 +0000 (13:17 +0000)
committerIlya Biryukov <ibiryukov@google.com>
Fri, 7 Dec 2018 13:17:52 +0000 (13:17 +0000)
commitecb70d1e9182f70e044f037e5e225c96dd06ef8f
tree6572e43db867b8abd164a3bd1421ad3a88690797
parent6ad12e250ea6f67f420c767d1181aee7211592ec
[CodeComplete] Fix assertion failure

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.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D55331

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348590 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaOverload.cpp
test/CodeCompletion/signatures-crash.cpp [new file with mode: 0644]