push_assignment (RETURN_VALUE_PLACE,
move_place (visit_expr (*ret.get_expr ()),
ret.get_expr ()->get_locus ()),
- ret.get_locus ());
+ ret.get_expr ()->get_locus ());
}
unwind_until (ROOT_SCOPE);
- ctx.get_current_bb ().statements.emplace_back (Statement::Kind::RETURN);
+ push_return (ret.get_locus ());
translated = INVALID_PLACE;
}
place);
}
+ void push_return (location_t location)
+ {
+ ctx.get_current_bb ().statements.emplace_back (Statement::Kind::RETURN,
+ INVALID_PLACE, location);
+ }
+
PlaceId borrow_place (PlaceId place_id, TyTy::BaseType *ty,
location_t location)
{
ctx.place_db[RETURN_VALUE_PLACE].tyty),
body.get_end_locus ());
}
- ctx.get_current_bb ().statements.emplace_back (Statement::Kind::RETURN);
+ auto return_location = body.has_expr ()
+ ? body.get_final_expr ()->get_locus ()
+ : body.get_end_locus ();
+ push_return (return_location);
}
}
};
std::unique_ptr<AbstractExpr> expr;
TyTy::BaseType *type;
// stores location of the actual expression from source code
- // currently only available when kind == Kind::ASSIGNMENT
- // FIXME: Add location for Statements other than ASSIGNMENT
+ // currently only available when kind is ASSIGNMENT | RETURN
+ // FIXME: Add location for other statement kinds
location_t location;
public:
{}
explicit Statement (Kind kind, PlaceId place = INVALID_PLACE,
- AbstractExpr *expr = nullptr,
location_t location = UNKNOWN_LOCATION)
- : kind (kind), place (place), expr (expr), location (location)
+ : kind (kind), place (place), location (location)
{}
explicit Statement (Kind kind, PlaceId place, TyTy::BaseType *type,