This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[pushed] 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 3fdeae1..bb3bf4e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2017-11-23  Simon Marchi  <simon.marchi@ericsson.com>
 
+	* osdata.c (osdata_end_column, get_osdata): Remove std::move.
+
+2017-11-23  Simon Marchi  <simon.marchi@ericsson.com>
+
 	* varobj.c (struct varobj_dynamic) <children_requested_>: Rename
 	back to...
 	<children_requested>: ... this.
diff --git a/gdb/osdata.c b/gdb/osdata.c
index f013d0f..a82cbf1 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.7.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]