@@ -277,8 +277,6 @@ ExprRule::argsToBind(clang::ASTContext &ctx, const clang::Expr *expr,
277277 // The right operand of an assignment is evaluated before the left one.
278278 auto *op = clang::dyn_cast<clang::CXXOperatorCallExpr>(expr);
279279 bool right_to_left = op && op->isAssignmentOp ();
280- auto *call = clang::dyn_cast<clang::CallExpr>(expr);
281- unsigned first_arg = clang::isa<clang::CXXMemberCallExpr>(expr);
282280 std::vector<bool > bind (args.size ());
283281 bool bind_rest = false ;
284282 unsigned next_first = position;
@@ -293,10 +291,7 @@ ExprRule::argsToBind(clang::ASTContext &ctx, const clang::Expr *expr,
293291 if (arg->HasSideEffects (ctx)) {
294292 // A temporary that a reference parameter is bound to would be
295293 // materialized before the call, out of order.
296- bool materialized =
297- call && i >= first_arg && takesAddress (ctx, i, arg) &&
298- GetRefBindingTempType (ctx, call, i - first_arg).has_value ();
299- bind_rest |= uses[i] > 1 || materialized ||
294+ bind_rest |= uses[i] > 1 || takesTemporaryAddress (ctx, expr, i, arg) ||
300295 (uses[i] == 1 && first[i] > next_first);
301296 bind[i] = bind_rest;
302297 if (uses[i] == 1 ) {
@@ -318,6 +313,15 @@ bool ExprRule::takesAddress(clang::ASTContext &ctx, unsigned i,
318313 !RuleRegistry::MapsToPointer (ctx, arg->getType ());
319314}
320315
316+ bool ExprRule::takesTemporaryAddress (clang::ASTContext &ctx,
317+ const clang::Expr *expr, unsigned i,
318+ const clang::Expr *arg) const {
319+ auto *call = clang::dyn_cast<clang::CallExpr>(expr);
320+ unsigned first_arg = clang::isa<clang::CXXMemberCallExpr>(expr);
321+ return call && i >= first_arg && takesAddress (ctx, i, arg) &&
322+ GetRefBindingTempType (ctx, call, i - first_arg).has_value ();
323+ }
324+
321325void RefExprFragment::dump () const {
322326 log () << " ref_expr: " << prefix << ' \n ' ;
323327 for (auto &frag : inner) {
0 commit comments