Expr: check_and_promote_expr() returns IntrusivePtr

Instead of returning a pseudo-boolean integer, it now returns a
referenced object or nullptr on error.  The old API was very error
prone because of its obscure reference counting semantics.
This commit is contained in:
Max Kellermann 2020-03-06 09:39:30 +01:00
parent 78e736621c
commit 097a362c80
4 changed files with 56 additions and 46 deletions

View file

@ -1450,9 +1450,9 @@ ReturnStmt::ReturnStmt(IntrusivePtr<Expr> arg_e)
else
{
Expr* e_ = e.release();
(void) check_and_promote_expr(e_, yt);
e = {AdoptRef{}, e_};
auto promoted_e = check_and_promote_expr(e.get(), yt);
if ( promoted_e )
e = std::move(promoted_e);
}
}