From f45e2a7704c738ba8195a667f910297c4155924e Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 23 Nov 2017 13:51:50 -0500 Subject: [PATCH] Fix clang warnings about copy elision When building with clang, I get: /home/emaisin/src/binutils-gdb/gdb/osdata.c:107:9: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move] std::move (std::string (body_text))); ^ /home/emaisin/src/binutils-gdb/gdb/osdata.c:107:9: note: remove std::move call here std::move (std::string (body_text))); ^~~~~~~~~~~ ~ /home/emaisin/src/binutils-gdb/gdb/osdata.c:181:10: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move] return std::move (osdata); ^ /home/emaisin/src/binutils-gdb/gdb/osdata.c:181:10: note: remove std::move call here return std::move (osdata); ^~~~~~~~~~~ ~ Indeed, those two std::move are unnecessary. gdb/ChangeLog: * osdata.c (osdata_end_column, get_osdata): Remove std::move. --- gdb/ChangeLog | 4 ++++ gdb/osdata.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3fdeae1879c..bb3bf4e6b9c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2017-11-23 Simon Marchi + + * osdata.c (osdata_end_column, get_osdata): Remove std::move. + 2017-11-23 Simon Marchi * varobj.c (struct varobj_dynamic) : Rename diff --git a/gdb/osdata.c b/gdb/osdata.c index f013d0fbd72..a82cbf1ad21 100644 --- a/gdb/osdata.c +++ b/gdb/osdata.c @@ -104,7 +104,7 @@ osdata_end_column (struct gdb_xml_parser *parser, osdata_item &item = osdata->items.back (); item.columns.emplace_back (std::move (data->property_name), - std::move (std::string (body_text))); + std::string (body_text)); } /* The allowed elements and attributes for OS data object. @@ -178,7 +178,7 @@ get_osdata (const char *type) if (osdata == NULL) error (_("Can not fetch data now.")); - return std::move (osdata); + return osdata; } const std::string * -- 2.30.2