Add noexcept to move constructors and assignment operators.
Bug: 116614593
Test: build with WITH_TIDY=1
Change-Id: I47101c362198665194f8b3248751caaa7da32505
diff --git a/libs/vr/libpdx/private/pdx/channel_handle.h b/libs/vr/libpdx/private/pdx/channel_handle.h
index 1e62d25..daa08f4 100644
--- a/libs/vr/libpdx/private/pdx/channel_handle.h
+++ b/libs/vr/libpdx/private/pdx/channel_handle.h
@@ -50,14 +50,14 @@
public:
ChannelHandle() = default;
using ChannelHandleBase::ChannelHandleBase;
- ChannelHandle(ChannelHandle&& other) : ChannelHandleBase{other.value_} {
+ ChannelHandle(ChannelHandle&& other) noexcept : ChannelHandleBase{other.value_} {
other.value_ = kEmptyHandle;
}
~ChannelHandle() = default;
ChannelHandle Duplicate() const { return ChannelHandle{value_}; }
- ChannelHandle& operator=(ChannelHandle&& other) {
+ ChannelHandle& operator=(ChannelHandle&& other) noexcept {
value_ = other.value_;
other.value_ = kEmptyHandle;
return *this;
@@ -74,13 +74,13 @@
ChannelHandle(const ChannelHandle&) = delete;
ChannelHandle& operator=(const ChannelHandle&) = delete;
- ChannelHandle(ChannelHandle&& other)
+ ChannelHandle(ChannelHandle&& other) noexcept
: ChannelHandleBase{other.value_}, manager_{other.manager_} {
other.manager_ = nullptr;
other.value_ = kEmptyHandle;
}
- ChannelHandle& operator=(ChannelHandle&& other) {
+ ChannelHandle& operator=(ChannelHandle&& other) noexcept {
value_ = other.value_;
manager_ = other.manager_;
other.value_ = kEmptyHandle;
diff --git a/libs/vr/libpdx/private/pdx/file_handle.h b/libs/vr/libpdx/private/pdx/file_handle.h
index b3c3ad7..fed1529 100644
--- a/libs/vr/libpdx/private/pdx/file_handle.h
+++ b/libs/vr/libpdx/private/pdx/file_handle.h
@@ -43,7 +43,7 @@
// Move constructor that assumes ownership of the file descriptor, leaving the
// other FileHandle object empty.
- FileHandle(FileHandle&& other) {
+ FileHandle(FileHandle&& other) noexcept {
fd_ = other.fd_;
other.fd_ = kEmptyFileHandle;
}
@@ -62,7 +62,7 @@
// Move assignment operator that assumes ownership of the underlying file
// descriptor, leaving the other FileHandle object empty.
- FileHandle& operator=(FileHandle&& other) {
+ FileHandle& operator=(FileHandle&& other) noexcept {
if (this != &other) {
Reset(other.fd_);
other.fd_ = kEmptyFileHandle;
diff --git a/libs/vr/libpdx/private/pdx/rpc/array_wrapper.h b/libs/vr/libpdx/private/pdx/rpc/array_wrapper.h
index 93d87f3..d835c57 100644
--- a/libs/vr/libpdx/private/pdx/rpc/array_wrapper.h
+++ b/libs/vr/libpdx/private/pdx/rpc/array_wrapper.h
@@ -39,7 +39,7 @@
ArrayWrapper(const ArrayWrapper& other) { *this = other; }
- ArrayWrapper(ArrayWrapper&& other) { *this = std::move(other); }
+ ArrayWrapper(ArrayWrapper&& other) noexcept { *this = std::move(other); }
ArrayWrapper& operator=(const ArrayWrapper& other) {
if (&other == this) {
@@ -53,7 +53,7 @@
return *this;
}
- ArrayWrapper& operator=(ArrayWrapper&& other) {
+ ArrayWrapper& operator=(ArrayWrapper&& other) noexcept {
if (&other == this) {
return *this;
} else {
diff --git a/libs/vr/libpdx/private/pdx/rpc/buffer_wrapper.h b/libs/vr/libpdx/private/pdx/rpc/buffer_wrapper.h
index aa86531..0421220 100644
--- a/libs/vr/libpdx/private/pdx/rpc/buffer_wrapper.h
+++ b/libs/vr/libpdx/private/pdx/rpc/buffer_wrapper.h
@@ -39,7 +39,7 @@
BufferWrapper(const BufferWrapper& other) { *this = other; }
- BufferWrapper(BufferWrapper&& other) { *this = std::move(other); }
+ BufferWrapper(BufferWrapper&& other) noexcept { *this = std::move(other); }
BufferWrapper& operator=(const BufferWrapper& other) {
if (&other == this) {
@@ -53,7 +53,7 @@
return *this;
}
- BufferWrapper& operator=(BufferWrapper&& other) {
+ BufferWrapper& operator=(BufferWrapper&& other) noexcept {
if (&other == this) {
return *this;
} else {
@@ -117,9 +117,9 @@
BufferWrapper(BufferType&& buffer, const Allocator& allocator)
: buffer_(std::move(buffer), allocator) {}
BufferWrapper(const BufferWrapper&) = default;
- BufferWrapper(BufferWrapper&&) = default;
+ BufferWrapper(BufferWrapper&&) noexcept = default;
BufferWrapper& operator=(const BufferWrapper&) = default;
- BufferWrapper& operator=(BufferWrapper&&) = default;
+ BufferWrapper& operator=(BufferWrapper&&) noexcept = default;
pointer data() { return buffer_.data(); }
const_pointer data() const { return buffer_.data(); }
diff --git a/libs/vr/libpdx/private/pdx/rpc/pointer_wrapper.h b/libs/vr/libpdx/private/pdx/rpc/pointer_wrapper.h
index d496719..1cb85de 100644
--- a/libs/vr/libpdx/private/pdx/rpc/pointer_wrapper.h
+++ b/libs/vr/libpdx/private/pdx/rpc/pointer_wrapper.h
@@ -15,9 +15,9 @@
PointerWrapper(T* pointer) : pointer_(pointer) {}
PointerWrapper(const PointerWrapper&) = default;
- PointerWrapper(PointerWrapper&&) = default;
+ PointerWrapper(PointerWrapper&&) noexcept = default;
PointerWrapper& operator=(const PointerWrapper&) = default;
- PointerWrapper& operator=(PointerWrapper&&) = default;
+ PointerWrapper& operator=(PointerWrapper&&) noexcept = default;
T& Dereference() { return *pointer_; }
const T& Dereference() const { return *pointer_; }
diff --git a/libs/vr/libpdx/private/pdx/rpc/string_wrapper.h b/libs/vr/libpdx/private/pdx/rpc/string_wrapper.h
index 19fc4c1..2d0a4ea 100644
--- a/libs/vr/libpdx/private/pdx/rpc/string_wrapper.h
+++ b/libs/vr/libpdx/private/pdx/rpc/string_wrapper.h
@@ -44,7 +44,7 @@
StringWrapper(const StringWrapper& other) { *this = other; }
- StringWrapper(StringWrapper&& other) { *this = std::move(other); }
+ StringWrapper(StringWrapper&& other) noexcept { *this = std::move(other); }
StringWrapper& operator=(const StringWrapper& other) {
if (&other == this) {
@@ -58,7 +58,7 @@
return *this;
}
- StringWrapper& operator=(StringWrapper&& other) {
+ StringWrapper& operator=(StringWrapper&& other) noexcept {
if (&other == this) {
return *this;
} else {
diff --git a/libs/vr/libpdx/private/pdx/rpc/variant.h b/libs/vr/libpdx/private/pdx/rpc/variant.h
index 0a4802e..a1292b0 100644
--- a/libs/vr/libpdx/private/pdx/rpc/variant.h
+++ b/libs/vr/libpdx/private/pdx/rpc/variant.h
@@ -447,7 +447,7 @@
Variant(const Variant& other)
: index_{other.index_}, value_{other.value_, other.index_} {}
- Variant(Variant&& other)
+ Variant(Variant&& other) noexcept
: index_{other.index_}, value_{std::move(other.value_), other.index_} {}
// Recent Clang versions has a regression that produces bogus
@@ -472,7 +472,7 @@
other.Visit([this](const auto& value) { *this = value; });
return *this;
}
- Variant& operator=(Variant&& other) {
+ Variant& operator=(Variant&& other) noexcept {
other.Visit([this](auto&& value) { *this = std::move(value); });
return *this;
}
diff --git a/libs/vr/libpdx/private/pdx/service.h b/libs/vr/libpdx/private/pdx/service.h
index 13aa3e9..234b24a 100644
--- a/libs/vr/libpdx/private/pdx/service.h
+++ b/libs/vr/libpdx/private/pdx/service.h
@@ -92,8 +92,8 @@
/*
* Message objects support move construction and assignment.
*/
- Message(Message&& other);
- Message& operator=(Message&& other);
+ Message(Message&& other) noexcept;
+ Message& operator=(Message&& other) noexcept;
/*
* Read/write payload, in either single buffer or iovec form.
diff --git a/libs/vr/libpdx/private/pdx/status.h b/libs/vr/libpdx/private/pdx/status.h
index 067fe25..7e51a52 100644
--- a/libs/vr/libpdx/private/pdx/status.h
+++ b/libs/vr/libpdx/private/pdx/status.h
@@ -41,14 +41,14 @@
// Copy/move constructors. Move constructor leaves |other| object in empty
// state.
Status(const Status& other) = default;
- Status(Status&& other)
+ Status(Status&& other) noexcept
: value_{std::move(other.value_)}, error_{other.error_} {
other.error_ = -1;
}
// Assignment operators.
Status& operator=(const Status& other) = default;
- Status& operator=(Status&& other) {
+ Status& operator=(Status&& other) noexcept {
error_ = other.error_;
value_ = std::move(other.value_);
other.error_ = -1;
diff --git a/libs/vr/libpdx/private/pdx/utility.h b/libs/vr/libpdx/private/pdx/utility.h
index 08fcaea..c9a0c21 100644
--- a/libs/vr/libpdx/private/pdx/utility.h
+++ b/libs/vr/libpdx/private/pdx/utility.h
@@ -33,7 +33,7 @@
return *this;
}
- ByteBuffer& operator=(ByteBuffer&& other) {
+ ByteBuffer& operator=(ByteBuffer&& other) noexcept {
std::swap(data_, other.data_);
std::swap(size_, other.size_);
std::swap(capacity_, other.capacity_);
diff --git a/libs/vr/libpdx/service.cpp b/libs/vr/libpdx/service.cpp
index 1d3b62a..68b8dd7 100644
--- a/libs/vr/libpdx/service.cpp
+++ b/libs/vr/libpdx/service.cpp
@@ -31,9 +31,9 @@
// C++11 specifies the move semantics for shared_ptr but not weak_ptr. This
// means we have to manually implement the desired move semantics for Message.
-Message::Message(Message&& other) { *this = std::move(other); }
+Message::Message(Message&& other) noexcept { *this = std::move(other); }
-Message& Message::operator=(Message&& other) {
+Message& Message::operator=(Message&& other) noexcept {
Destroy();
auto base = reinterpret_cast<std::uint8_t*>(&info_);
std::fill(&base[0], &base[sizeof(info_)], 0);