diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -5257,11 +5257,21 @@ // Peel off the ParenListExpr by chosing the last one, as they don't have a // predefined type. - if (auto *PLE = llvm::dyn_cast(Base)) + if (auto *PLE = llvm::dyn_cast(Base)) { + // FIXME: Get rid of this check once we are sure the ParenListExpr in here + // cannot be empty. This is assumed to ultimately be a chain of comma + // operators. We expect other ParenListExprs to be resolved to e.g. + // constructor calls before getting here. Same for OtherOpBase. + if (PLE->getNumExprs() == 0) + return; Base = PLE->getExpr(PLE->getNumExprs() - 1); + } if (OtherOpBase) { - if (auto *PLE = llvm::dyn_cast(OtherOpBase)) + if (auto *PLE = llvm::dyn_cast(OtherOpBase)) { + if (PLE->getNumExprs() == 0) + return; OtherOpBase = PLE->getExpr(PLE->getNumExprs() - 1); + } } ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow); @@ -5698,8 +5708,15 @@ // If we have a ParenListExpr for LHS, peel it off by chosing the last expr. // As ParenListExprs don't have a predefined type. - if (auto *PLE = llvm::dyn_cast(Fn)) + if (auto *PLE = llvm::dyn_cast(Fn)) { + // FIXME: Get rid of this check once we are sure the ParenListExpr in here + // cannot be empty. This is assumed to ultimately be a chain of comma + // operators. We expect other ParenListExprs to be resolved to e.g. + // constructor calls before getting here. + if (PLE->getNumExprs() == 0) + return QualType(); Fn = PLE->getExpr(PLE->getNumExprs() - 1); + } // FIXME: Provide support for variadic template functions. // Ignore type-dependent call expressions entirely.