Fix -Wredundant-move and -Wdeprecated-copy warnings (#6663)

* Do not move result at end of function

This makes GCC 9.1.2 happy with the active -Wredundant-move warning.
Indeed, such moving of local variables or local arguments before
returning is unnecessary and prevents the compiler from copy elision
optimization.
This commit is contained in:
Nicholas Guriev 2019-11-12 18:15:34 +03:00 committed by John Preston
parent a196b0aba7
commit 793862bee6
34 changed files with 60 additions and 61 deletions

View File

@ -1148,7 +1148,7 @@ object_ptr<Ui::BoxContent> ProxiesBoxController::create() {
for (const auto &item : _list) { for (const auto &item : _list) {
updateView(item); updateView(item);
} }
return std::move(result); return result;
} }
auto ProxiesBoxController::findById(int id) -> std::vector<Item>::iterator { auto ProxiesBoxController::findById(int id) -> std::vector<Item>::iterator {

View File

@ -768,7 +768,7 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
FocusAtEnd(question); FocusAtEnd(question);
}, lifetime()); }, lifetime());
return std::move(result); return result;
} }
void CreatePollBox::prepare() { void CreatePollBox::prepare() {

View File

@ -223,7 +223,7 @@ object_ptr<Ui::RpWidget> SetupAbout(
tr::now, tr::now,
Ui::Text::WithEntities); Ui::Text::WithEntities);
}()); }());
return std::move(about); return about;
} }
object_ptr<Ui::RpWidget> SetupFooter( object_ptr<Ui::RpWidget> SetupFooter(

View File

@ -1786,7 +1786,7 @@ std::unique_ptr<PeerListRow> ParticipantsBoxController::createRow(
row->setActionLink(tr::lng_profile_kick(tr::now)); row->setActionLink(tr::lng_profile_kick(tr::now));
} }
} }
return std::move(row); return row;
} }
auto ParticipantsBoxController::computeType( auto ParticipantsBoxController::computeType(
@ -1931,7 +1931,7 @@ auto ParticipantsBoxSearchController::saveState() const
result->offset = _offset; result->offset = _offset;
result->allLoaded = _allLoaded; result->allLoaded = _allLoaded;
result->wasLoading = (_requestId != 0); result->wasLoading = (_requestId != 0);
return std::move(result); return result;
} }
void ParticipantsBoxSearchController::restoreState( void ParticipantsBoxSearchController::restoreState(

View File

@ -478,7 +478,7 @@ object_ptr<Ui::RpWidget> Controller::createTitleEdit() {
[=] { submitTitle(); }); [=] { submitTitle(); });
_controls.title = result->entity(); _controls.title = result->entity();
return std::move(result); return result;
} }
object_ptr<Ui::RpWidget> Controller::createDescriptionEdit() { object_ptr<Ui::RpWidget> Controller::createDescriptionEdit() {
@ -512,7 +512,7 @@ object_ptr<Ui::RpWidget> Controller::createDescriptionEdit() {
[=] { submitDescription(); }); [=] { submitDescription(); });
_controls.description = result->entity(); _controls.description = result->entity();
return std::move(result); return result;
} }
object_ptr<Ui::RpWidget> Controller::createManageGroupButtons() { object_ptr<Ui::RpWidget> Controller::createManageGroupButtons() {
@ -526,7 +526,7 @@ object_ptr<Ui::RpWidget> Controller::createManageGroupButtons() {
fillManageSection(); fillManageSection();
return std::move(result); return result;
} }
object_ptr<Ui::RpWidget> Controller::createStickersEdit() { object_ptr<Ui::RpWidget> Controller::createStickersEdit() {
@ -564,7 +564,7 @@ object_ptr<Ui::RpWidget> Controller::createStickersEdit() {
Ui::show(Box<StickersBox>(channel), Ui::LayerOption::KeepOther); Ui::show(Box<StickersBox>(channel), Ui::LayerOption::KeepOther);
}); });
return std::move(result); return result;
} }
bool Controller::canEditInformation() const { bool Controller::canEditInformation() const {

View File

@ -364,7 +364,7 @@ object_ptr<Ui::RpWidget> Controller::createUsernameEdit() {
const auto shown = (_controls.privacy->value() == Privacy::HasUsername); const auto shown = (_controls.privacy->value() == Privacy::HasUsername);
result->toggle(shown, anim::type::instant); result->toggle(shown, anim::type::instant);
return std::move(result); return result;
} }
void Controller::privacyChanged(Privacy value) { void Controller::privacyChanged(Privacy value) {
@ -630,7 +630,7 @@ object_ptr<Ui::RpWidget> Controller::createInviteLinkEdit() {
observeInviteLink(); observeInviteLink();
return std::move(result); return result;
} }
void Controller::refreshEditInviteLink() { void Controller::refreshEditInviteLink() {
@ -692,7 +692,7 @@ object_ptr<Ui::RpWidget> Controller::createInviteLinkCreate() {
observeInviteLink(); observeInviteLink();
return std::move(result); return result;
} }
void Controller::refreshCreateInviteLink() { void Controller::refreshCreateInviteLink() {

View File

@ -404,8 +404,7 @@ BoxController::Row *BoxController::rowForItem(not_null<const HistoryItem*> item)
std::unique_ptr<PeerListRow> BoxController::createRow( std::unique_ptr<PeerListRow> BoxController::createRow(
not_null<HistoryItem*> item) const { not_null<HistoryItem*> item) const {
auto row = std::make_unique<Row>(item); return std::make_unique<Row>(item);
return std::move(row);
} }
} // namespace Calls } // namespace Calls

View File

@ -427,7 +427,7 @@ object_ptr<TabbedSelector::InnerFooter> EmojiListWidget::createFooter() {
Expects(_footer == nullptr); Expects(_footer == nullptr);
auto result = object_ptr<Footer>(this); auto result = object_ptr<Footer>(this);
_footer = result; _footer = result;
return std::move(result); return result;
} }
template <typename Callback> template <typename Callback>

View File

@ -178,7 +178,7 @@ object_ptr<TabbedSelector::InnerFooter> GifsListWidget::createFooter() {
auto result = object_ptr<Footer>(this); auto result = object_ptr<Footer>(this);
_footer = result; _footer = result;
return std::move(result); return result;
} }
void GifsListWidget::visibleTopBottomUpdated( void GifsListWidget::visibleTopBottomUpdated(

View File

@ -891,7 +891,7 @@ std::optional<std::vector<not_null<EmojiPtr>>> GetEmojiListFromSet(
if (result.empty()) { if (result.empty()) {
return std::nullopt; return std::nullopt;
} }
return std::move(result); return result;
} }
return std::nullopt; return std::nullopt;
} }

View File

@ -878,7 +878,7 @@ object_ptr<TabbedSelector::InnerFooter> StickersListWidget::createFooter() {
auto result = object_ptr<Footer>(this); auto result = object_ptr<Footer>(this);
_footer = result; _footer = result;
return std::move(result); return result;
} }
void StickersListWidget::visibleTopBottomUpdated( void StickersListWidget::visibleTopBottomUpdated(

View File

@ -20,7 +20,7 @@ object_ptr<Window::SectionWidget> TabbedMemento::createWidget(
const QRect &geometry) { const QRect &geometry) {
auto result = object_ptr<TabbedSection>(parent, controller); auto result = object_ptr<TabbedSection>(parent, controller);
result->setGeometry(geometry); result->setGeometry(geometry);
return std::move(result); return result;
} }
TabbedSection::TabbedSection( TabbedSection::TabbedSection(

View File

@ -97,7 +97,7 @@ object_ptr<Window::SectionWidget> SectionMemento::createWidget(
} }
auto result = object_ptr<Widget>(parent, controller, _channel); auto result = object_ptr<Widget>(parent, controller, _channel);
result->setInternalState(geometry, this); result->setInternalState(geometry, this);
return std::move(result); return result;
} }
FixedBar::FixedBar( FixedBar::FixedBar(
@ -365,7 +365,7 @@ void Widget::setupShortcuts() {
std::unique_ptr<Window::SectionMemento> Widget::createMemento() { std::unique_ptr<Window::SectionMemento> Widget::createMemento() {
auto result = std::make_unique<SectionMemento>(channel()); auto result = std::make_unique<SectionMemento>(channel());
saveState(result.get()); saveState(result.get());
return std::move(result); return result;
} }
void Widget::saveState(not_null<SectionMemento*> memento) { void Widget::saveState(not_null<SectionMemento*> memento) {

View File

@ -59,7 +59,7 @@ object_ptr<Window::SectionWidget> Memento::createWidget(
} }
auto result = object_ptr<Widget>(parent, controller, _feed); auto result = object_ptr<Widget>(parent, controller, _feed);
result->setInternalState(geometry, this); result->setInternalState(geometry, this);
return std::move(result); return result;
} }
Widget::Widget( Widget::Widget(
@ -456,7 +456,7 @@ ClickHandlerPtr Widget::listDateLink(not_null<Element*> view) {
std::unique_ptr<Window::SectionMemento> Widget::createMemento() { std::unique_ptr<Window::SectionMemento> Widget::createMemento() {
auto result = std::make_unique<Memento>(_feed); auto result = std::make_unique<Memento>(_feed);
saveState(result.get()); saveState(result.get());
return std::move(result); return result;
} }
void Widget::saveState(not_null<Memento*> memento) { void Widget::saveState(not_null<Memento*> memento) {

View File

@ -67,7 +67,7 @@ object_ptr<Window::SectionWidget> ScheduledMemento::createWidget(
} }
auto result = object_ptr<ScheduledWidget>(parent, controller, _history); auto result = object_ptr<ScheduledWidget>(parent, controller, _history);
result->setInternalState(geometry, this); result->setInternalState(geometry, this);
return std::move(result); return result;
} }
ScheduledWidget::ScheduledWidget( ScheduledWidget::ScheduledWidget(
@ -714,7 +714,7 @@ bool ScheduledWidget::returnTabbedSelector() {
std::unique_ptr<Window::SectionMemento> ScheduledWidget::createMemento() { std::unique_ptr<Window::SectionMemento> ScheduledWidget::createMemento() {
auto result = std::make_unique<ScheduledMemento>(history()); auto result = std::make_unique<ScheduledMemento>(history());
saveState(result.get()); saveState(result.get());
return std::move(result); return result;
} }
void ScheduledWidget::saveState(not_null<ScheduledMemento*> memento) { void ScheduledWidget::saveState(not_null<ScheduledMemento*> memento) {

View File

@ -35,7 +35,7 @@ object_ptr<ContentWidget> Memento::createWidget(
parent, parent,
controller); controller);
result->setInternalState(geometry, this); result->setInternalState(geometry, this);
return std::move(result); return result;
} }
void Memento::setState(std::unique_ptr<SavedState> state) { void Memento::setState(std::unique_ptr<SavedState> state) {
@ -79,7 +79,7 @@ void Widget::setInternalState(
std::unique_ptr<ContentMemento> Widget::doCreateMemento() { std::unique_ptr<ContentMemento> Widget::doCreateMemento() {
auto result = std::make_unique<Memento>(controller()); auto result = std::make_unique<Memento>(controller());
saveState(result.get()); saveState(result.get());
return std::move(result); return result;
} }
void Widget::saveState(not_null<Memento*> memento) { void Widget::saveState(not_null<Memento*> memento) {

View File

@ -33,7 +33,7 @@ object_ptr<ContentWidget> Memento::createWidget(
controller, controller,
Auth().data().user(userId())); Auth().data().user(userId()));
result->setInternalState(geometry, this); result->setInternalState(geometry, this);
return std::move(result); return result;
} }
void Memento::setListState(std::unique_ptr<PeerListState> state) { void Memento::setListState(std::unique_ptr<PeerListState> state) {
@ -85,7 +85,7 @@ void Widget::setInternalState(
std::unique_ptr<ContentMemento> Widget::doCreateMemento() { std::unique_ptr<ContentMemento> Widget::doCreateMemento() {
auto result = std::make_unique<Memento>(user()->bareId()); auto result = std::make_unique<Memento>(user()->bareId());
saveState(result.get()); saveState(result.get());
return std::move(result); return result;
} }
void Widget::saveState(not_null<Memento*> memento) { void Widget::saveState(not_null<Memento*> memento) {

View File

@ -61,7 +61,7 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
_scrollToRequests.fire({ min, max }); _scrollToRequests.fire({ min, max });
}, _channels->lifetime()); }, _channels->lifetime());
return std::move(result); return result;
} }
int InnerWidget::countDesiredHeight() const { int InnerWidget::countDesiredHeight() const {

View File

@ -35,7 +35,7 @@ object_ptr<ContentWidget> Memento::createWidget(
parent, parent,
controller); controller);
result->setInternalState(geometry, this); result->setInternalState(geometry, this);
return std::move(result); return result;
} }
void Memento::setChannelsState(std::unique_ptr<ChannelsState> state) { void Memento::setChannelsState(std::unique_ptr<ChannelsState> state) {
@ -99,7 +99,7 @@ void Widget::setInternalState(
std::unique_ptr<ContentMemento> Widget::doCreateMemento() { std::unique_ptr<ContentMemento> Widget::doCreateMemento() {
auto result = std::make_unique<Memento>(controller()); auto result = std::make_unique<Memento>(controller());
saveState(result.get()); saveState(result.get());
return std::move(result); return result;
} }
void Widget::saveState(not_null<Memento*> memento) { void Widget::saveState(not_null<Memento*> memento) {

View File

@ -160,7 +160,7 @@ object_ptr<Window::SectionWidget> Memento::createWidget(
wrap, wrap,
this); this);
result->setGeometry(geometry); result->setGeometry(geometry);
return std::move(result); return result;
} }
object_ptr<Ui::LayerWidget> Memento::createLayer( object_ptr<Ui::LayerWidget> Memento::createLayer(
@ -198,7 +198,7 @@ object_ptr<Window::SectionWidget> MoveMemento::createWidget(
wrap, wrap,
this); this);
result->setGeometry(geometry); result->setGeometry(geometry);
return std::move(result); return result;
} }
object_ptr<Ui::LayerWidget> MoveMemento::createLayer( object_ptr<Ui::LayerWidget> MoveMemento::createLayer(

View File

@ -1043,7 +1043,7 @@ object_ptr<Ui::RpWidget> WrapWidget::createTopBarSurrogate(
}); });
result->setGeometry(_topBar->geometry()); result->setGeometry(_topBar->geometry());
result->show(); result->show();
return std::move(result); return result;
} }
return nullptr; return nullptr;
} }

View File

@ -94,7 +94,7 @@ inline auto AddButton(
navigation->showSection( navigation->showSection(
Info::Memento(peer->id, Section(type))); Info::Memento(peer->id, Section(type)));
}); });
return std::move(result); return result;
}; };
inline auto AddCommonGroupsButton( inline auto AddCommonGroupsButton(
@ -113,8 +113,8 @@ inline auto AddCommonGroupsButton(
navigation->showSection( navigation->showSection(
Info::Memento(user->id, Section::Type::CommonGroups)); Info::Memento(user->id, Section::Type::CommonGroups));
}); });
return std::move(result); return result;
}; };
} // namespace Media } // namespace Media
} // namespace Info } // namespace Info

View File

@ -65,7 +65,7 @@ object_ptr<ContentWidget> Memento::createWidget(
parent, parent,
controller); controller);
result->setInternalState(geometry, this); result->setInternalState(geometry, this);
return std::move(result); return result;
} }
Widget::Widget( Widget::Widget(
@ -117,7 +117,7 @@ void Widget::setInternalState(
std::unique_ptr<ContentMemento> Widget::doCreateMemento() { std::unique_ptr<ContentMemento> Widget::doCreateMemento() {
auto result = std::make_unique<Memento>(controller()); auto result = std::make_unique<Memento>(controller());
saveState(result.get()); saveState(result.get());
return std::move(result); return result;
} }
void Widget::saveState(not_null<Memento*> memento) { void Widget::saveState(not_null<Memento*> memento) {

View File

@ -38,7 +38,7 @@ object_ptr<ContentWidget> Memento::createWidget(
parent, parent,
controller); controller);
result->setInternalState(geometry, this); result->setInternalState(geometry, this);
return std::move(result); return result;
} }
void Memento::setState(std::unique_ptr<SavedState> state) { void Memento::setState(std::unique_ptr<SavedState> state) {
@ -82,7 +82,7 @@ void Widget::setInternalState(
std::unique_ptr<ContentMemento> Widget::doCreateMemento() { std::unique_ptr<ContentMemento> Widget::doCreateMemento() {
auto result = std::make_unique<Memento>(controller()); auto result = std::make_unique<Memento>(controller());
saveState(result.get()); saveState(result.get());
return std::move(result); return result;
} }
void Widget::saveState(not_null<Memento*> memento) { void Widget::saveState(not_null<Memento*> memento) {

View File

@ -344,7 +344,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
result, result,
st::infoIconInformation, st::infoIconInformation,
st::infoInformationIconPosition); st::infoInformationIconPosition);
return std::move(result); return result;
} }
object_ptr<Ui::RpWidget> DetailsFiller::setupMuteToggle() { object_ptr<Ui::RpWidget> DetailsFiller::setupMuteToggle() {
@ -365,7 +365,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupMuteToggle() {
result, result,
st::infoIconNotifications, st::infoIconNotifications,
st::infoNotificationsIconPosition); st::infoNotificationsIconPosition);
return std::move(result); return result;
} }
void DetailsFiller::setupMainButtons() { void DetailsFiller::setupMainButtons() {
@ -775,7 +775,7 @@ object_ptr<Ui::RpWidget> ActionsFiller::fill() {
// result, // result,
// st::infoIconNotifications, // st::infoIconNotifications,
// st::infoNotificationsIconPosition); // st::infoNotificationsIconPosition);
// return std::move(result); // return result;
//} //}
} // namespace } // namespace
@ -870,7 +870,7 @@ object_ptr<Ui::RpWidget> SetupChannelMembers(
st::infoChannelMembersIconPosition); st::infoChannelMembersIconPosition);
members->add(CreateSkipWidget(members)); members->add(CreateSkipWidget(members));
return std::move(result); return result;
} }
// // #feed // // #feed
//object_ptr<Ui::RpWidget> SetupFeedDetails( //object_ptr<Ui::RpWidget> SetupFeedDetails(

View File

@ -125,7 +125,7 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
}, _members->lifetime()); }, _members->lifetime());
_cover->setOnlineCount(_members->onlineCountValue()); _cover->setOnlineCount(_members->onlineCountValue());
} }
return std::move(result); return result;
} }
object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia( object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
@ -227,7 +227,7 @@ object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
)->setAttribute(Qt::WA_TransparentForMouseEvents); )->setAttribute(Qt::WA_TransparentForMouseEvents);
_sharedMediaWrap = result; _sharedMediaWrap = result;
return std::move(result); return result;
} }
int InnerWidget::countDesiredHeight() const { int InnerWidget::countDesiredHeight() const {

View File

@ -38,7 +38,7 @@ object_ptr<ContentWidget> Memento::createWidget(
parent, parent,
controller); controller);
result->setInternalState(geometry, this); result->setInternalState(geometry, this);
return std::move(result); return result;
} }
void Memento::setMembersState(std::unique_ptr<MembersState> state) { void Memento::setMembersState(std::unique_ptr<MembersState> state) {
@ -102,7 +102,7 @@ void Widget::setInternalState(
std::unique_ptr<ContentMemento> Widget::doCreateMemento() { std::unique_ptr<ContentMemento> Widget::doCreateMemento() {
auto result = std::make_unique<Memento>(controller()); auto result = std::make_unique<Memento>(controller());
saveState(result.get()); saveState(result.get());
return std::move(result); return result;
} }
void Widget::saveState(not_null<Memento*> memento) { void Widget::saveState(not_null<Memento*> memento) {

View File

@ -32,7 +32,7 @@ object_ptr<ContentWidget> Memento::createWidget(
parent, parent,
controller); controller);
result->setInternalState(geometry, this); result->setInternalState(geometry, this);
return std::move(result); return result;
} }
Memento::~Memento() = default; Memento::~Memento() = default;
@ -95,7 +95,7 @@ rpl::producer<bool> Widget::desiredShadowVisibility() const {
std::unique_ptr<ContentMemento> Widget::doCreateMemento() { std::unique_ptr<ContentMemento> Widget::doCreateMemento() {
auto result = std::make_unique<Memento>(self(), _type); auto result = std::make_unique<Memento>(self(), _type);
saveState(result.get()); saveState(result.get());
return std::move(result); return result;
} }
void Widget::saveState(not_null<Memento*> memento) { void Widget::saveState(not_null<Memento*> memento) {

View File

@ -215,7 +215,7 @@ base::variant<FFmpeg::Packet, FFmpeg::AvErrorWrap> File::Context::readPacket() {
if (unroll()) { if (unroll()) {
return FFmpeg::AvErrorWrap(); return FFmpeg::AvErrorWrap();
} else if (!error) { } else if (!error) {
return std::move(result); return result;
} else if (error.code() != AVERROR_EOF) { } else if (error.code() != AVERROR_EOF) {
logFatal(qstr("av_read_frame"), error); logFatal(qstr("av_read_frame"), error);
} }

View File

@ -1192,7 +1192,7 @@ void PanelController::startScopeEdit(
_panelHasUnsavedChanges = [=] { _panelHasUnsavedChanges = [=] {
return weak ? weak->hasUnsavedChanges() : false; return weak ? weak->hasUnsavedChanges() : false;
}; };
return std::move(result); return result;
} break; } break;
case Scope::Type::PersonalDetails: case Scope::Type::PersonalDetails:
case Scope::Type::AddressDetails: { case Scope::Type::AddressDetails: {
@ -1210,7 +1210,7 @@ void PanelController::startScopeEdit(
_panelHasUnsavedChanges = [=] { _panelHasUnsavedChanges = [=] {
return weak ? weak->hasUnsavedChanges() : false; return weak ? weak->hasUnsavedChanges() : false;
}; };
return std::move(result); return result;
} break; } break;
case Scope::Type::Phone: case Scope::Type::Phone:
case Scope::Type::Email: { case Scope::Type::Email: {

View File

@ -334,7 +334,7 @@ std::unique_ptr<PeerListRow> BlockedBoxController::createRow(
return tr::lng_blocked_list_unknown_phone(tr::now); return tr::lng_blocked_list_unknown_phone(tr::now);
}(); }();
row->setCustomStatus(status); row->setCustomStatus(status);
return std::move(row); return row;
} }
ApiWrap::Privacy::Key PhoneNumberPrivacyController::key() { ApiWrap::Privacy::Key PhoneNumberPrivacyController::key() {
@ -444,7 +444,7 @@ object_ptr<Ui::RpWidget> PhoneNumberPrivacyController::setupMiddleWidget(
QVector<MTPInputPrivacyRule>(1, value)); QVector<MTPInputPrivacyRule>(1, value));
}; };
return std::move(widget); return widget;
} }
void PhoneNumberPrivacyController::saveAdditional() { void PhoneNumberPrivacyController::saveAdditional() {

View File

@ -525,7 +525,7 @@ object_ptr<Ui::BoxContent> EditCloudPasswordBox(not_null<Main::Session*> session
session->api().clearUnconfirmedPassword(); session->api().clearUnconfirmedPassword();
}, box->lifetime()); }, box->lifetime());
return std::move(result); return result;
} }
void RemoveCloudPassword(not_null<::Main::Session*> session) { void RemoveCloudPassword(not_null<::Main::Session*> session) {
@ -565,7 +565,7 @@ object_ptr<Ui::BoxContent> CloudPasswordAppOutdatedBox() {
tr::lng_menu_update(tr::now), tr::lng_menu_update(tr::now),
callback); callback);
*box = result.data(); *box = result.data();
return std::move(result); return result;
} }
void AddPrivacyButton( void AddPrivacyButton(

View File

@ -162,7 +162,7 @@ object_ptr<Ui::RpWidget> CreateOutdatedBar(not_null<QWidget*> parent) {
Closed(); Closed();
}, wrap->lifetime()); }, wrap->lifetime());
return std::move(result); return result;
} }
} // namespace Window } // namespace Window

@ -1 +1 @@
Subproject commit a94ad7f817c1e1aeb242843d90f2bac313daab7a Subproject commit 3aaab885075b503950327e544316cd71a1412651