Skip to content

Commit

Permalink
Mark base::*Callback, GURL and mojo::ScopeHandleBase as noexcept movable
Browse files Browse the repository at this point in the history
These types are used by

  search_provider_logos::LogoMetadata
  search_provider_logos::LogoCallbacks
  viz::InterprocessFramePool::PooledBuffer

which are already using explicitly-defaulted ("= default") noexcept move
constructors and assignment operators. This is illegal however, as C++ requires
the exception specification of an explicitly-defaulted function to be compatible
with the exception specification of the implicit declaration (see
dcl.fct.def.default in C++11 standard). GCC considers this an error and Clang
too, but only if compiling without -fno-exceptions.

Bug: 843143, 819294
Change-Id: I24fb8660b3e8c7748cf6b626292ebd6ddd971643
Reviewed-on: https://chromium-review.googlesource.com/1061464
Reviewed-by: Ken Rockot <rockot@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/master@{#560076}
  • Loading branch information
valdmann authored and Commit Bot committed May 18, 2018
1 parent 1a9ca24 commit f841ac2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
8 changes: 4 additions & 4 deletions base/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class OnceCallback<R(Args...)> : public internal::CallbackBase {
OnceCallback(const OnceCallback&) = delete;
OnceCallback& operator=(const OnceCallback&) = delete;

OnceCallback(OnceCallback&&) = default;
OnceCallback& operator=(OnceCallback&&) = default;
OnceCallback(OnceCallback&&) noexcept = default;
OnceCallback& operator=(OnceCallback&&) noexcept = default;

OnceCallback(RepeatingCallback<RunType> other)
: internal::CallbackBase(std::move(other)) {}
Expand Down Expand Up @@ -112,8 +112,8 @@ class RepeatingCallback<R(Args...)> : public internal::CallbackBaseCopyable {
// Copyable and movable.
RepeatingCallback(const RepeatingCallback&) = default;
RepeatingCallback& operator=(const RepeatingCallback&) = default;
RepeatingCallback(RepeatingCallback&&) = default;
RepeatingCallback& operator=(RepeatingCallback&&) = default;
RepeatingCallback(RepeatingCallback&&) noexcept = default;
RepeatingCallback& operator=(RepeatingCallback&&) noexcept = default;

bool Equals(const RepeatingCallback& other) const {
return EqualsInternal(other);
Expand Down
12 changes: 6 additions & 6 deletions base/callback_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ class BASE_EXPORT BindStateBase
// CallbackBase<Copyable> uses CallbackBase<MoveOnly> for its implementation.
class BASE_EXPORT CallbackBase {
public:
CallbackBase(CallbackBase&& c);
CallbackBase& operator=(CallbackBase&& c);
CallbackBase(CallbackBase&& c) noexcept;
CallbackBase& operator=(CallbackBase&& c) noexcept;

explicit CallbackBase(const CallbackBaseCopyable& c);
CallbackBase& operator=(const CallbackBaseCopyable& c);

explicit CallbackBase(CallbackBaseCopyable&& c);
CallbackBase& operator=(CallbackBaseCopyable&& c);
explicit CallbackBase(CallbackBaseCopyable&& c) noexcept;
CallbackBase& operator=(CallbackBaseCopyable&& c) noexcept;

// Returns true if Callback is null (doesn't refer to anything).
bool is_null() const { return !bind_state_; }
Expand Down Expand Up @@ -158,9 +158,9 @@ constexpr CallbackBase::CallbackBase() = default;
class BASE_EXPORT CallbackBaseCopyable : public CallbackBase {
public:
CallbackBaseCopyable(const CallbackBaseCopyable& c);
CallbackBaseCopyable(CallbackBaseCopyable&& c);
CallbackBaseCopyable(CallbackBaseCopyable&& c) noexcept;
CallbackBaseCopyable& operator=(const CallbackBaseCopyable& c);
CallbackBaseCopyable& operator=(CallbackBaseCopyable&& c);
CallbackBaseCopyable& operator=(CallbackBaseCopyable&& c) noexcept;

protected:
constexpr CallbackBaseCopyable() = default;
Expand Down
5 changes: 3 additions & 2 deletions mojo/public/cpp/system/handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ class ScopedHandleBase {
: handle_(other.release()) {}

// Move-only constructor and operator=.
ScopedHandleBase(ScopedHandleBase&& other) : handle_(other.release()) {}
ScopedHandleBase& operator=(ScopedHandleBase&& other) {
ScopedHandleBase(ScopedHandleBase&& other) noexcept
: handle_(other.release()) {}
ScopedHandleBase& operator=(ScopedHandleBase&& other) noexcept {
if (&other != this) {
CloseIfNecessary();
handle_ = other.release();
Expand Down
2 changes: 1 addition & 1 deletion url/gurl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ GURL& GURL::operator=(const GURL& other) {
return *this;
}

GURL& GURL::operator=(GURL&& other) {
GURL& GURL::operator=(GURL&& other) noexcept {
spec_ = std::move(other.spec_);
is_valid_ = other.is_valid_;
parsed_ = other.parsed_;
Expand Down
2 changes: 1 addition & 1 deletion url/gurl.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class URL_EXPORT GURL {
~GURL();

GURL& operator=(const GURL& other);
GURL& operator=(GURL&& other);
GURL& operator=(GURL&& other) noexcept;

// Returns true when this object represents a valid parsed URL. When not
// valid, other functions will still succeed, but you will not get canonical
Expand Down

0 comments on commit f841ac2

Please sign in to comment.