diff options
author | Chih-Hung Hsieh <chh@google.com> | 2018-09-25 12:03:06 -0700 |
---|---|---|
committer | Chih-Hung Hsieh <chh@google.com> | 2018-09-25 16:01:40 -0700 |
commit | 3833f201a9e4b269e7fc657706762d744444caa0 (patch) | |
tree | 10bf68011ebd93d18a0fe5e5f47951ea04a29f23 /base | |
parent | b7798be47e9ad0bed913458278b81af3ffd442fa (diff) | |
download | libhidl-3833f201a9e4b269e7fc657706762d744444caa0.tar.gz |
Add noexcept to move constructors and assignment operators.
Bug: 116614593
Test: build with WITH_TIDY=1
Change-Id: Ic97b2945ad8c77688f9df94e511a970539c06105
Diffstat (limited to 'base')
-rw-r--r-- | base/HidlSupport.cpp | 8 | ||||
-rw-r--r-- | base/Status.cpp | 2 | ||||
-rw-r--r-- | base/include/hidl/HidlInternal.h | 4 | ||||
-rw-r--r-- | base/include/hidl/Status.h | 14 |
4 files changed, 13 insertions, 15 deletions
diff --git a/base/HidlSupport.cpp b/base/HidlSupport.cpp index eb4368f..58afa69 100644 --- a/base/HidlSupport.cpp +++ b/base/HidlSupport.cpp @@ -56,7 +56,7 @@ hidl_handle::hidl_handle(const hidl_handle &other) { } // move constructor. -hidl_handle::hidl_handle(hidl_handle &&other) { +hidl_handle::hidl_handle(hidl_handle&& other) noexcept { mOwnsHandle = false; *this = std::move(other); } @@ -87,7 +87,7 @@ hidl_handle &hidl_handle::operator=(const native_handle_t *native_handle) { return *this; } -hidl_handle &hidl_handle::operator=(hidl_handle &&other) { +hidl_handle& hidl_handle::operator=(hidl_handle&& other) noexcept { if (this != &other) { freeHandle(); mHandle = other.mHandle; @@ -167,11 +167,11 @@ hidl_string::hidl_string(const std::string &s) : hidl_string() { copyFrom(s.c_str(), s.size()); } -hidl_string::hidl_string(hidl_string &&other): hidl_string() { +hidl_string::hidl_string(hidl_string&& other) noexcept : hidl_string() { moveFrom(std::forward<hidl_string>(other)); } -hidl_string &hidl_string::operator=(hidl_string &&other) { +hidl_string& hidl_string::operator=(hidl_string&& other) noexcept { if (this != &other) { clear(); moveFrom(std::forward<hidl_string>(other)); diff --git a/base/Status.cpp b/base/Status.cpp index 1ba91c3..7161bc0 100644 --- a/base/Status.cpp +++ b/base/Status.cpp @@ -150,7 +150,7 @@ namespace details { } } - return_status &return_status::operator=(return_status &&other) { + return_status& return_status::operator=(return_status&& other) noexcept { if (!mCheckedStatus && !isOk()) { LOG(FATAL) << "Failed HIDL return status not checked: " << description(); } diff --git a/base/include/hidl/HidlInternal.h b/base/include/hidl/HidlInternal.h index d000a87..6377c46 100644 --- a/base/include/hidl/HidlInternal.h +++ b/base/include/hidl/HidlInternal.h @@ -71,13 +71,13 @@ struct hidl_pointer { } hidl_pointer(T* ptr) : hidl_pointer() { mPointer = ptr; } hidl_pointer(const hidl_pointer<T>& other) : hidl_pointer() { mPointer = other.mPointer; } - hidl_pointer(hidl_pointer<T>&& other) : hidl_pointer() { *this = std::move(other); } + hidl_pointer(hidl_pointer<T>&& other) noexcept : hidl_pointer() { *this = std::move(other); } hidl_pointer &operator=(const hidl_pointer<T>& other) { mPointer = other.mPointer; return *this; } - hidl_pointer &operator=(hidl_pointer<T>&& other) { + hidl_pointer& operator=(hidl_pointer<T>&& other) noexcept { mPointer = other.mPointer; other.mPointer = nullptr; return *this; diff --git a/base/include/hidl/Status.h b/base/include/hidl/Status.h index 1a2ef6d..b69d4e4 100644 --- a/base/include/hidl/Status.h +++ b/base/include/hidl/Status.h @@ -148,10 +148,8 @@ namespace details { return_status(const return_status &) = delete; return_status &operator=(const return_status &) = delete; - return_status(return_status &&other) { - *this = std::move(other); - } - return_status &operator=(return_status &&other); + return_status(return_status&& other) noexcept { *this = std::move(other); } + return_status& operator=(return_status&& other) noexcept; ~return_status(); @@ -197,8 +195,8 @@ public: // move-able. // precondition: "this" has checked status // postcondition: other is safe to destroy after moving to *this. - Return(Return &&other) = default; - Return &operator=(Return &&) = default; + Return(Return&& other) noexcept = default; + Return& operator=(Return&&) noexcept = default; ~Return() = default; @@ -226,8 +224,8 @@ public: // move-able. // precondition: "this" has checked status // postcondition: other is safe to destroy after moving to *this. - Return(Return &&other) = default; - Return &operator=(Return &&) = default; + Return(Return&& other) noexcept = default; + Return& operator=(Return&&) noexcept = default; ~Return() = default; |