@@ -143,7 +143,8 @@ clang::Expr *getObject(clang::ASTContext &ctx, clang::Expr *object) {
143143}
144144
145145std::vector<clang::Expr *> getOperands (clang::ASTContext &ctx,
146- const clang::Expr *use) {
146+ const clang::Expr *use,
147+ unsigned arity = 0 ) {
147148 auto expr = const_cast <clang::Expr *>(RuleDecls::SkipImplicit (use));
148149 while (auto cast = llvm::dyn_cast<clang::ExplicitCastExpr>(expr)) {
149150 expr =
@@ -182,7 +183,7 @@ std::vector<clang::Expr *> getOperands(clang::ASTContext &ctx,
182183 ->IgnoreParenImpCasts ();
183184 operands.push_back (getObject (ctx, base));
184185 }
185- while (! operands.empty () &&
186+ while (operands.size () > arity &&
186187 llvm::isa<clang::CXXDefaultArgExpr>(operands.back ())) {
187188 operands.pop_back ();
188189 }
@@ -298,7 +299,7 @@ void checkCallable(clang::Sema &sema, const clang::Expr *use,
298299 }
299300 RuleDecls::Trial trial (sema);
300301 auto loc = use->getBeginLoc ();
301- auto operands = getOperands (sema.Context , use);
302+ auto operands = getOperands (sema.Context , use, rule-> getNumParams () );
302303 clang::OverloadCandidateSet set (loc, clang::OverloadCandidateSet::CSK_Normal);
303304 auto found = clang::DeclAccessPair::make (rule, clang::AS_public);
304305 if (auto tmpl = rule->getDescribedFunctionTemplate ()) {
@@ -347,7 +348,8 @@ MatchResult matchTemplate(clang::Sema &sema, const clang::Expr *use,
347348 auto &ctx = sema.Context ;
348349 auto explicit_args = getResultArgs (sema, rule, use);
349350 auto specialization =
350- deduce (sema, rule, explicit_args, getOperands (ctx, use));
351+ deduce (sema, rule, explicit_args,
352+ getOperands (ctx, use, rule->getTemplatedDecl ()->getNumParams ()));
351353 if (!specialization) {
352354 return std::nullopt ;
353355 }
0 commit comments