llvm-project/clang/lib/Sema
Ilya Biryukov 143a9e0b12 [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

llvm-svn: 348590
2018-12-07 13:17:52 +00:00
..
AnalysisBasedWarnings.cpp Revert "Revert r347417 "Re-Reinstate 347294 with a fix for the failures."" 2018-11-30 23:41:18 +00:00
CMakeLists.txt Fix llvm-clang-x86_64-expensive-checks-win build by setting bigobj flag. 2018-10-05 12:33:57 +00:00
CodeCompleteConsumer.cpp [CodeComplete] Cleanup access checking in code completion 2018-12-03 13:29:17 +00:00
CoroutineStmtBuilder.h Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
DeclSpec.cpp [OpenCL] Enable address spaces for references in C++ 2018-11-16 16:22:56 +00:00
DelayedDiagnostic.cpp Remove trailing space 2018-07-30 19:24:48 +00:00
IdentifierResolver.cpp [AST] Various optimizations + refactoring in DeclarationName(Table) 2018-09-21 12:53:22 +00:00
JumpDiagnostics.cpp Port getLocStart -> getBeginLoc 2018-08-09 21:08:08 +00:00
MultiplexExternalSemaSource.cpp Remove trailing space 2018-07-30 19:24:48 +00:00
ParsedAttr.cpp Allow a double-underscore spelling of Clang attributes using double square bracket syntax. 2018-11-09 19:37:18 +00:00
Scope.cpp Revert r335019 "Update NRVO logic to support early return (Attempt 2)" 2018-06-19 05:35:30 +00:00
ScopeInfo.cpp Distinguish `__block` variables that are captured by escaping blocks 2018-10-01 21:51:28 +00:00
Sema.cpp [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension 2018-11-08 11:25:41 +00:00
SemaAccess.cpp [CodeComplete] Fix a crash in access checks of inner classes 2018-12-05 17:38:39 +00:00
SemaAttr.cpp Revert "Revert "Support for groups of attributes in #pragma clang attribute"" 2018-10-29 17:38:42 +00:00
SemaCUDA.cpp [NFC] Rename clang::AttributeList to clang::ParsedAttr 2018-07-13 15:07:47 +00:00
SemaCXXScopeSpec.cpp Clean up and simplify RequireCompleteType. 2018-08-07 21:35:41 +00:00
SemaCast.cpp Revert "Revert r347417 "Re-Reinstate 347294 with a fix for the failures."" 2018-11-30 23:41:18 +00:00
SemaChecking.cpp [Hexagon] Add intrinsics for Hexagon V66 2018-12-05 22:03:04 +00:00
SemaCodeComplete.cpp [CodeComplete] Fix a crash in access checks of inner classes 2018-12-05 17:38:39 +00:00
SemaConsumer.cpp
SemaCoroutine.cpp [AST] Store the expressions in ParenListExpr in a trailing array 2018-11-20 16:20:40 +00:00
SemaDecl.cpp Diagnose friend function template redefinitions. 2018-12-06 09:35:04 +00:00
SemaDeclAttr.cpp [attributes] Add an attribute os_consumes_this, with similar semantics to ns_consumes_self 2018-12-06 22:06:59 +00:00
SemaDeclCXX.cpp Revert "Revert r347417 "Re-Reinstate 347294 with a fix for the failures."" 2018-11-30 23:41:18 +00:00
SemaDeclObjC.cpp [Sema] Push and Pop Expression Evaluation Context Records at the start and end of function definitions 2018-12-06 00:10:36 +00:00
SemaExceptionSpec.cpp Create ConstantExpr class 2018-10-31 03:48:47 +00:00
SemaExpr.cpp [Sema/Attribute] Check for noderef attribute 2018-12-06 01:05:54 +00:00
SemaExprCXX.cpp [Sema] Provide -fvisibility-global-new-delete-hidden option 2018-12-04 03:25:25 +00:00
SemaExprMember.cpp [Sema/Attribute] Check for noderef attribute 2018-12-06 01:05:54 +00:00
SemaExprObjC.cpp NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects) 2018-10-30 20:31:30 +00:00
SemaFixItUtils.cpp [Sema] Revert r329346 because of memory sanitizer failures. 2018-04-05 22:15:42 +00:00
SemaInit.cpp [Sema/Attribute] Check for noderef attribute 2018-12-06 01:05:54 +00:00
SemaLambda.cpp NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects) 2018-10-30 20:31:30 +00:00
SemaLookup.cpp Use llvm::{all,any,none}_of instead std::{all,any,none}_of. NFC 2018-10-20 17:53:42 +00:00
SemaObjCProperty.cpp Add -Wobjc-property-assign-on-object-type. 2018-09-05 19:02:00 +00:00
SemaOpenMP.cpp Revert "Revert r347417 "Re-Reinstate 347294 with a fix for the failures."" 2018-11-30 23:41:18 +00:00
SemaOverload.cpp [CodeComplete] Fix assertion failure 2018-12-07 13:17:52 +00:00
SemaPseudoObject.cpp Port getLocStart -> getBeginLoc 2018-08-09 21:08:08 +00:00
SemaStmt.cpp Revert "Revert r347417 "Re-Reinstate 347294 with a fix for the failures."" 2018-11-30 23:41:18 +00:00
SemaStmtAsm.cpp Revert "Revert r347417 "Re-Reinstate 347294 with a fix for the failures."" 2018-11-30 23:41:18 +00:00
SemaStmtAttr.cpp Move LoopHint.h from Sema to Parse 2018-11-28 04:36:31 +00:00
SemaTemplate.cpp [WIP][Sema] Improve static_assert diagnostics for type traits. 2018-12-04 07:59:57 +00:00
SemaTemplateDeduction.cpp Revert "Revert r347417 "Re-Reinstate 347294 with a fix for the failures."" 2018-11-30 23:41:18 +00:00
SemaTemplateInstantiate.cpp Fix clang -Wimplicit-fallthrough warnings across llvm, NFC 2018-11-01 19:54:45 +00:00
SemaTemplateInstantiateDecl.cpp Diagnose friend function template redefinitions. 2018-12-06 09:35:04 +00:00
SemaTemplateVariadic.cpp Fix clang -Wimplicit-fallthrough warnings across llvm, NFC 2018-11-01 19:54:45 +00:00
SemaType.cpp [Sema/Attribute] Check for noderef attribute 2018-12-06 01:05:54 +00:00
TreeTransform.h [OpenCL] Diagnose conflicting address spaces in templates. 2018-12-05 17:02:22 +00:00
TypeLocBuilder.cpp
TypeLocBuilder.h Remove trailing space 2018-07-30 19:24:48 +00:00