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.
This commit is contained in:
Simon Marchi 2017-11-23 13:51:50 -05:00
parent bd046f64a1
commit f45e2a7704
2 changed files with 6 additions and 2 deletions

View File

@ -1,3 +1,7 @@
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

View File

@ -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 *