[base] Add missing V8_NOEXCEPT annotations

This silences the new presubmit check for all base classes.

R=tebbi@chromium.org

Bug: v8:8616
Change-Id: I389fedde1b44d9c583dd2fb75e6c8af138c4feb0
Reviewed-on: https://chromium-review.googlesource.com/c/1387491
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58478}
This commit is contained in:
Clemens Hammacher 2018-12-21 11:22:23 +01:00 committed by Commit Bot
parent a71ac627f2
commit 4e9682bda6
3 changed files with 41 additions and 44 deletions

View File

@ -23,7 +23,7 @@ class ReversedAdapter {
std::reverse_iterator<decltype(std::begin(std::declval<T>()))>;
explicit ReversedAdapter(T& t) : t_(t) {}
ReversedAdapter(const ReversedAdapter& ra) = default;
ReversedAdapter(const ReversedAdapter& ra) V8_NOEXCEPT = default;
// TODO(clemensh): Use std::rbegin/std::rend once we have C++14 support.
Iterator begin() const { return Iterator(std::end(t_)); }

View File

@ -163,12 +163,11 @@ struct OptionalStorage : OptionalStorageBase<T> {
// Define it explicitly.
OptionalStorage() = default;
OptionalStorage(const OptionalStorage& other) {
OptionalStorage(const OptionalStorage& other) V8_NOEXCEPT {
if (other.is_populated_) Init(other.value_);
}
OptionalStorage(OptionalStorage&& other) noexcept(
std::is_nothrow_move_constructible<T>::value) {
OptionalStorage(OptionalStorage&& other) V8_NOEXCEPT {
if (other.is_populated_) Init(std::move(other.value_));
}
};
@ -183,10 +182,9 @@ struct OptionalStorage<T, true /* trivially copy constructible */,
using OptionalStorageBase<T>::OptionalStorageBase;
OptionalStorage() = default;
OptionalStorage(const OptionalStorage& other) = default;
OptionalStorage(const OptionalStorage& other) V8_NOEXCEPT = default;
OptionalStorage(OptionalStorage&& other) noexcept(
std::is_nothrow_move_constructible<T>::value) {
OptionalStorage(OptionalStorage&& other) V8_NOEXCEPT {
if (other.is_populated_) Init(std::move(other.value_));
}
};
@ -201,9 +199,9 @@ struct OptionalStorage<T, false /* trivially copy constructible */,
using OptionalStorageBase<T>::OptionalStorageBase;
OptionalStorage() = default;
OptionalStorage(OptionalStorage&& other) = default;
OptionalStorage(OptionalStorage&& other) V8_NOEXCEPT = default;
OptionalStorage(const OptionalStorage& other) {
OptionalStorage(const OptionalStorage& other) V8_NOEXCEPT {
if (other.is_populated_) Init(other.value_);
}
};
@ -227,8 +225,8 @@ class OptionalBase {
// because of C++ language restriction.
protected:
constexpr OptionalBase() = default;
constexpr OptionalBase(const OptionalBase& other) = default;
constexpr OptionalBase(OptionalBase&& other) = default;
constexpr OptionalBase(const OptionalBase& other) V8_NOEXCEPT = default;
constexpr OptionalBase(OptionalBase&& other) V8_NOEXCEPT = default;
template <class... Args>
constexpr explicit OptionalBase(in_place_t, Args&&... args)
@ -236,26 +234,24 @@ class OptionalBase {
// Implementation of converting constructors.
template <typename U>
explicit OptionalBase(const OptionalBase<U>& other) {
explicit OptionalBase(const OptionalBase<U>& other) V8_NOEXCEPT {
if (other.storage_.is_populated_) storage_.Init(other.storage_.value_);
}
template <typename U>
explicit OptionalBase(OptionalBase<U>&& other) {
explicit OptionalBase(OptionalBase<U>&& other) V8_NOEXCEPT {
if (other.storage_.is_populated_)
storage_.Init(std::move(other.storage_.value_));
}
~OptionalBase() = default;
OptionalBase& operator=(const OptionalBase& other) {
OptionalBase& operator=(const OptionalBase& other) V8_NOEXCEPT {
CopyAssign(other);
return *this;
}
OptionalBase& operator=(OptionalBase&& other) noexcept(
std::is_nothrow_move_assignable<T>::value&&
std::is_nothrow_move_constructible<T>::value) {
OptionalBase& operator=(OptionalBase&& other) V8_NOEXCEPT {
MoveAssign(std::move(other));
return *this;
}
@ -309,9 +305,9 @@ template <>
struct CopyConstructible<false> {
constexpr CopyConstructible() = default;
constexpr CopyConstructible(const CopyConstructible&) = delete;
constexpr CopyConstructible(CopyConstructible&&) = default;
CopyConstructible& operator=(const CopyConstructible&) = default;
CopyConstructible& operator=(CopyConstructible&&) = default;
constexpr CopyConstructible(CopyConstructible&&) V8_NOEXCEPT = default;
CopyConstructible& operator=(const CopyConstructible&) V8_NOEXCEPT = default;
CopyConstructible& operator=(CopyConstructible&&) V8_NOEXCEPT = default;
};
template <bool is_move_constructible>
@ -320,10 +316,10 @@ struct MoveConstructible {};
template <>
struct MoveConstructible<false> {
constexpr MoveConstructible() = default;
constexpr MoveConstructible(const MoveConstructible&) = default;
constexpr MoveConstructible(const MoveConstructible&) V8_NOEXCEPT = default;
constexpr MoveConstructible(MoveConstructible&&) = delete;
MoveConstructible& operator=(const MoveConstructible&) = default;
MoveConstructible& operator=(MoveConstructible&&) = default;
MoveConstructible& operator=(const MoveConstructible&) V8_NOEXCEPT = default;
MoveConstructible& operator=(MoveConstructible&&) V8_NOEXCEPT = default;
};
template <bool is_copy_assignable>
@ -332,10 +328,10 @@ struct CopyAssignable {};
template <>
struct CopyAssignable<false> {
constexpr CopyAssignable() = default;
constexpr CopyAssignable(const CopyAssignable&) = default;
constexpr CopyAssignable(CopyAssignable&&) = default;
constexpr CopyAssignable(const CopyAssignable&) V8_NOEXCEPT = default;
constexpr CopyAssignable(CopyAssignable&&) V8_NOEXCEPT = default;
CopyAssignable& operator=(const CopyAssignable&) = delete;
CopyAssignable& operator=(CopyAssignable&&) = default;
CopyAssignable& operator=(CopyAssignable&&) V8_NOEXCEPT = default;
};
template <bool is_move_assignable>
@ -344,9 +340,9 @@ struct MoveAssignable {};
template <>
struct MoveAssignable<false> {
constexpr MoveAssignable() = default;
constexpr MoveAssignable(const MoveAssignable&) = default;
constexpr MoveAssignable(MoveAssignable&&) = default;
MoveAssignable& operator=(const MoveAssignable&) = default;
constexpr MoveAssignable(const MoveAssignable&) V8_NOEXCEPT = default;
constexpr MoveAssignable(MoveAssignable&&) V8_NOEXCEPT = default;
MoveAssignable& operator=(const MoveAssignable&) V8_NOEXCEPT = default;
MoveAssignable& operator=(MoveAssignable&&) = delete;
};
@ -421,7 +417,7 @@ using RemoveCvRefT =
// - Constructors do not use 'constexpr' as it is a C++14 extension.
// - 'constexpr' might be missing in some places for reasons specified locally.
// - No exceptions are thrown, because they are banned from Chromium.
// Marked noexcept for only move constructor and move assign operators.
// All copy/move constructors or assignment operators are marked V8_NOEXCEPT.
// - All the non-members are in the 'base' namespace instead of 'std'.
//
// Note that T cannot have a constructor T(Optional<T>) etc. Optional<T> checks
@ -445,8 +441,8 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
// Defer default/copy/move constructor implementation to OptionalBase.
constexpr Optional() = default;
constexpr Optional(const Optional& other) = default;
constexpr Optional(Optional&& other) = default;
constexpr Optional(const Optional& other) V8_NOEXCEPT = default;
constexpr Optional(Optional&& other) V8_NOEXCEPT = default;
constexpr Optional(nullopt_t) {} // NOLINT(runtime/explicit)
@ -460,7 +456,8 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
!internal::IsConvertibleFromOptional<T, U>::value &&
std::is_convertible<const U&, T>::value,
bool>::type = false>
Optional(const Optional<U>& other) : internal::OptionalBase<T>(other) {}
Optional(const Optional<U>& other) V8_NOEXCEPT
: internal::OptionalBase<T>(other) {}
template <typename U,
typename std::enable_if<
@ -468,7 +465,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
!internal::IsConvertibleFromOptional<T, U>::value &&
!std::is_convertible<const U&, T>::value,
bool>::type = false>
explicit Optional(const Optional<U>& other)
explicit Optional(const Optional<U>& other) V8_NOEXCEPT
: internal::OptionalBase<T>(other) {}
// Converting move constructor. Similar to converting copy constructor,
@ -479,7 +476,8 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
!internal::IsConvertibleFromOptional<T, U>::value &&
std::is_convertible<U&&, T>::value,
bool>::type = false>
Optional(Optional<U>&& other) : internal::OptionalBase<T>(std::move(other)) {}
Optional(Optional<U>&& other) V8_NOEXCEPT
: internal::OptionalBase<T>(std::move(other)) {}
template <typename U,
typename std::enable_if<
@ -487,7 +485,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
!internal::IsConvertibleFromOptional<T, U>::value &&
!std::is_convertible<U&&, T>::value,
bool>::type = false>
explicit Optional(Optional<U>&& other)
explicit Optional(Optional<U>&& other) V8_NOEXCEPT
: internal::OptionalBase<T>(std::move(other)) {}
template <class... Args>
@ -528,8 +526,8 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
~Optional() = default;
// Defer copy-/move- assign operator implementation to OptionalBase.
Optional& operator=(const Optional& other) = default;
Optional& operator=(Optional&& other) = default;
Optional& operator=(const Optional& other) V8_NOEXCEPT = default;
Optional& operator=(Optional&& other) V8_NOEXCEPT = default;
Optional& operator=(nullopt_t) {
FreeIfNeeded();
@ -545,7 +543,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
(!std::is_scalar<T>::value ||
!std::is_same<typename std::decay<U>::type, T>::value),
Optional&>::type
operator=(U&& value) {
operator=(U&& value) V8_NOEXCEPT {
InitOrAssign(std::forward<U>(value));
return *this;
}
@ -556,7 +554,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
std::is_constructible<T, const U&>::value &&
std::is_assignable<T&, const U&>::value,
Optional&>::type
operator=(const Optional<U>& other) {
operator=(const Optional<U>& other) V8_NOEXCEPT {
CopyAssign(other);
return *this;
}
@ -567,7 +565,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
std::is_constructible<T, U>::value &&
std::is_assignable<T&, U>::value,
Optional&>::type
operator=(Optional<U>&& other) {
operator=(Optional<U>&& other) V8_NOEXCEPT {
MoveAssign(std::move(other));
return *this;
}

View File

@ -616,13 +616,12 @@ class EmbeddedVector : public Vector<T> {
}
// When copying, make underlying Vector to reference our buffer.
EmbeddedVector(const EmbeddedVector& rhs)
: Vector<T>(rhs) {
EmbeddedVector(const EmbeddedVector& rhs) V8_NOEXCEPT : Vector<T>(rhs) {
MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize);
this->set_start(buffer_);
}
EmbeddedVector& operator=(const EmbeddedVector& rhs) {
EmbeddedVector& operator=(const EmbeddedVector& rhs) V8_NOEXCEPT {
if (this == &rhs) return *this;
Vector<T>::operator=(rhs);
MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize);