Commit 4e9682bd authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[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: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58478}
parent a71ac627
...@@ -23,7 +23,7 @@ class ReversedAdapter { ...@@ -23,7 +23,7 @@ class ReversedAdapter {
std::reverse_iterator<decltype(std::begin(std::declval<T>()))>; std::reverse_iterator<decltype(std::begin(std::declval<T>()))>;
explicit ReversedAdapter(T& t) : t_(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. // TODO(clemensh): Use std::rbegin/std::rend once we have C++14 support.
Iterator begin() const { return Iterator(std::end(t_)); } Iterator begin() const { return Iterator(std::end(t_)); }
......
...@@ -163,12 +163,11 @@ struct OptionalStorage : OptionalStorageBase<T> { ...@@ -163,12 +163,11 @@ struct OptionalStorage : OptionalStorageBase<T> {
// Define it explicitly. // Define it explicitly.
OptionalStorage() = default; OptionalStorage() = default;
OptionalStorage(const OptionalStorage& other) { OptionalStorage(const OptionalStorage& other) V8_NOEXCEPT {
if (other.is_populated_) Init(other.value_); if (other.is_populated_) Init(other.value_);
} }
OptionalStorage(OptionalStorage&& other) noexcept( OptionalStorage(OptionalStorage&& other) V8_NOEXCEPT {
std::is_nothrow_move_constructible<T>::value) {
if (other.is_populated_) Init(std::move(other.value_)); if (other.is_populated_) Init(std::move(other.value_));
} }
}; };
...@@ -183,10 +182,9 @@ struct OptionalStorage<T, true /* trivially copy constructible */, ...@@ -183,10 +182,9 @@ struct OptionalStorage<T, true /* trivially copy constructible */,
using OptionalStorageBase<T>::OptionalStorageBase; using OptionalStorageBase<T>::OptionalStorageBase;
OptionalStorage() = default; OptionalStorage() = default;
OptionalStorage(const OptionalStorage& other) = default; OptionalStorage(const OptionalStorage& other) V8_NOEXCEPT = default;
OptionalStorage(OptionalStorage&& other) noexcept( OptionalStorage(OptionalStorage&& other) V8_NOEXCEPT {
std::is_nothrow_move_constructible<T>::value) {
if (other.is_populated_) Init(std::move(other.value_)); if (other.is_populated_) Init(std::move(other.value_));
} }
}; };
...@@ -201,9 +199,9 @@ struct OptionalStorage<T, false /* trivially copy constructible */, ...@@ -201,9 +199,9 @@ struct OptionalStorage<T, false /* trivially copy constructible */,
using OptionalStorageBase<T>::OptionalStorageBase; using OptionalStorageBase<T>::OptionalStorageBase;
OptionalStorage() = default; 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_); if (other.is_populated_) Init(other.value_);
} }
}; };
...@@ -227,8 +225,8 @@ class OptionalBase { ...@@ -227,8 +225,8 @@ class OptionalBase {
// because of C++ language restriction. // because of C++ language restriction.
protected: protected:
constexpr OptionalBase() = default; constexpr OptionalBase() = default;
constexpr OptionalBase(const OptionalBase& other) = default; constexpr OptionalBase(const OptionalBase& other) V8_NOEXCEPT = default;
constexpr OptionalBase(OptionalBase&& other) = default; constexpr OptionalBase(OptionalBase&& other) V8_NOEXCEPT = default;
template <class... Args> template <class... Args>
constexpr explicit OptionalBase(in_place_t, Args&&... args) constexpr explicit OptionalBase(in_place_t, Args&&... args)
...@@ -236,26 +234,24 @@ class OptionalBase { ...@@ -236,26 +234,24 @@ class OptionalBase {
// Implementation of converting constructors. // Implementation of converting constructors.
template <typename U> 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_); if (other.storage_.is_populated_) storage_.Init(other.storage_.value_);
} }
template <typename U> template <typename U>
explicit OptionalBase(OptionalBase<U>&& other) { explicit OptionalBase(OptionalBase<U>&& other) V8_NOEXCEPT {
if (other.storage_.is_populated_) if (other.storage_.is_populated_)
storage_.Init(std::move(other.storage_.value_)); storage_.Init(std::move(other.storage_.value_));
} }
~OptionalBase() = default; ~OptionalBase() = default;
OptionalBase& operator=(const OptionalBase& other) { OptionalBase& operator=(const OptionalBase& other) V8_NOEXCEPT {
CopyAssign(other); CopyAssign(other);
return *this; return *this;
} }
OptionalBase& operator=(OptionalBase&& other) noexcept( OptionalBase& operator=(OptionalBase&& other) V8_NOEXCEPT {
std::is_nothrow_move_assignable<T>::value&&
std::is_nothrow_move_constructible<T>::value) {
MoveAssign(std::move(other)); MoveAssign(std::move(other));
return *this; return *this;
} }
...@@ -309,9 +305,9 @@ template <> ...@@ -309,9 +305,9 @@ template <>
struct CopyConstructible<false> { struct CopyConstructible<false> {
constexpr CopyConstructible() = default; constexpr CopyConstructible() = default;
constexpr CopyConstructible(const CopyConstructible&) = delete; constexpr CopyConstructible(const CopyConstructible&) = delete;
constexpr CopyConstructible(CopyConstructible&&) = default; constexpr CopyConstructible(CopyConstructible&&) V8_NOEXCEPT = default;
CopyConstructible& operator=(const CopyConstructible&) = default; CopyConstructible& operator=(const CopyConstructible&) V8_NOEXCEPT = default;
CopyConstructible& operator=(CopyConstructible&&) = default; CopyConstructible& operator=(CopyConstructible&&) V8_NOEXCEPT = default;
}; };
template <bool is_move_constructible> template <bool is_move_constructible>
...@@ -320,10 +316,10 @@ struct MoveConstructible {}; ...@@ -320,10 +316,10 @@ struct MoveConstructible {};
template <> template <>
struct MoveConstructible<false> { struct MoveConstructible<false> {
constexpr MoveConstructible() = default; constexpr MoveConstructible() = default;
constexpr MoveConstructible(const MoveConstructible&) = default; constexpr MoveConstructible(const MoveConstructible&) V8_NOEXCEPT = default;
constexpr MoveConstructible(MoveConstructible&&) = delete; constexpr MoveConstructible(MoveConstructible&&) = delete;
MoveConstructible& operator=(const MoveConstructible&) = default; MoveConstructible& operator=(const MoveConstructible&) V8_NOEXCEPT = default;
MoveConstructible& operator=(MoveConstructible&&) = default; MoveConstructible& operator=(MoveConstructible&&) V8_NOEXCEPT = default;
}; };
template <bool is_copy_assignable> template <bool is_copy_assignable>
...@@ -332,10 +328,10 @@ struct CopyAssignable {}; ...@@ -332,10 +328,10 @@ struct CopyAssignable {};
template <> template <>
struct CopyAssignable<false> { struct CopyAssignable<false> {
constexpr CopyAssignable() = default; constexpr CopyAssignable() = default;
constexpr CopyAssignable(const CopyAssignable&) = default; constexpr CopyAssignable(const CopyAssignable&) V8_NOEXCEPT = default;
constexpr CopyAssignable(CopyAssignable&&) = default; constexpr CopyAssignable(CopyAssignable&&) V8_NOEXCEPT = default;
CopyAssignable& operator=(const CopyAssignable&) = delete; CopyAssignable& operator=(const CopyAssignable&) = delete;
CopyAssignable& operator=(CopyAssignable&&) = default; CopyAssignable& operator=(CopyAssignable&&) V8_NOEXCEPT = default;
}; };
template <bool is_move_assignable> template <bool is_move_assignable>
...@@ -344,9 +340,9 @@ struct MoveAssignable {}; ...@@ -344,9 +340,9 @@ struct MoveAssignable {};
template <> template <>
struct MoveAssignable<false> { struct MoveAssignable<false> {
constexpr MoveAssignable() = default; constexpr MoveAssignable() = default;
constexpr MoveAssignable(const MoveAssignable&) = default; constexpr MoveAssignable(const MoveAssignable&) V8_NOEXCEPT = default;
constexpr MoveAssignable(MoveAssignable&&) = default; constexpr MoveAssignable(MoveAssignable&&) V8_NOEXCEPT = default;
MoveAssignable& operator=(const MoveAssignable&) = default; MoveAssignable& operator=(const MoveAssignable&) V8_NOEXCEPT = default;
MoveAssignable& operator=(MoveAssignable&&) = delete; MoveAssignable& operator=(MoveAssignable&&) = delete;
}; };
...@@ -421,7 +417,7 @@ using RemoveCvRefT = ...@@ -421,7 +417,7 @@ using RemoveCvRefT =
// - Constructors do not use 'constexpr' as it is a C++14 extension. // - Constructors do not use 'constexpr' as it is a C++14 extension.
// - 'constexpr' might be missing in some places for reasons specified locally. // - 'constexpr' might be missing in some places for reasons specified locally.
// - No exceptions are thrown, because they are banned from Chromium. // - 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'. // - 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 // Note that T cannot have a constructor T(Optional<T>) etc. Optional<T> checks
...@@ -445,8 +441,8 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional ...@@ -445,8 +441,8 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
// Defer default/copy/move constructor implementation to OptionalBase. // Defer default/copy/move constructor implementation to OptionalBase.
constexpr Optional() = default; constexpr Optional() = default;
constexpr Optional(const Optional& other) = default; constexpr Optional(const Optional& other) V8_NOEXCEPT = default;
constexpr Optional(Optional&& other) = default; constexpr Optional(Optional&& other) V8_NOEXCEPT = default;
constexpr Optional(nullopt_t) {} // NOLINT(runtime/explicit) constexpr Optional(nullopt_t) {} // NOLINT(runtime/explicit)
...@@ -460,7 +456,8 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional ...@@ -460,7 +456,8 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
!internal::IsConvertibleFromOptional<T, U>::value && !internal::IsConvertibleFromOptional<T, U>::value &&
std::is_convertible<const U&, T>::value, std::is_convertible<const U&, T>::value,
bool>::type = false> 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, template <typename U,
typename std::enable_if< typename std::enable_if<
...@@ -468,7 +465,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional ...@@ -468,7 +465,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
!internal::IsConvertibleFromOptional<T, U>::value && !internal::IsConvertibleFromOptional<T, U>::value &&
!std::is_convertible<const U&, T>::value, !std::is_convertible<const U&, T>::value,
bool>::type = false> bool>::type = false>
explicit Optional(const Optional<U>& other) explicit Optional(const Optional<U>& other) V8_NOEXCEPT
: internal::OptionalBase<T>(other) {} : internal::OptionalBase<T>(other) {}
// Converting move constructor. Similar to converting copy constructor, // Converting move constructor. Similar to converting copy constructor,
...@@ -479,7 +476,8 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional ...@@ -479,7 +476,8 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
!internal::IsConvertibleFromOptional<T, U>::value && !internal::IsConvertibleFromOptional<T, U>::value &&
std::is_convertible<U&&, T>::value, std::is_convertible<U&&, T>::value,
bool>::type = false> 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, template <typename U,
typename std::enable_if< typename std::enable_if<
...@@ -487,7 +485,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional ...@@ -487,7 +485,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
!internal::IsConvertibleFromOptional<T, U>::value && !internal::IsConvertibleFromOptional<T, U>::value &&
!std::is_convertible<U&&, T>::value, !std::is_convertible<U&&, T>::value,
bool>::type = false> bool>::type = false>
explicit Optional(Optional<U>&& other) explicit Optional(Optional<U>&& other) V8_NOEXCEPT
: internal::OptionalBase<T>(std::move(other)) {} : internal::OptionalBase<T>(std::move(other)) {}
template <class... Args> template <class... Args>
...@@ -528,8 +526,8 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional ...@@ -528,8 +526,8 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
~Optional() = default; ~Optional() = default;
// Defer copy-/move- assign operator implementation to OptionalBase. // Defer copy-/move- assign operator implementation to OptionalBase.
Optional& operator=(const Optional& other) = default; Optional& operator=(const Optional& other) V8_NOEXCEPT = default;
Optional& operator=(Optional&& other) = default; Optional& operator=(Optional&& other) V8_NOEXCEPT = default;
Optional& operator=(nullopt_t) { Optional& operator=(nullopt_t) {
FreeIfNeeded(); FreeIfNeeded();
...@@ -545,7 +543,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional ...@@ -545,7 +543,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
(!std::is_scalar<T>::value || (!std::is_scalar<T>::value ||
!std::is_same<typename std::decay<U>::type, T>::value), !std::is_same<typename std::decay<U>::type, T>::value),
Optional&>::type Optional&>::type
operator=(U&& value) { operator=(U&& value) V8_NOEXCEPT {
InitOrAssign(std::forward<U>(value)); InitOrAssign(std::forward<U>(value));
return *this; return *this;
} }
...@@ -556,7 +554,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional ...@@ -556,7 +554,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
std::is_constructible<T, const U&>::value && std::is_constructible<T, const U&>::value &&
std::is_assignable<T&, const U&>::value, std::is_assignable<T&, const U&>::value,
Optional&>::type Optional&>::type
operator=(const Optional<U>& other) { operator=(const Optional<U>& other) V8_NOEXCEPT {
CopyAssign(other); CopyAssign(other);
return *this; return *this;
} }
...@@ -567,7 +565,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional ...@@ -567,7 +565,7 @@ class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
std::is_constructible<T, U>::value && std::is_constructible<T, U>::value &&
std::is_assignable<T&, U>::value, std::is_assignable<T&, U>::value,
Optional&>::type Optional&>::type
operator=(Optional<U>&& other) { operator=(Optional<U>&& other) V8_NOEXCEPT {
MoveAssign(std::move(other)); MoveAssign(std::move(other));
return *this; return *this;
} }
......
...@@ -616,13 +616,12 @@ class EmbeddedVector : public Vector<T> { ...@@ -616,13 +616,12 @@ class EmbeddedVector : public Vector<T> {
} }
// When copying, make underlying Vector to reference our buffer. // When copying, make underlying Vector to reference our buffer.
EmbeddedVector(const EmbeddedVector& rhs) EmbeddedVector(const EmbeddedVector& rhs) V8_NOEXCEPT : Vector<T>(rhs) {
: Vector<T>(rhs) {
MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize); MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize);
this->set_start(buffer_); this->set_start(buffer_);
} }
EmbeddedVector& operator=(const EmbeddedVector& rhs) { EmbeddedVector& operator=(const EmbeddedVector& rhs) V8_NOEXCEPT {
if (this == &rhs) return *this; if (this == &rhs) return *this;
Vector<T>::operator=(rhs); Vector<T>::operator=(rhs);
MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize); MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment