@@ -5158,25 +5158,32 @@ class ConceptInfo {
5158
5158
5159
5159
llvm::DenseMap<const IdentifierInfo *, Member> Results;
5160
5160
};
5161
+
5162
+ // If \p Base is ParenListExpr, assume a chain of comma operators and pick the
5163
+ // last expr. We expect other ParenListExprs to be resolved to e.g. constructor
5164
+ // calls before here. (So the ParenListExpr should be nonempty, but check just
5165
+ // in case)
5166
+ Expr *unwrapParenList (Expr *Base) {
5167
+ if (auto *PLE = llvm::dyn_cast_or_null<ParenListExpr>(Base)) {
5168
+ if (PLE->getNumExprs () == 0 )
5169
+ return nullptr ;
5170
+ Base = PLE->getExpr (PLE->getNumExprs () - 1 );
5171
+ }
5172
+ return Base;
5173
+ }
5174
+
5161
5175
} // namespace
5162
5176
5163
5177
void Sema::CodeCompleteMemberReferenceExpr (Scope *S, Expr *Base,
5164
5178
Expr *OtherOpBase,
5165
5179
SourceLocation OpLoc, bool IsArrow,
5166
5180
bool IsBaseExprStatement,
5167
5181
QualType PreferredType) {
5182
+ Base = unwrapParenList (Base);
5183
+ OtherOpBase = unwrapParenList (OtherOpBase);
5168
5184
if (!Base || !CodeCompleter)
5169
5185
return ;
5170
5186
5171
- // Peel off the ParenListExpr by chosing the last one, as they don't have a
5172
- // predefined type.
5173
- if (auto *PLE = llvm::dyn_cast<ParenListExpr>(Base))
5174
- Base = PLE->getExpr (PLE->getNumExprs () - 1 );
5175
- if (OtherOpBase) {
5176
- if (auto *PLE = llvm::dyn_cast<ParenListExpr>(OtherOpBase))
5177
- OtherOpBase = PLE->getExpr (PLE->getNumExprs () - 1 );
5178
- }
5179
-
5180
5187
ExprResult ConvertedBase = PerformMemberExprBaseConversion (Base, IsArrow);
5181
5188
if (ConvertedBase.isInvalid ())
5182
5189
return ;
@@ -5606,14 +5613,10 @@ ProduceSignatureHelp(Sema &SemaRef, Scope *S,
5606
5613
QualType Sema::ProduceCallSignatureHelp (Scope *S, Expr *Fn,
5607
5614
ArrayRef<Expr *> Args,
5608
5615
SourceLocation OpenParLoc) {
5616
+ Fn = unwrapParenList (Fn);
5609
5617
if (!CodeCompleter || !Fn)
5610
5618
return QualType ();
5611
5619
5612
- // If we have a ParenListExpr for LHS, peel it off by chosing the last expr.
5613
- // As ParenListExprs don't have a predefined type.
5614
- if (auto *PLE = llvm::dyn_cast<ParenListExpr>(Fn))
5615
- Fn = PLE->getExpr (PLE->getNumExprs () - 1 );
5616
-
5617
5620
// FIXME: Provide support for variadic template functions.
5618
5621
// Ignore type-dependent call expressions entirely.
5619
5622
if (Fn->isTypeDependent () || anyNullArguments (Args))
0 commit comments