diff options
author | clang-format-7.0.1 <adam.martin@10gen.com> | 2019-07-26 18:20:35 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-07-27 11:02:23 -0400 |
commit | 134a4083953270e8a11430395357fb70a29047ad (patch) | |
tree | dd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /src/mongo/base | |
parent | 1e46b5049003f427047e723ea5fab15b5a9253ca (diff) | |
download | mongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz |
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'src/mongo/base')
-rw-r--r-- | src/mongo/base/clonable_ptr.h | 5 | ||||
-rw-r--r-- | src/mongo/base/concept/assignable.h | 8 | ||||
-rw-r--r-- | src/mongo/base/concept/clonable.h | 20 | ||||
-rw-r--r-- | src/mongo/base/concept/clone_factory.h | 22 | ||||
-rw-r--r-- | src/mongo/base/concept/constructible.h | 49 | ||||
-rw-r--r-- | src/mongo/base/concept/convertible_to.h | 16 | ||||
-rw-r--r-- | src/mongo/base/concept/copy_assignable.h | 20 | ||||
-rw-r--r-- | src/mongo/base/concept/copy_constructible.h | 16 | ||||
-rw-r--r-- | src/mongo/base/concept/unique_ptr.h | 50 | ||||
-rw-r--r-- | src/mongo/base/data_type_validated_test.cpp | 2 | ||||
-rw-r--r-- | src/mongo/base/encoded_value_storage_test.cpp | 2 | ||||
-rw-r--r-- | src/mongo/base/global_initializer_registerer.h | 72 | ||||
-rw-r--r-- | src/mongo/base/initializer.h | 16 | ||||
-rw-r--r-- | src/mongo/base/initializer_function.h | 10 | ||||
-rw-r--r-- | src/mongo/base/parse_number_test.cpp | 13 | ||||
-rw-r--r-- | src/mongo/base/unwind_test.cpp | 15 |
16 files changed, 172 insertions, 164 deletions
diff --git a/src/mongo/base/clonable_ptr.h b/src/mongo/base/clonable_ptr.h index 42b0c63c1db..6f6f890e2de 100644 --- a/src/mongo/base/clonable_ptr.h +++ b/src/mongo/base/clonable_ptr.h @@ -264,8 +264,9 @@ public: * NOTE: This constructor is disabled for types with a stateless `CloneFactory` type. */ template <typename CloneFactory_ = CloneFactory> - inline clonable_ptr(typename std::enable_if<!std::is_empty<CloneFactory_>::value, - std::nullptr_t>::type) = delete; + inline clonable_ptr( + typename std::enable_if<!std::is_empty<CloneFactory_>::value, std::nullptr_t>::type) = + delete; /*! * Constructs a pointer to nothing, with a default `CloneFactory`. diff --git a/src/mongo/base/concept/assignable.h b/src/mongo/base/concept/assignable.h index 15fcc555b01..0c3e2d68e59 100644 --- a/src/mongo/base/concept/assignable.h +++ b/src/mongo/base/concept/assignable.h @@ -33,9 +33,9 @@ namespace mongo { namespace concept { -/*! - * The Assignable concept models a type which can be copy assigned and copy constructed. - */ -struct Assignable : CopyConstructible, CopyAssignable {}; + /*! + * The Assignable concept models a type which can be copy assigned and copy constructed. + */ + struct Assignable : CopyConstructible, CopyAssignable {}; } // namespace concept } // namespace mongo diff --git a/src/mongo/base/concept/clonable.h b/src/mongo/base/concept/clonable.h index 63cdceec353..d658b0e5442 100644 --- a/src/mongo/base/concept/clonable.h +++ b/src/mongo/base/concept/clonable.h @@ -33,16 +33,16 @@ namespace mongo { namespace concept { -/*! - * Objects conforming to the Clonable concept can be dynamically copied, using `this->clone()`. - * The Clonable concept does not specify the return type of the `clone()` function. - */ -struct Clonable { - /*! Clonable objects must be safe to destroy, by pointer. */ - virtual ~Clonable() noexcept = 0; + /*! + * Objects conforming to the Clonable concept can be dynamically copied, using `this->clone()`. + * The Clonable concept does not specify the return type of the `clone()` function. + */ + struct Clonable { + /*! Clonable objects must be safe to destroy, by pointer. */ + virtual ~Clonable() noexcept = 0; - /*! Clonable objects can be cloned without knowing the actual dynamic type. */ - Constructible<UniquePtr<Clonable>> clone() const; -}; + /*! Clonable objects can be cloned without knowing the actual dynamic type. */ + Constructible<UniquePtr<Clonable>> clone() const; + }; } // namespace concept } // namespace mongo diff --git a/src/mongo/base/concept/clone_factory.h b/src/mongo/base/concept/clone_factory.h index 5db13c17de9..d263311b79d 100644 --- a/src/mongo/base/concept/clone_factory.h +++ b/src/mongo/base/concept/clone_factory.h @@ -34,16 +34,16 @@ namespace mongo { namespace concept { -/*! - * Objects conforming to the `CloneFactory` concept are function-like constructs which return - * objects that are dynamically allocated copies of their inputs. - * These copies can be made without knowing the actual dynamic type. The `CloneFactory` type itself - * must be `Assignable`, in that it can be used with automatically generated copy constructors and - * copy assignment operators. - */ -template <typename T> -struct CloneFactory : Assignable { - Constructible<UniquePtr<T>> operator()(const T*) const; -}; + /*! + * Objects conforming to the `CloneFactory` concept are function-like constructs which return + * objects that are dynamically allocated copies of their inputs. + * These copies can be made without knowing the actual dynamic type. The `CloneFactory` type + * itself must be `Assignable`, in that it can be used with automatically generated copy + * constructors and copy assignment operators. + */ + template <typename T> + struct CloneFactory : Assignable { + Constructible<UniquePtr<T>> operator()(const T*) const; + }; } // namespace concept } // namespace mongo diff --git a/src/mongo/base/concept/constructible.h b/src/mongo/base/concept/constructible.h index b0f6d81adc5..f725c952d36 100644 --- a/src/mongo/base/concept/constructible.h +++ b/src/mongo/base/concept/constructible.h @@ -35,32 +35,31 @@ namespace mongo { namespace concept { -/** - * The Constructable trait indicates whether `T` is constructible from `Constructible`. - * - * RETURNS: true if `T{ std::declval< Constructible >() }` is a valid expression and false - * otherwise. - */ -template <typename T, typename Constructible, typename = void> -struct is_constructible : std::false_type {}; + /** + * The Constructable trait indicates whether `T` is constructible from `Constructible`. + * + * RETURNS: true if `T{ std::declval< Constructible >() }` is a valid expression and false + * otherwise. + */ + template <typename T, typename Constructible, typename = void> + struct is_constructible : std::false_type {}; -template <typename T, typename Constructible> -struct is_constructible<T, - Constructible, - stdx::void_t<decltype(T{std::declval<Constructible<T>>()})>> - : std::true_type {}; + template <typename T, typename Constructible> + struct is_constructible<T, + Constructible, + stdx::void_t<decltype(T{std::declval<Constructible<T>>()})>> + : std::true_type {}; -/** - * The Constructable concept models a type which can be passed to a single-argument constructor of - * `T`. - * This is not possible to describe in the type `Constructible`. - * - * The expression: `T{ std::declval< Constructible< T > >() }` should be valid. - * - * This concept is more broadly applicable than `ConvertibleTo`. `ConvertibleTo` uses implicit - * conversion, whereas `Constructible` uses direct construction. - */ -template <typename T> -struct Constructible {}; + /** + * The Constructable concept models a type which can be passed to a single-argument constructor + * of `T`. This is not possible to describe in the type `Constructible`. + * + * The expression: `T{ std::declval< Constructible< T > >() }` should be valid. + * + * This concept is more broadly applicable than `ConvertibleTo`. `ConvertibleTo` uses implicit + * conversion, whereas `Constructible` uses direct construction. + */ + template <typename T> + struct Constructible {}; } // namespace concept } // namespace mongo diff --git a/src/mongo/base/concept/convertible_to.h b/src/mongo/base/concept/convertible_to.h index 7cf7e86a73f..9f9187126d5 100644 --- a/src/mongo/base/concept/convertible_to.h +++ b/src/mongo/base/concept/convertible_to.h @@ -30,13 +30,13 @@ namespace mongo { namespace concept { -/** - * The ConvertibleTo concept models a type which can be converted implicitly into a `T`. - * The code: `T x; x= ConvertibleTo< T >{};` should be valid. - */ -template <typename T> -struct ConvertibleTo { - operator T(); -} + /** + * The ConvertibleTo concept models a type which can be converted implicitly into a `T`. + * The code: `T x; x= ConvertibleTo< T >{};` should be valid. + */ + template <typename T> + struct ConvertibleTo { + operator T(); + } } // namespace concept } // namespace mongo diff --git a/src/mongo/base/concept/copy_assignable.h b/src/mongo/base/concept/copy_assignable.h index e89d4699e87..580325564e0 100644 --- a/src/mongo/base/concept/copy_assignable.h +++ b/src/mongo/base/concept/copy_assignable.h @@ -30,17 +30,17 @@ namespace mongo { namespace concept { -/** - * The CopyAssignable concept models a type which can be copy assigned. - * - * The expression: `copyAssignable= copyAssignable` should be valid. - */ -struct CopyAssignable { /** - * The copy assignment operator is required by `CopyAssignable`. - * NOTE: Copy Assignment is only required on lvalue targets of `CopyAssignable`. + * The CopyAssignable concept models a type which can be copy assigned. + * + * The expression: `copyAssignable= copyAssignable` should be valid. */ - CopyAssignable& operator=(const CopyAssignable&) &; -}; + struct CopyAssignable { + /** + * The copy assignment operator is required by `CopyAssignable`. + * NOTE: Copy Assignment is only required on lvalue targets of `CopyAssignable`. + */ + CopyAssignable& operator=(const CopyAssignable&) &; + }; } // namespace concept } // namespace mongo diff --git a/src/mongo/base/concept/copy_constructible.h b/src/mongo/base/concept/copy_constructible.h index 68d8cab494a..689f8e44b71 100644 --- a/src/mongo/base/concept/copy_constructible.h +++ b/src/mongo/base/concept/copy_constructible.h @@ -30,13 +30,13 @@ namespace mongo { namespace concept { -/** - * The CopyConstructable concept models a type which can be copy constructed. - * - * The expression: `CopyConstructible{ copyConstructible }` should be valid. - */ -struct CopyConstructible { - CopyConstructible(const CopyConstructible&); -}; + /** + * The CopyConstructable concept models a type which can be copy constructed. + * + * The expression: `CopyConstructible{ copyConstructible }` should be valid. + */ + struct CopyConstructible { + CopyConstructible(const CopyConstructible&); + }; } // namespace concept } // namespace mongo diff --git a/src/mongo/base/concept/unique_ptr.h b/src/mongo/base/concept/unique_ptr.h index e014a6d8a14..b7518963c54 100644 --- a/src/mongo/base/concept/unique_ptr.h +++ b/src/mongo/base/concept/unique_ptr.h @@ -32,38 +32,38 @@ namespace mongo { namespace concept { -/** - * The `UniquePtr` Concept models a movable owning pointer of an object. - * `std::unique_ptr< T >` is a model of `mongo::concept::UniquePtr< T >`. - */ -template <typename T> -struct UniquePtr { - /** The `UniquePtr< T >` must retire its pointer to `T` on destruction. */ - ~UniquePtr() noexcept; + /** + * The `UniquePtr` Concept models a movable owning pointer of an object. + * `std::unique_ptr< T >` is a model of `mongo::concept::UniquePtr< T >`. + */ + template <typename T> + struct UniquePtr { + /** The `UniquePtr< T >` must retire its pointer to `T` on destruction. */ + ~UniquePtr() noexcept; - UniquePtr(UniquePtr&& p); - UniquePtr& operator=(UniquePtr&& p); + UniquePtr(UniquePtr&& p); + UniquePtr& operator=(UniquePtr&& p); - UniquePtr(); - UniquePtr(T* p); + UniquePtr(); + UniquePtr(T* p); - ConvertibleTo<T*> operator->() const; - T& operator*() const; + ConvertibleTo<T*> operator->() const; + T& operator*() const; - explicit operator bool() const; + explicit operator bool() const; - ConvertibleTo<T*> get() const; + ConvertibleTo<T*> get() const; - void reset() noexcept; - void reset(ConvertibleTo<T*>); -}; + void reset() noexcept; + void reset(ConvertibleTo<T*>); + }; -/*! A `UniquePtr` object must be equality comparable. */ -template <typename T> -bool operator==(const UniquePtr<T>& lhs, const UniquePtr<T>& rhs); + /*! A `UniquePtr` object must be equality comparable. */ + template <typename T> + bool operator==(const UniquePtr<T>& lhs, const UniquePtr<T>& rhs); -/*! A `UniquePtr` object must be inequality comparable. */ -template <typename T> -bool operator!=(const UniquePtr<T>& lhs, const UniquePtr<T>& rhs); + /*! A `UniquePtr` object must be inequality comparable. */ + template <typename T> + bool operator!=(const UniquePtr<T>& lhs, const UniquePtr<T>& rhs); } // namespace concept } // namespace mongo diff --git a/src/mongo/base/data_type_validated_test.cpp b/src/mongo/base/data_type_validated_test.cpp index e6e63f4592a..392ef98989b 100644 --- a/src/mongo/base/data_type_validated_test.cpp +++ b/src/mongo/base/data_type_validated_test.cpp @@ -61,8 +61,8 @@ struct Validator<char> { namespace { using namespace mongo; -using std::end; using std::begin; +using std::end; TEST(DataTypeValidated, SuccessfulValidation) { char buf[1]; diff --git a/src/mongo/base/encoded_value_storage_test.cpp b/src/mongo/base/encoded_value_storage_test.cpp index e9a70a819e3..2a6ed09b5e2 100644 --- a/src/mongo/base/encoded_value_storage_test.cpp +++ b/src/mongo/base/encoded_value_storage_test.cpp @@ -117,7 +117,7 @@ public: Value(ZeroInitTag_t zit) : EncodedValueStorage<Layout, ConstView, View>(zit) {} }; -} +} // namespace EncodedValueStorageTest TEST(EncodedValueStorage, EncodedValueStorage) { EncodedValueStorageTest::Value raw; diff --git a/src/mongo/base/global_initializer_registerer.h b/src/mongo/base/global_initializer_registerer.h index 14345a3f98a..08b0ba625bc 100644 --- a/src/mongo/base/global_initializer_registerer.h +++ b/src/mongo/base/global_initializer_registerer.h @@ -51,42 +51,42 @@ extern const std::string& defaultInitializerName(); class GlobalInitializerRegisterer { public: /** - * Constructor parameters: - * - * - std::string name - * - * - InitializerFunction initFn - * Must be nonnull. - * Example expression: - * - * [](InitializerContext* context) { - * // initialization code - * return Status::OK(); - * } - * - * - DeinitializerFunction deinitFn - * A deinitialization that will execute in reverse order from initialization and - * support re-initialization. If not specified, defaults to the `nullptr` function. - * Example expression: - * - * [](DeinitializerContext* context) { - * // deinitialization code - * return Status::OK(); - * } - * - * - std::vector<std::string> prerequisites - * If not specified, defaults to {"default"}. - * - * - std::vector<std::string> dependents - * If not specified, defaults to {} (no dependents). - * - * - * At run time, the full set of prerequisites for `name` will be computed as the union of the - * `prerequisites` (which can be defaulted) and all other mongo initializers that list `name` in - * their `dependents`. - * - * A non-null `deinitFn` will tag the initializer as supporting re-initialization. - */ + * Constructor parameters: + * + * - std::string name + * + * - InitializerFunction initFn + * Must be nonnull. + * Example expression: + * + * [](InitializerContext* context) { + * // initialization code + * return Status::OK(); + * } + * + * - DeinitializerFunction deinitFn + * A deinitialization that will execute in reverse order from initialization and + * support re-initialization. If not specified, defaults to the `nullptr` function. + * Example expression: + * + * [](DeinitializerContext* context) { + * // deinitialization code + * return Status::OK(); + * } + * + * - std::vector<std::string> prerequisites + * If not specified, defaults to {"default"}. + * + * - std::vector<std::string> dependents + * If not specified, defaults to {} (no dependents). + * + * + * At run time, the full set of prerequisites for `name` will be computed as the union of the + * `prerequisites` (which can be defaulted) and all other mongo initializers that list `name` in + * their `dependents`. + * + * A non-null `deinitFn` will tag the initializer as supporting re-initialization. + */ GlobalInitializerRegisterer(std::string name, InitializerFunction initFn, DeinitializerFunction deinitFn = nullptr, diff --git a/src/mongo/base/initializer.h b/src/mongo/base/initializer.h index eff1500387c..c7297abacbf 100644 --- a/src/mongo/base/initializer.h +++ b/src/mongo/base/initializer.h @@ -97,14 +97,14 @@ Status runGlobalInitializers(int argc, const char* const* argv, const char* cons void runGlobalInitializersOrDie(int argc, const char* const* argv, const char* const* envp); /** -* Run the global deinitializers. They will execute in reverse order from initialization. -* -* It's a programming error for this to fail, but if it does it will return a status other -* than Status::OK. -* -* This means that the few initializers that might want to terminate the program by failing -* should probably arrange to terminate the process themselves. -*/ + * Run the global deinitializers. They will execute in reverse order from initialization. + * + * It's a programming error for this to fail, but if it does it will return a status other + * than Status::OK. + * + * This means that the few initializers that might want to terminate the program by failing + * should probably arrange to terminate the process themselves. + */ Status runGlobalDeinitializers(); } // namespace mongo diff --git a/src/mongo/base/initializer_function.h b/src/mongo/base/initializer_function.h index 2050013c997..05025010a87 100644 --- a/src/mongo/base/initializer_function.h +++ b/src/mongo/base/initializer_function.h @@ -47,11 +47,11 @@ class DeinitializerContext; typedef std::function<Status(InitializerContext*)> InitializerFunction; /** -* A DeinitializerFunction implements the behavior of a deinitializer operation. -* -* On successful execution, a DeinitializerFunction returns Status::OK(). It may -* inspect and mutate the supplied DeinitializerContext. -*/ + * A DeinitializerFunction implements the behavior of a deinitializer operation. + * + * On successful execution, a DeinitializerFunction returns Status::OK(). It may + * inspect and mutate the supplied DeinitializerContext. + */ typedef std::function<Status(DeinitializerContext*)> DeinitializerFunction; diff --git a/src/mongo/base/parse_number_test.cpp b/src/mongo/base/parse_number_test.cpp index d4f42dbbb72..577f2c3b38d 100644 --- a/src/mongo/base/parse_number_test.cpp +++ b/src/mongo/base/parse_number_test.cpp @@ -137,7 +137,10 @@ PARSE_TEST(TestRejectingBadBases) { std::vector<Spec> specs = {{-1, "0"}, {1, "10"}, {37, "-10"}, {-1, " "}, {37, "f"}, {-1, "^%"}}; if (typeid(NumberType) == typeid(double)) { std::vector<Spec> doubleSpecs = { - {8, "0"}, {10, "0"}, {16, "0"}, {36, "0"}, + {8, "0"}, + {10, "0"}, + {16, "0"}, + {36, "0"}, }; std::copy(doubleSpecs.begin(), doubleSpecs.end(), std::back_inserter(specs)); } @@ -156,7 +159,7 @@ PARSE_TEST(TestParsingNonNegatives) { StringData spec; int expectedValue; } specs[] = {{"10", 10}, {"0", 0}, {"1", 1}, {"0xff", 0xff}, {"077", 077}}; - for (const auto[str, expected] : specs) { + for (const auto [str, expected] : specs) { ASSERT_PARSES(NumberType, str, expected); } } @@ -271,7 +274,7 @@ PARSE_TEST(TestSkipLeadingWhitespace) { {"-077", true}}; NumberParser defaultParser; NumberParser skipWs = NumberParser().skipWhitespace(); - for (const auto[numStr, is_negative] : specs) { + for (const auto [numStr, is_negative] : specs) { NumberType expected; bool shouldParse = !is_negative || (is_negative && std::is_signed_v<NumberType>); @@ -322,7 +325,7 @@ PARSE_TEST(TestEndOfNum) { "g", // since the largest inferred base is 16, next non-number character will be g ""}; NumberParser defaultParser; - for (const auto[numStr, is_negative] : specs) { + for (const auto [numStr, is_negative] : specs) { NumberType expected; bool shouldParse = !is_negative || (is_negative && std::is_signed_v<NumberType>); Status parsed = defaultParser(numStr, &expected); @@ -384,7 +387,7 @@ PARSE_TEST(TestSkipLeadingWsAndEndptr) { {"-077", true}}; StringData whitespaces[] = {" ", "", "\t \t", "\r\n\n\t", "\f\v "}; NumberParser defaultParser; - for (const auto[numStr, is_negative] : specs) { + for (const auto [numStr, is_negative] : specs) { NumberType expected; bool shouldParse = !is_negative || (is_negative && std::is_signed_v<NumberType>); Status parsed = defaultParser(numStr, &expected); diff --git a/src/mongo/base/unwind_test.cpp b/src/mongo/base/unwind_test.cpp index 6afea43e89b..7b2e5129d5f 100644 --- a/src/mongo/base/unwind_test.cpp +++ b/src/mongo/base/unwind_test.cpp @@ -135,10 +135,10 @@ void assertTraceContains(const std::string (&names)[size], const std::string sta auto pos = remainder.find(name); if (pos == remainder.npos) { - unittest::log().setIsTruncatable(false) << std::endl - << "--- BEGIN SAMPLE BACKTRACE ---" << std::endl - << std::string(stacktrace) - << "--- END SAMPLE BACKTRACE ---"; + unittest::log().setIsTruncatable(false) + << std::endl + << "--- BEGIN SAMPLE BACKTRACE ---" << std::endl + << std::string(stacktrace) << "--- END SAMPLE BACKTRACE ---"; FAIL("name '{}' is missing or out of order in sample backtrace"_format( std::string(name))); } @@ -149,7 +149,12 @@ void assertTraceContains(const std::string (&names)[size], const std::string sta TEST(Unwind, Demangled) { // Trickery with std::vector<std::function> is to hide from the optimizer. Context ctx{{ - callNext<0>, callNext<1>, callNext<2>, callNext<3>, callNext<4>, callNext<5>, + callNext<0>, + callNext<1>, + callNext<2>, + callNext<3>, + callNext<4>, + callNext<5>, }}; ctx.plan.back()(ctx); // Check that these function names appear in the trace, in order. |