From a8b7a4a698c9d61b49561497b822d2599986f3c6 Mon Sep 17 00:00:00 2001 From: Valentyn Yukhymenko Date: Sat, 10 Aug 2024 00:18:33 +0100 Subject: [PATCH] more optimal exclusion of object argument Signed-off-by: Valentyn Yukhymenko --- clang/lib/Sema/Metafunctions.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/clang/lib/Sema/Metafunctions.cpp b/clang/lib/Sema/Metafunctions.cpp index 0ea6e2c3cfdbb1..809f9c737d0387 100644 --- a/clang/lib/Sema/Metafunctions.cpp +++ b/clang/lib/Sema/Metafunctions.cpp @@ -4598,9 +4598,8 @@ bool reflect_invoke(APValue &Result, Sema &S, EvalFn Evaluator, TemplateDeductionResult Result = S.DeduceTemplateArguments( FTD, &ExplicitTAListInfo, - exclude_first_arg - ? SmallVector(ArgExprs.begin() + 1, ArgExprs.end()) - : ArgExprs, + ArrayRef(ArgExprs.begin() + (exclude_first_arg ? 1 : 0), + ArgExprs.end()), Specialization, Info, false, true, QualType(), Expr::Classification(), [](ArrayRef) { return false; }); if (Result != TemplateDeductionResult::Success) @@ -4633,9 +4632,10 @@ bool reflect_invoke(APValue &Result, Sema &S, EvalFn Evaluator, CXXConstructionKind::Complete, Range); } else { auto *FnExpr = FnRefExpr; - auto FnArgExprs = ArgExprs; + bool exclude_first_arg = false; if (DRE && is_nonstatic_member_function(DRE->getDecl())) { + exclude_first_arg = true; auto *MD = cast(DRE->getDecl()); if (ArgExprs.size() < 1) { @@ -4690,12 +4690,13 @@ bool reflect_invoke(APValue &Result, Sema &S, EvalFn Evaluator, } FnExpr = MemberAccessResult.get(); - // exclude first argument because it's an object - FnArgExprs = {ArgExprs.begin() + 1, ArgExprs.end()}; } - ER = S.ActOnCallExpr(S.getCurScope(), FnExpr, Range.getBegin(), - FnArgExprs, Range.getEnd(), /*ExecConfig=*/nullptr); + ER = S.ActOnCallExpr( + S.getCurScope(), FnExpr, Range.getBegin(), + MutableArrayRef(ArgExprs.begin() + (exclude_first_arg ? 1 : 0), + ArgExprs.end()), + Range.getEnd(), /*ExecConfig=*/nullptr); } }