================ @@ -152,3 +303,105 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &funcInfo, return ret; } + +void CIRGenFunction::emitCallArg(CallArgList &args, const clang::Expr *e, + clang::QualType argType) { + assert(argType->isReferenceType() == e->isGLValue() && + "reference binding to unmaterialized r-value!"); + + if (e->isGLValue()) { + assert(e->getObjectKind() == OK_Ordinary); + args.add(emitReferenceBindingToExpr(e), argType); + } + + bool hasAggregateEvalKind = hasAggregateEvaluationKind(argType); + + if (hasAggregateEvalKind) { + assert(!cir::MissingFeatures::opCallAggregateArgs()); + cgm.errorNYI(e->getSourceRange(), "aggregate function call argument"); + } + + args.add(emitAnyExprToTemp(e), argType); +} + +/// Similar to emitAnyExpr(), however, the result will always be accessible +/// even if no aggregate location is provided. +RValue CIRGenFunction::emitAnyExprToTemp(const Expr *e) { + assert(!cir::MissingFeatures::opCallAggregateArgs()); + + if (hasAggregateEvaluationKind(e->getType())) + cgm.errorNYI(e->getSourceRange(), "emit aggregate value to temp"); + + return emitAnyExpr(e); +} + +void CIRGenFunction::emitCallArgs( + CallArgList &args, PrototypeWrapper prototype, + llvm::iterator_range<clang::CallExpr::const_arg_iterator> argRange, + AbstractCallee callee, unsigned paramsToSkip) { + llvm::SmallVector<QualType, 16> argTypes; + + assert(!cir::MissingFeatures::opCallCallConv()); + + // First, if a prototype was provided, use those argument types. + assert(!cir::MissingFeatures::opCallVariadic()); + if (prototype.p) { + assert(!cir::MissingFeatures::opCallObjCMethod()); + + const auto *fpt = cast<const FunctionProtoType *>(prototype.p); + argTypes.assign(fpt->param_type_begin() + paramsToSkip, + fpt->param_type_end()); + } + + // If we still have any arguments, emit them using the type of the argument. + for (auto *a : llvm::drop_begin(argRange, argTypes.size())) ---------------- erichkeane wrote:
This loop could be a std::copy with predicate. https://github.com/llvm/llvm-project/pull/136810 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits