diff --git a/deps/googletest/include/gtest/gtest-assertion-result.h b/deps/googletest/include/gtest/gtest-assertion-result.h index 954e7c40f3af8b..52a6d62c77ec2f 100644 --- a/deps/googletest/include/gtest/gtest-assertion-result.h +++ b/deps/googletest/include/gtest/gtest-assertion-result.h @@ -137,7 +137,7 @@ namespace testing { class [[nodiscard]] AssertionResult; #endif // !SWIG -class GTEST_API_ AssertionResult { +class GTEST_API_ [[nodiscard]] AssertionResult { public: // Copy constructor. // Used in EXPECT_TRUE/FALSE(assertion_result). diff --git a/deps/googletest/include/gtest/gtest-death-test.h b/deps/googletest/include/gtest/gtest-death-test.h index 3c61909726f3c1..afd7b3a4685a01 100644 --- a/deps/googletest/include/gtest/gtest-death-test.h +++ b/deps/googletest/include/gtest/gtest-death-test.h @@ -192,7 +192,7 @@ GTEST_API_ bool InDeathTestChild(); // Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*: // Tests that an exit code describes a normal exit with a given exit code. -class GTEST_API_ ExitedWithCode { +class GTEST_API_ [[nodiscard]] ExitedWithCode { public: explicit ExitedWithCode(int exit_code); ExitedWithCode(const ExitedWithCode&) = default; @@ -206,7 +206,7 @@ class GTEST_API_ ExitedWithCode { #if !defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_FUCHSIA) // Tests that an exit code describes an exit due to termination by a // given signal. -class GTEST_API_ KilledBySignal { +class GTEST_API_ [[nodiscard]] KilledBySignal { public: explicit KilledBySignal(int signum); bool operator()(int exit_status) const; @@ -317,7 +317,7 @@ class GTEST_API_ KilledBySignal { GTEST_LOG_(WARNING) << "Death tests are not supported on this platform.\n" \ << "Statement '" #statement "' cannot be verified."; \ } else if (::testing::internal::AlwaysFalse()) { \ - ::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \ + (void)::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ terminator; \ } else \ diff --git a/deps/googletest/include/gtest/gtest-matchers.h b/deps/googletest/include/gtest/gtest-matchers.h index bd8dfe999d3681..08ffbeb93c976f 100644 --- a/deps/googletest/include/gtest/gtest-matchers.h +++ b/deps/googletest/include/gtest/gtest-matchers.h @@ -75,7 +75,7 @@ namespace testing { // 2. a factory function that creates a Matcher object from a // FooMatcherMatcher. -class MatchResultListener { +class [[nodiscard]] MatchResultListener { public: // Creates a listener object with the given underlying ostream. The // listener does not own the ostream, and does not dereference it @@ -111,7 +111,7 @@ inline MatchResultListener::~MatchResultListener() = default; // An instance of a subclass of this knows how to describe itself as a // matcher. -class GTEST_API_ MatcherDescriberInterface { +class GTEST_API_ [[nodiscard]] MatcherDescriberInterface { public: virtual ~MatcherDescriberInterface() = default; @@ -137,7 +137,7 @@ class GTEST_API_ MatcherDescriberInterface { // The implementation of a matcher. template -class MatcherInterface : public MatcherDescriberInterface { +class [[nodiscard]] MatcherInterface : public MatcherDescriberInterface { public: // Returns true if and only if the matcher matches x; also explains the // match result to 'listener' if necessary (see the next paragraph), in @@ -180,7 +180,7 @@ class MatcherInterface : public MatcherDescriberInterface { namespace internal { // A match result listener that ignores the explanation. -class DummyMatchResultListener : public MatchResultListener { +class [[nodiscard]] DummyMatchResultListener : public MatchResultListener { public: DummyMatchResultListener() : MatchResultListener(nullptr) {} @@ -192,7 +192,7 @@ class DummyMatchResultListener : public MatchResultListener { // A match result listener that forwards the explanation to a given // ostream. The difference between this and MatchResultListener is // that the former is concrete. -class StreamMatchResultListener : public MatchResultListener { +class [[nodiscard]] StreamMatchResultListener : public MatchResultListener { public: explicit StreamMatchResultListener(::std::ostream* os) : MatchResultListener(os) {} @@ -225,7 +225,7 @@ struct SharedPayload : SharedPayloadBase { // from it. We put functionalities common to all Matcher // specializations here to avoid code duplication. template -class MatcherBase : private MatcherDescriberInterface { +class [[nodiscard]] MatcherBase : private MatcherDescriberInterface { public: // Returns true if and only if the matcher matches x; also explains the // match result to 'listener'. @@ -460,7 +460,7 @@ class MatcherBase : private MatcherDescriberInterface { // implementation of Matcher is just a std::shared_ptr to const // MatcherInterface. Don't inherit from Matcher! template -class Matcher : public internal::MatcherBase { +class [[nodiscard]] Matcher : public internal::MatcherBase { public: // Constructs a null matcher. Needed for storing Matcher objects in STL // containers. A default-constructed matcher is not yet initialized. You @@ -491,8 +491,8 @@ class Matcher : public internal::MatcherBase { // instead of Eq(str) and "foo" instead of Eq("foo") when a std::string // matcher is expected. template <> -class GTEST_API_ Matcher - : public internal::MatcherBase { +class GTEST_API_ [[nodiscard]] +Matcher : public internal::MatcherBase { public: Matcher() = default; @@ -513,8 +513,8 @@ class GTEST_API_ Matcher }; template <> -class GTEST_API_ Matcher - : public internal::MatcherBase { +class GTEST_API_ [[nodiscard]] +Matcher : public internal::MatcherBase { public: Matcher() = default; @@ -541,7 +541,7 @@ class GTEST_API_ Matcher // instead of Eq(str) and "foo" instead of Eq("foo") when a absl::string_view // matcher is expected. template <> -class GTEST_API_ Matcher +class GTEST_API_ [[nodiscard]] Matcher : public internal::MatcherBase { public: Matcher() = default; @@ -567,7 +567,7 @@ class GTEST_API_ Matcher }; template <> -class GTEST_API_ Matcher +class GTEST_API_ [[nodiscard]] Matcher : public internal::MatcherBase { public: Matcher() = default; @@ -614,7 +614,7 @@ std::ostream& operator<<(std::ostream& os, const Matcher& matcher) { // // See the definition of NotNull() for a complete example. template -class PolymorphicMatcher { +class [[nodiscard]] PolymorphicMatcher { public: explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {} @@ -689,7 +689,7 @@ namespace internal { // The following template definition assumes that the Rhs parameter is // a "bare" type (i.e. neither 'const T' nor 'T&'). template -class ComparisonBase { +class [[nodiscard]] ComparisonBase { public: explicit ComparisonBase(const Rhs& rhs) : rhs_(rhs) {} @@ -722,7 +722,8 @@ class ComparisonBase { }; template -class EqMatcher : public ComparisonBase, Rhs, std::equal_to<>> { +class [[nodiscard]] EqMatcher + : public ComparisonBase, Rhs, std::equal_to<>> { public: explicit EqMatcher(const Rhs& rhs) : ComparisonBase, Rhs, std::equal_to<>>(rhs) {} @@ -730,7 +731,7 @@ class EqMatcher : public ComparisonBase, Rhs, std::equal_to<>> { static const char* NegatedDesc() { return "isn't equal to"; } }; template -class NeMatcher +class [[nodiscard]] NeMatcher : public ComparisonBase, Rhs, std::not_equal_to<>> { public: explicit NeMatcher(const Rhs& rhs) @@ -739,7 +740,8 @@ class NeMatcher static const char* NegatedDesc() { return "is equal to"; } }; template -class LtMatcher : public ComparisonBase, Rhs, std::less<>> { +class [[nodiscard]] LtMatcher + : public ComparisonBase, Rhs, std::less<>> { public: explicit LtMatcher(const Rhs& rhs) : ComparisonBase, Rhs, std::less<>>(rhs) {} @@ -747,7 +749,8 @@ class LtMatcher : public ComparisonBase, Rhs, std::less<>> { static const char* NegatedDesc() { return "isn't <"; } }; template -class GtMatcher : public ComparisonBase, Rhs, std::greater<>> { +class [[nodiscard]] GtMatcher + : public ComparisonBase, Rhs, std::greater<>> { public: explicit GtMatcher(const Rhs& rhs) : ComparisonBase, Rhs, std::greater<>>(rhs) {} @@ -755,7 +758,7 @@ class GtMatcher : public ComparisonBase, Rhs, std::greater<>> { static const char* NegatedDesc() { return "isn't >"; } }; template -class LeMatcher +class [[nodiscard]] LeMatcher : public ComparisonBase, Rhs, std::less_equal<>> { public: explicit LeMatcher(const Rhs& rhs) @@ -764,7 +767,7 @@ class LeMatcher static const char* NegatedDesc() { return "isn't <="; } }; template -class GeMatcher +class [[nodiscard]] GeMatcher : public ComparisonBase, Rhs, std::greater_equal<>> { public: explicit GeMatcher(const Rhs& rhs) @@ -776,7 +779,7 @@ class GeMatcher // Same as `EqMatcher`, except that the `rhs` is stored as `StoredRhs` and // must be implicitly convertible to `Rhs`. template -class ImplicitCastEqMatcher { +class [[nodiscard]] ImplicitCastEqMatcher { public: explicit ImplicitCastEqMatcher(const StoredRhs& rhs) : stored_rhs_(rhs) {} @@ -809,7 +812,7 @@ using StringLike = T; // Implements polymorphic matchers MatchesRegex(regex) and // ContainsRegex(regex), which can be used as a Matcher as long as // T can be converted to a string. -class MatchesRegexMatcher { +class [[nodiscard]] MatchesRegexMatcher { public: MatchesRegexMatcher(const RE* regex, bool full_match) : regex_(regex), full_match_(full_match) {} diff --git a/deps/googletest/include/gtest/gtest-printers.h b/deps/googletest/include/gtest/gtest-printers.h index 048c32db2e7c2e..d1704bb7580a96 100644 --- a/deps/googletest/include/gtest/gtest-printers.h +++ b/deps/googletest/include/gtest/gtest-printers.h @@ -382,7 +382,7 @@ void PrintWithFallback(const T& value, ::std::ostream* os) { // The default case. template -class FormatForComparison { +class [[nodiscard]] FormatForComparison { public: static ::std::string Format(const ToPrint& value) { return ::testing::PrintToString(value); @@ -391,7 +391,7 @@ class FormatForComparison { // Array. template -class FormatForComparison { +class [[nodiscard]] FormatForComparison { public: static ::std::string Format(const ToPrint* value) { return FormatForComparison::Format(value); @@ -477,7 +477,7 @@ std::string FormatForComparisonFailureMessage(const T1& value, // function template), as we need to partially specialize it for // reference types, which cannot be done with function templates. template -class UniversalPrinter; +class [[nodiscard]] UniversalPrinter; // Prints the given value using the << operator if it has one; // otherwise prints the bytes in it. This is what @@ -889,7 +889,7 @@ void PrintTo(const ::std::pair& value, ::std::ostream* os) { // Implements printing a non-reference type T by letting the compiler // pick the right overload of PrintTo() for T. template -class UniversalPrinter { +class [[nodiscard]] UniversalPrinter { public: // MSVC warns about adding const to a function type, so we want to // disable the warning. @@ -915,11 +915,11 @@ class UniversalPrinter { // Remove any const-qualifiers before passing a type to UniversalPrinter. template -class UniversalPrinter : public UniversalPrinter {}; +class [[nodiscard]] UniversalPrinter : public UniversalPrinter {}; // Printer for std::any template <> -class UniversalPrinter { +class [[nodiscard]] UniversalPrinter { public: static void Print(const std::any& value, ::std::ostream* os) { if (value.has_value()) { @@ -942,7 +942,7 @@ class UniversalPrinter { // Printer for std::optional template -class UniversalPrinter> { +class [[nodiscard]] UniversalPrinter> { public: static void Print(const std::optional& value, ::std::ostream* os) { *os << '('; @@ -956,14 +956,14 @@ class UniversalPrinter> { }; template <> -class UniversalPrinter { +class [[nodiscard]] UniversalPrinter { public: static void Print(std::nullopt_t, ::std::ostream* os) { *os << "(nullopt)"; } }; // Printer for std::variant template -class UniversalPrinter> { +class [[nodiscard]] UniversalPrinter> { public: static void Print(const std::variant& value, ::std::ostream* os) { *os << '('; @@ -1031,7 +1031,7 @@ GTEST_API_ void UniversalPrintArray(const wchar_t* begin, size_t len, // Implements printing an array type T[N]. template -class UniversalPrinter { +class [[nodiscard]] UniversalPrinter { public: // Prints the given array, omitting some elements when there are too // many. @@ -1042,7 +1042,7 @@ class UniversalPrinter { // Implements printing a reference type T&. template -class UniversalPrinter { +class [[nodiscard]] UniversalPrinter { public: // MSVC warns about adding const to a function type, so we want to // disable the warning. @@ -1065,35 +1065,35 @@ class UniversalPrinter { // NUL-terminated string (but not the pointer) is printed. template -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const T& value, ::std::ostream* os) { UniversalPrint(value, os); } }; template -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const T& value, ::std::ostream* os) { UniversalPrint(value, os); } }; template -class UniversalTersePrinter> { +class [[nodiscard]] UniversalTersePrinter> { public: static void Print(std::reference_wrapper value, ::std::ostream* os) { UniversalTersePrinter::Print(value.get(), os); } }; template -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const T (&value)[N], ::std::ostream* os) { UniversalPrinter::Print(value, os); } }; template <> -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const char* str, ::std::ostream* os) { if (str == nullptr) { @@ -1104,12 +1104,12 @@ class UniversalTersePrinter { } }; template <> -class UniversalTersePrinter : public UniversalTersePrinter { -}; +class [[nodiscard]] +UniversalTersePrinter : public UniversalTersePrinter {}; #ifdef __cpp_lib_char8_t template <> -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const char8_t* str, ::std::ostream* os) { if (str == nullptr) { @@ -1120,12 +1120,12 @@ class UniversalTersePrinter { } }; template <> -class UniversalTersePrinter +class [[nodiscard]] UniversalTersePrinter : public UniversalTersePrinter {}; #endif template <> -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const char16_t* str, ::std::ostream* os) { if (str == nullptr) { @@ -1136,11 +1136,11 @@ class UniversalTersePrinter { } }; template <> -class UniversalTersePrinter +class [[nodiscard]] UniversalTersePrinter : public UniversalTersePrinter {}; template <> -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const char32_t* str, ::std::ostream* os) { if (str == nullptr) { @@ -1151,12 +1151,12 @@ class UniversalTersePrinter { } }; template <> -class UniversalTersePrinter +class [[nodiscard]] UniversalTersePrinter : public UniversalTersePrinter {}; #if GTEST_HAS_STD_WSTRING template <> -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(const wchar_t* str, ::std::ostream* os) { if (str == nullptr) { @@ -1169,7 +1169,7 @@ class UniversalTersePrinter { #endif template <> -class UniversalTersePrinter { +class [[nodiscard]] UniversalTersePrinter { public: static void Print(wchar_t* str, ::std::ostream* os) { UniversalTersePrinter::Print(str, os); diff --git a/deps/googletest/include/gtest/gtest-spi.h b/deps/googletest/include/gtest/gtest-spi.h index c0613b6959560b..27c2d660e0d51d 100644 --- a/deps/googletest/include/gtest/gtest-spi.h +++ b/deps/googletest/include/gtest/gtest-spi.h @@ -51,7 +51,7 @@ namespace testing { // generated in the same thread that created this object or it can intercept // all generated failures. The scope of this mock object can be controlled with // the second argument to the two arguments constructor. -class GTEST_API_ ScopedFakeTestPartResultReporter +class GTEST_API_ [[nodiscard]] ScopedFakeTestPartResultReporter : public TestPartResultReporterInterface { public: // The two possible mocking modes of this object. @@ -100,7 +100,7 @@ namespace internal { // TestPartResultArray contains exactly one failure that has the given // type and contains the given substring. If that's not the case, a // non-fatal failure will be generated. -class GTEST_API_ SingleFailureChecker { +class GTEST_API_ [[nodiscard]] SingleFailureChecker { public: // The constructor remembers the arguments. SingleFailureChecker(const TestPartResultArray* results, diff --git a/deps/googletest/include/gtest/gtest-test-part.h b/deps/googletest/include/gtest/gtest-test-part.h index 41c8a9a0d0e31f..90380a973070b9 100644 --- a/deps/googletest/include/gtest/gtest-test-part.h +++ b/deps/googletest/include/gtest/gtest-test-part.h @@ -51,7 +51,7 @@ namespace testing { // assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()). // // Don't inherit from TestPartResult as its destructor is not virtual. -class GTEST_API_ TestPartResult { +class GTEST_API_ [[nodiscard]] TestPartResult { public: // The possible outcomes of a test part (i.e. an assertion or an // explicit SUCCEED(), FAIL(), or ADD_FAILURE()). @@ -131,7 +131,7 @@ std::ostream& operator<<(std::ostream& os, const TestPartResult& result); // // Don't inherit from TestPartResultArray as its destructor is not // virtual. -class GTEST_API_ TestPartResultArray { +class GTEST_API_ [[nodiscard]] TestPartResultArray { public: TestPartResultArray() = default; @@ -152,7 +152,7 @@ class GTEST_API_ TestPartResultArray { }; // This interface knows how to report a test part result. -class GTEST_API_ TestPartResultReporterInterface { +class GTEST_API_ [[nodiscard]] TestPartResultReporterInterface { public: virtual ~TestPartResultReporterInterface() = default; @@ -167,7 +167,7 @@ namespace internal { // reported, it only delegates the reporting to the former result reporter. // The original result reporter is restored in the destructor. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. -class GTEST_API_ HasNewFatalFailureHelper +class GTEST_API_ [[nodiscard]] HasNewFatalFailureHelper : public TestPartResultReporterInterface { public: HasNewFatalFailureHelper(); diff --git a/deps/googletest/include/gtest/gtest-typed-test.h b/deps/googletest/include/gtest/gtest-typed-test.h index ae24f94915d004..8575a41076ed0f 100644 --- a/deps/googletest/include/gtest/gtest-typed-test.h +++ b/deps/googletest/include/gtest/gtest-typed-test.h @@ -45,7 +45,7 @@ // First, define a fixture class template. It should be parameterized // by a type. Remember to derive it from testing::Test. template -class FooTest : public testing::Test { +class [[nodiscard]] FooTest : public testing::Test { public: ... using List = ::std::list; @@ -123,7 +123,7 @@ TYPED_TEST(FooTest, HasPropertyA) { ... } // First, define a fixture class template. It should be parameterized // by a type. Remember to derive it from testing::Test. template -class FooTest : public testing::Test { +class [[nodiscard]] FooTest : public testing::Test { ... }; diff --git a/deps/googletest/include/gtest/gtest.h b/deps/googletest/include/gtest/gtest.h index 69994ee9dc3a36..b63685380c8a14 100644 --- a/deps/googletest/include/gtest/gtest.h +++ b/deps/googletest/include/gtest/gtest.h @@ -193,7 +193,7 @@ std::set* GetIgnoredParameterizedTestSuites(); // A base class that prevents subclasses from being copyable. // We do this instead of using '= delete' so as to avoid triggering warnings // inside user code regarding any of our declarations. -class GTestNonCopyable { +class [[nodiscard]] GTestNonCopyable { public: GTestNonCopyable() = default; GTestNonCopyable(const GTestNonCopyable&) = delete; @@ -206,15 +206,15 @@ class GTestNonCopyable { // The friend relationship of some of these classes is cyclic. // If we don't forward declare them the compiler might confuse the classes // in friendship clauses with same named classes on the scope. -class Test; -class TestSuite; +class [[nodiscard]] Test; +class [[nodiscard]] TestSuite; // Old API is still available but deprecated #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ using TestCase = TestSuite; #endif -class TestInfo; -class UnitTest; +class [[nodiscard]] TestInfo; +class [[nodiscard]] UnitTest; // The abstract class that all tests inherit from. // @@ -239,7 +239,7 @@ class UnitTest; // TEST_F(FooTest, Baz) { ... } // // Test is not copyable. -class GTEST_API_ Test { +class GTEST_API_ [[nodiscard]] Test { public: friend class TestInfo; @@ -366,7 +366,7 @@ typedef internal::TimeInMillis TimeInMillis; // output as a key/value string pair. // // Don't inherit from TestProperty as its destructor is not virtual. -class TestProperty { +class [[nodiscard]] TestProperty { public: // C'tor. TestProperty does NOT have a default constructor. // Always use this constructor (with parameters) to create a @@ -396,7 +396,7 @@ class TestProperty { // the Test. // // TestResult is not copyable. -class GTEST_API_ TestResult { +class GTEST_API_ [[nodiscard]] TestResult { public: // Creates an empty TestResult. TestResult(); @@ -530,7 +530,7 @@ class GTEST_API_ TestResult { // The constructor of TestInfo registers itself with the UnitTest // singleton such that the RUN_ALL_TESTS() macro knows which tests to // run. -class GTEST_API_ TestInfo { +class GTEST_API_ [[nodiscard]] TestInfo { public: // Destructs a TestInfo object. This function is not virtual, so // don't inherit from TestInfo. @@ -669,7 +669,7 @@ class GTEST_API_ TestInfo { // A test suite, which consists of a vector of TestInfos. // // TestSuite is not copyable. -class GTEST_API_ TestSuite { +class GTEST_API_ [[nodiscard]] TestSuite { public: // Creates a TestSuite with the given name. // @@ -890,7 +890,7 @@ class GTEST_API_ TestSuite { // available. // 2. You cannot use ASSERT_* directly in a constructor or // destructor. -class Environment { +class [[nodiscard]] Environment { public: // The d'tor is virtual as we need to subclass Environment. virtual ~Environment() = default; @@ -911,7 +911,7 @@ class Environment { #if GTEST_HAS_EXCEPTIONS // Exception which can be thrown from TestEventListener::OnTestPartResult. -class GTEST_API_ AssertionException +class GTEST_API_ [[nodiscard]] AssertionException : public internal::GoogleTestFailureException { public: explicit AssertionException(const TestPartResult& result) @@ -922,7 +922,7 @@ class GTEST_API_ AssertionException // The interface for tracing execution of tests. The methods are organized in // the order the corresponding events are fired. -class TestEventListener { +class [[nodiscard]] TestEventListener { public: virtual ~TestEventListener() = default; @@ -989,7 +989,7 @@ class TestEventListener { // the methods they override will not be caught during the build. For // comments about each method please see the definition of TestEventListener // above. -class EmptyTestEventListener : public TestEventListener { +class [[nodiscard]] EmptyTestEventListener : public TestEventListener { public: void OnTestProgramStart(const UnitTest& /*unit_test*/) override {} void OnTestIterationStart(const UnitTest& /*unit_test*/, @@ -1019,7 +1019,7 @@ class EmptyTestEventListener : public TestEventListener { }; // TestEventListeners lets users add listeners to track events in Google Test. -class GTEST_API_ TestEventListeners { +class GTEST_API_ [[nodiscard]] TestEventListeners { public: TestEventListeners(); ~TestEventListeners(); @@ -1110,7 +1110,7 @@ class GTEST_API_ TestEventListeners { // // This class is thread-safe as long as the methods are called // according to their specification. -class GTEST_API_ UnitTest { +class GTEST_API_ [[nodiscard]] UnitTest { public: // Gets the singleton UnitTest object. The first time this method // is called, a UnitTest object is constructed and returned. @@ -1398,7 +1398,7 @@ AssertionResult CmpHelperEQ(const char* lhs_expression, return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs); } -class EqHelper { +class [[nodiscard]] EqHelper { public: // This templatized version is for the general case. template < @@ -1614,7 +1614,7 @@ using GoogleTest_NotSupported_OnFunctionReturningNonVoid = void; // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // A class that enables one to stream messages to assertion macros -class GTEST_API_ AssertHelper { +class GTEST_API_ [[nodiscard]] AssertHelper { public: // Constructor. AssertHelper(TestPartResult::Type type, const char* file, int line, @@ -1689,7 +1689,7 @@ class GTEST_API_ AssertHelper { // INSTANTIATE_TEST_SUITE_P(OneToTenRange, FooTest, ::testing::Range(1, 10)); template -class WithParamInterface { +class [[nodiscard]] WithParamInterface { public: typedef T ParamType; virtual ~WithParamInterface() = default; @@ -1723,7 +1723,8 @@ const T* WithParamInterface::parameter_ = nullptr; // WithParamInterface, and can just inherit from ::testing::TestWithParam. template -class TestWithParam : public Test, public WithParamInterface {}; +class [[nodiscard]] TestWithParam : public Test, + public WithParamInterface {}; // Macros for indicating success/failure in test code. @@ -2071,7 +2072,7 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2, // Example: // testing::ScopedTrace trace("file.cc", 123, "message"); // -class GTEST_API_ ScopedTrace { +class GTEST_API_ [[nodiscard]] ScopedTrace { public: // The c'tor pushes the given source file location and message onto // a trace stack maintained by Google Test. diff --git a/deps/googletest/include/gtest/internal/gtest-death-test-internal.h b/deps/googletest/include/gtest/internal/gtest-death-test-internal.h index b363259ec60203..6013a57bfe9f69 100644 --- a/deps/googletest/include/gtest/internal/gtest-death-test-internal.h +++ b/deps/googletest/include/gtest/internal/gtest-death-test-internal.h @@ -96,7 +96,7 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ // by wait(2) // exit code: The integer code passed to exit(3), _Exit(2), or // returned from main() -class GTEST_API_ DeathTest { +class GTEST_API_ [[nodiscard]] DeathTest { public: // Create returns false if there was an error determining the // appropriate action to take for the current death test; for example, @@ -172,7 +172,7 @@ class GTEST_API_ DeathTest { GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 // Factory interface for death tests. May be mocked out for testing. -class DeathTestFactory { +class [[nodiscard]] DeathTestFactory { public: virtual ~DeathTestFactory() = default; virtual bool Create(const char* statement, @@ -181,7 +181,7 @@ class DeathTestFactory { }; // A concrete DeathTestFactory implementation for normal use. -class DefaultDeathTestFactory : public DeathTestFactory { +class [[nodiscard]] DefaultDeathTestFactory : public DeathTestFactory { public: bool Create(const char* statement, Matcher matcher, const char* file, int line, DeathTest** test) override; @@ -256,19 +256,19 @@ GTEST_API_ bool ExitedUnsuccessfully(int exit_status); // must accept a streamed message even though the message is never printed. // The regex object is not evaluated, but it is used to prevent "unused" // warnings and to avoid an expression that doesn't compile in debug mode. -#define GTEST_EXECUTE_STATEMENT_(statement, regex_or_matcher) \ - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ - if (::testing::internal::AlwaysTrue()) { \ - GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ - } else if (!::testing::internal::AlwaysTrue()) { \ - ::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \ - } else \ +#define GTEST_EXECUTE_STATEMENT_(statement, regex_or_matcher) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } else if (!::testing::internal::AlwaysTrue()) { \ + (void)::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \ + } else \ ::testing::Message() // A class representing the parsed contents of the // --gtest_internal_run_death_test flag, as it existed when // RUN_ALL_TESTS was called. -class InternalRunDeathTestFlag { +class [[nodiscard]] InternalRunDeathTestFlag { public: InternalRunDeathTestFlag(const std::string& a_file, int a_line, int an_index, int a_write_fd) diff --git a/deps/googletest/include/gtest/internal/gtest-filepath.h b/deps/googletest/include/gtest/internal/gtest-filepath.h index 6dc47be54ad3e7..4dc00ee7b31503 100644 --- a/deps/googletest/include/gtest/internal/gtest-filepath.h +++ b/deps/googletest/include/gtest/internal/gtest-filepath.h @@ -67,7 +67,7 @@ namespace internal { // Names are NOT checked for syntax correctness -- no checking for illegal // characters, malformed paths, etc. -class GTEST_API_ FilePath { +class GTEST_API_ [[nodiscard]] FilePath { public: FilePath() : pathname_("") {} FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) {} diff --git a/deps/googletest/include/gtest/internal/gtest-internal.h b/deps/googletest/include/gtest/internal/gtest-internal.h index 808d89be91439a..4379137d77eba3 100644 --- a/deps/googletest/include/gtest/internal/gtest-internal.h +++ b/deps/googletest/include/gtest/internal/gtest-internal.h @@ -95,7 +95,7 @@ #define GTEST_STRINGIFY_(...) GTEST_STRINGIFY_HELPER_(__VA_ARGS__, ) namespace proto2 { -class MessageLite; +class [[nodiscard]] MessageLite; } namespace testing { @@ -115,15 +115,15 @@ ::std::string PrintToString(const T& value); namespace internal { struct TraceInfo; // Information about a trace point. -class TestInfoImpl; // Opaque implementation of TestInfo -class UnitTestImpl; // Opaque implementation of UnitTest +class [[nodiscard]] TestInfoImpl; // Opaque implementation of TestInfo +class [[nodiscard]] UnitTestImpl; // Opaque implementation of UnitTest // The text used in failure messages to indicate the start of the // stack trace. GTEST_API_ extern const char kStackTraceMarker[]; // An IgnoredValue object can be implicitly constructed from ANY value. -class IgnoredValue { +class [[nodiscard]] IgnoredValue { struct Sink {}; public: @@ -155,7 +155,8 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_( // errors presumably detectable only at run time. Since // std::runtime_error inherits from std::exception, many testing // frameworks know how to extract and print the message inside it. -class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error { +class GTEST_API_ [[nodiscard]] GoogleTestFailureException + : public ::std::runtime_error { public: explicit GoogleTestFailureException(const TestPartResult& failure); }; @@ -242,7 +243,7 @@ GTEST_API_ std::string GetBoolAssertionFailureMessage( // // RawType: the raw floating-point type (either float or double) template -class FloatingPoint { +class [[nodiscard]] FloatingPoint { public: // Defines the unsigned integer type that has the same size as the // floating point number. @@ -392,7 +393,7 @@ typedef FloatingPoint Double; typedef const void* TypeId; template -class TypeIdHelper { +class [[nodiscard]] TypeIdHelper { public: // dummy_ must not have a const type. Otherwise an overly eager // compiler (e.g. MSVC 7.1 & 8.0) may try to merge @@ -424,7 +425,7 @@ GTEST_API_ TypeId GetTestTypeId(); // Defines the abstract factory interface that creates instances // of a Test object. -class TestFactoryBase { +class [[nodiscard]] TestFactoryBase { public: virtual ~TestFactoryBase() = default; @@ -443,7 +444,7 @@ class TestFactoryBase { // This class provides implementation of TestFactoryBase interface. // It is used in TEST and TEST_F macros. template -class TestFactoryImpl : public TestFactoryBase { +class [[nodiscard]] TestFactoryImpl : public TestFactoryBase { public: Test* CreateTest() override { return new TestClass; } }; @@ -570,7 +571,7 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ /* class A needs to have dll-interface to be used by clients of class B */) // State of the definition of a type-parameterized test suite. -class GTEST_API_ TypedTestSuitePState { +class GTEST_API_ [[nodiscard]] TypedTestSuitePState { public: TypedTestSuitePState() : registered_(false) {} @@ -685,7 +686,7 @@ std::vector GenerateNames() { // Implementation note: The GTEST_TEMPLATE_ macro declares a template // template parameter. It's defined in gtest-type-util.h. template -class TypeParameterizedTest { +class [[nodiscard]] TypeParameterizedTest { public: // 'index' is the index of the test in the type list 'Types' // specified in INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, TestSuite, @@ -723,7 +724,7 @@ class TypeParameterizedTest { // The base case for the compile time recursion. template -class TypeParameterizedTest { +class [[nodiscard]] TypeParameterizedTest { public: static bool Register(const char* /*prefix*/, CodeLocation, const char* /*case_name*/, const char* /*test_names*/, @@ -744,7 +745,7 @@ GTEST_API_ void RegisterTypeParameterizedTestSuiteInstantiation( // Test. The return value is insignificant - we just need to return // something such that we can call this function in a namespace scope. template -class TypeParameterizedTestSuite { +class [[nodiscard]] TypeParameterizedTestSuite { public: static bool Register(const char* prefix, CodeLocation code_location, const TypedTestSuitePState* state, const char* case_name, @@ -782,7 +783,7 @@ class TypeParameterizedTestSuite { // The base case for the compile time recursion. template -class TypeParameterizedTestSuite { +class [[nodiscard]] TypeParameterizedTestSuite { public: static bool Register(const char* /*prefix*/, const CodeLocation&, const TypedTestSuitePState* /*state*/, @@ -838,7 +839,7 @@ struct TrueWithString { // doesn't use global state (and therefore can't interfere with user // code). Unlike rand_r(), it's portable. An LCG isn't very random, // but it's good enough for our purposes. -class GTEST_API_ Random { +class GTEST_API_ [[nodiscard]] Random { public: static const uint32_t kMaxRange = 1u << 31; @@ -864,7 +865,7 @@ class GTEST_API_ Random { // that's true if and only if T has methods DebugString() and ShortDebugString() // that return std::string. template -class HasDebugStringAndShortDebugString { +class [[nodiscard]] HasDebugStringAndShortDebugString { private: template static auto CheckDebugString(C*) -> typename std::is_same< @@ -1064,7 +1065,7 @@ struct RelationToSourceCopy {}; // this requirement. Element can be an array type itself (hence // multi-dimensional arrays are supported). template -class NativeArray { +class [[nodiscard]] NativeArray { public: // STL-style container typedefs. typedef Element value_type; @@ -1150,7 +1151,7 @@ struct ElemFromList { struct FlatTupleConstructTag {}; template -class FlatTuple; +class [[nodiscard]] FlatTuple; template struct FlatTupleElemBase; @@ -1209,7 +1210,7 @@ struct FlatTupleBase, std::index_sequence> // std::make_index_sequence, on the other hand, it is recursive but with an // instantiation depth of O(ln(N)). template -class FlatTuple +class [[nodiscard]] FlatTuple : private FlatTupleBase, std::make_index_sequence> { using Indices = @@ -1317,7 +1318,7 @@ struct tuple_size> namespace testing { namespace internal { -class NeverThrown { +class [[nodiscard]] NeverThrown { public: const char* what() const noexcept { return "this exception should never be thrown"; diff --git a/deps/googletest/include/gtest/internal/gtest-param-util.h b/deps/googletest/include/gtest/internal/gtest-param-util.h index a092a86adab27d..716779346a012d 100644 --- a/deps/googletest/include/gtest/internal/gtest-param-util.h +++ b/deps/googletest/include/gtest/internal/gtest-param-util.h @@ -90,14 +90,14 @@ GTEST_API_ void ReportInvalidTestSuiteType(const char* test_suite_name, const CodeLocation& code_location); template -class ParamGeneratorInterface; +class [[nodiscard]] ParamGeneratorInterface; template -class ParamGenerator; +class [[nodiscard]] ParamGenerator; // Interface for iterating over elements provided by an implementation // of ParamGeneratorInterface. template -class ParamIteratorInterface { +class [[nodiscard]] ParamIteratorInterface { public: virtual ~ParamIteratorInterface() = default; // A pointer to the base generator instance. @@ -127,7 +127,7 @@ class ParamIteratorInterface { // ParamGeneratorInterface. It wraps ParamIteratorInterface // and implements the const forward iterator concept. template -class ParamIterator { +class [[nodiscard]] ParamIterator { public: typedef T value_type; typedef const T& reference; @@ -169,7 +169,7 @@ class ParamIterator { // ParamGeneratorInterface is the binary interface to access generators // defined in other translation units. template -class ParamGeneratorInterface { +class [[nodiscard]] ParamGeneratorInterface { public: typedef T ParamType; @@ -186,7 +186,7 @@ class ParamGeneratorInterface { // ParamGeneratorInterface instance is shared among all copies // of the original object. This is possible because that instance is immutable. template -class ParamGenerator { +class [[nodiscard]] ParamGenerator { public: typedef ParamIterator iterator; @@ -210,7 +210,7 @@ class ParamGenerator { // operator<(). // This class is used in the Range() function. template -class RangeGenerator : public ParamGeneratorInterface { +class [[nodiscard]] RangeGenerator : public ParamGeneratorInterface { public: RangeGenerator(T begin, T end, IncrementT step) : begin_(begin), @@ -296,7 +296,8 @@ class RangeGenerator : public ParamGeneratorInterface { // since the source can be located on the stack, and the generator // is likely to persist beyond that stack frame. template -class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface { +class [[nodiscard]] ValuesInIteratorRangeGenerator + : public ParamGeneratorInterface { public: template ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end) @@ -396,7 +397,7 @@ void TestNotEmpty(const T&) {} // Stores a parameter value and later creates tests parameterized with that // value. template -class ParameterizedTestFactory : public TestFactoryBase { +class [[nodiscard]] ParameterizedTestFactory : public TestFactoryBase { public: typedef typename TestClass::ParamType ParamType; explicit ParameterizedTestFactory(ParamType parameter) @@ -418,7 +419,7 @@ class ParameterizedTestFactory : public TestFactoryBase { // TestMetaFactoryBase is a base class for meta-factories that create // test factories for passing into MakeAndRegisterTestInfo function. template -class TestMetaFactoryBase { +class [[nodiscard]] TestMetaFactoryBase { public: virtual ~TestMetaFactoryBase() = default; @@ -434,7 +435,7 @@ class TestMetaFactoryBase { // it for each Test/Parameter value combination. Thus it needs meta factory // creator class. template -class TestMetaFactory +class [[nodiscard]] TestMetaFactory : public TestMetaFactoryBase { public: using ParamType = typename TestSuite::ParamType; @@ -460,7 +461,7 @@ class TestMetaFactory // in RegisterTests method. The ParameterizeTestSuiteRegistry class holds // a collection of pointers to the ParameterizedTestSuiteInfo objects // and calls RegisterTests() on each of them when asked. -class ParameterizedTestSuiteInfoBase { +class [[nodiscard]] ParameterizedTestSuiteInfoBase { public: virtual ~ParameterizedTestSuiteInfoBase() = default; @@ -503,7 +504,8 @@ GTEST_API_ void InsertSyntheticTestCase(const std::string& name, // test suite. It registers tests with all values generated by all // generators when asked. template -class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase { +class [[nodiscard]] ParameterizedTestSuiteInfo + : public ParameterizedTestSuiteInfoBase { public: // ParamType and GeneratorCreationFunc are private types but are required // for declarations of public methods AddTestPattern() and @@ -688,7 +690,7 @@ using ParameterizedTestCaseInfo = ParameterizedTestSuiteInfo; // ParameterizedTestSuiteInfoBase classes accessed by test suite names. TEST_P // and INSTANTIATE_TEST_SUITE_P macros use it to locate their corresponding // ParameterizedTestSuiteInfo descriptors. -class ParameterizedTestSuiteRegistry { +class [[nodiscard]] ParameterizedTestSuiteRegistry { public: ParameterizedTestSuiteRegistry() = default; ~ParameterizedTestSuiteRegistry() { @@ -762,7 +764,7 @@ class ParameterizedTestSuiteRegistry { // Keep track of what type-parameterized test suite are defined and // where as well as which are intatiated. This allows susequently // identifying suits that are defined but never used. -class TypeParameterizedTestSuiteRegistry { +class [[nodiscard]] TypeParameterizedTestSuiteRegistry { public: // Add a suite definition void RegisterTestSuite(const char* test_suite_name, @@ -801,7 +803,7 @@ namespace internal { GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100) template -class ValueArray { +class [[nodiscard]] ValueArray { public: explicit ValueArray(Ts... v) : v_(FlatTupleConstructTag{}, std::move(v)...) {} @@ -822,7 +824,7 @@ class ValueArray { GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100 template -class CartesianProductGenerator +class [[nodiscard]] CartesianProductGenerator : public ParamGeneratorInterface<::std::tuple> { public: typedef ::std::tuple ParamType; @@ -939,7 +941,7 @@ class CartesianProductGenerator }; template -class CartesianProductHolder { +class [[nodiscard]] CartesianProductHolder { public: CartesianProductHolder(const Gen&... g) : generators_(g...) {} template @@ -953,7 +955,8 @@ class CartesianProductHolder { }; template -class ParamGeneratorConverter : public ParamGeneratorInterface { +class [[nodiscard]] ParamGeneratorConverter + : public ParamGeneratorInterface { public: ParamGeneratorConverter(ParamGenerator gen, Func converter) // NOLINT : generator_(std::move(gen)), converter_(std::move(converter)) {} @@ -1023,7 +1026,7 @@ class ParamGeneratorConverter : public ParamGeneratorInterface { template > -class ParamConverterGenerator { +class [[nodiscard]] ParamConverterGenerator { public: ParamConverterGenerator(ParamGenerator g) // NOLINT : generator_(std::move(g)), converter_(Identity) {} diff --git a/deps/googletest/include/gtest/internal/gtest-port.h b/deps/googletest/include/gtest/internal/gtest-port.h index d433f05459c76a..f6394a00728205 100644 --- a/deps/googletest/include/gtest/internal/gtest-port.h +++ b/deps/googletest/include/gtest/internal/gtest-port.h @@ -827,6 +827,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #elif defined(GTEST_CREATE_SHARED_LIBRARY) && GTEST_CREATE_SHARED_LIBRARY #define GTEST_API_ __declspec(dllexport) #endif +#elif GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(gnu::visibility) +#define GTEST_API_ [[gnu::visibility("default")]] #elif GTEST_HAVE_ATTRIBUTE_(visibility) #define GTEST_API_ __attribute__((visibility("default"))) #endif // _MSC_VER @@ -917,7 +919,7 @@ namespace internal { // A secret type that Google Test users don't know about. It has no // accessible constructors on purpose. Therefore it's impossible to create a // Secret object, which is what we want. -class Secret { +class [[nodiscard]] Secret { Secret(const Secret&) = delete; }; @@ -932,7 +934,7 @@ GTEST_API_ bool IsTrue(bool condition); // This is almost `using RE = ::RE2`, except it is copy-constructible, and it // needs to disambiguate the `std::string`, `absl::string_view`, and `const // char*` constructors. -class GTEST_API_ RE { +class GTEST_API_ [[nodiscard]] RE { public: RE(absl::string_view regex) : regex_(regex) {} // NOLINT RE(const char* regex) : RE(absl::string_view(regex)) {} // NOLINT @@ -958,7 +960,7 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ // A simple C++ wrapper for . It uses the POSIX Extended // Regular Expression syntax. -class GTEST_API_ RE { +class GTEST_API_ [[nodiscard]] RE { public: // A copy constructor is required by the Standard to initialize object // references from r-values. @@ -1027,7 +1029,7 @@ enum GTestLogSeverity { GTEST_INFO, GTEST_WARNING, GTEST_ERROR, GTEST_FATAL }; // Formats log entry severity, provides a stream object for streaming the // log message, and terminates the message with a newline when going out of // scope. -class GTEST_API_ GTestLog { +class GTEST_API_ [[nodiscard]] GTestLog { public: GTestLog(GTestLogSeverity severity, const char* file, int line); @@ -1190,7 +1192,7 @@ void ClearInjectableArgvs(); #ifdef GTEST_OS_WINDOWS // Provides leak-safe Windows kernel handle ownership. // Used in death tests and in threading support. -class GTEST_API_ AutoHandle { +class GTEST_API_ [[nodiscard]] AutoHandle { public: // Assume that Win32 HANDLE type is equivalent to void*. Doing so allows us to // avoid including in this header file. Including is @@ -1234,7 +1236,7 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ // This class is only for testing Google Test's own constructs. Do not // use it in user tests, either directly or indirectly. // TODO(b/203539622): Replace unconditionally with absl::Notification. -class GTEST_API_ Notification { +class GTEST_API_ [[nodiscard]] Notification { public: Notification() : notified_(false) {} Notification(const Notification&) = delete; @@ -1273,7 +1275,7 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 // in order to call its Run(). Introducing ThreadWithParamBase as a // non-templated base class for ThreadWithParam allows us to bypass this // problem. -class ThreadWithParamBase { +class [[nodiscard]] ThreadWithParamBase { public: virtual ~ThreadWithParamBase() = default; virtual void Run() = 0; @@ -1303,7 +1305,7 @@ extern "C" inline void* ThreadFuncWithCLinkage(void* thread) { // These classes are only for testing Google Test's own constructs. Do // not use them in user tests, either directly or indirectly. template -class ThreadWithParam : public ThreadWithParamBase { +class [[nodiscard]] ThreadWithParam : public ThreadWithParamBase { public: typedef void UserThreadFunc(T); @@ -1369,7 +1371,7 @@ class ThreadWithParam : public ThreadWithParamBase { // GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex); // // (A non-static Mutex is defined/declared in the usual way). -class GTEST_API_ Mutex { +class GTEST_API_ [[nodiscard]] Mutex { public: enum MutexType { kStatic = 0, kDynamic = 1 }; // We rely on kStaticMutex being 0 as it is to what the linker initializes @@ -1422,7 +1424,7 @@ class GTEST_API_ Mutex { // platforms. That macro is used as a defensive measure to prevent against // inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than // "MutexLock l(&mu)". Hence the typedef trick below. -class GTestMutexLock { +class [[nodiscard]] GTestMutexLock { public: explicit GTestMutexLock(Mutex& mutex) : mutex_(mutex) { mutex_.lock(); } ~GTestMutexLock() { mutex_.unlock(); } @@ -1438,14 +1440,14 @@ typedef GTestMutexLock MutexLock; // Base class for ValueHolder. Allows a caller to hold and delete a value // without knowing its type. -class ThreadLocalValueHolderBase { +class [[nodiscard]] ThreadLocalValueHolderBase { public: virtual ~ThreadLocalValueHolderBase() {} }; // Provides a way for a thread to send notifications to a ThreadLocal // regardless of its parameter type. -class ThreadLocalBase { +class [[nodiscard]] ThreadLocalBase { public: // Creates a new ValueHolder object holding a default value passed to // this ThreadLocal's constructor and returns it. It is the caller's @@ -1465,7 +1467,7 @@ class ThreadLocalBase { // Maps a thread to a set of ThreadLocals that have values instantiated on that // thread and notifies them when the thread exits. A ThreadLocal instance is // expected to persist until all threads it has values on have terminated. -class GTEST_API_ ThreadLocalRegistry { +class GTEST_API_ [[nodiscard]] ThreadLocalRegistry { public: // Registers thread_local_instance as having value on the current thread. // Returns a value that can be used to identify the thread from other threads. @@ -1477,7 +1479,7 @@ class GTEST_API_ ThreadLocalRegistry { const ThreadLocalBase* thread_local_instance); }; -class GTEST_API_ ThreadWithParamBase { +class GTEST_API_ [[nodiscard]] ThreadWithParamBase { public: void Join(); @@ -1497,7 +1499,7 @@ class GTEST_API_ ThreadWithParamBase { // Helper class for testing Google Test's multi-threading constructs. template -class ThreadWithParam : public ThreadWithParamBase { +class [[nodiscard]] ThreadWithParam : public ThreadWithParamBase { public: typedef void UserThreadFunc(T); @@ -1552,7 +1554,7 @@ class ThreadWithParam : public ThreadWithParamBase { // object managed by Google Test will be leaked as long as all threads // using Google Test have exited when main() returns. template -class ThreadLocal : public ThreadLocalBase { +class [[nodiscard]] ThreadLocal : public ThreadLocalBase { public: ThreadLocal() : default_factory_(new DefaultValueHolderFactory()) {} explicit ThreadLocal(const T& value) @@ -1637,7 +1639,7 @@ class ThreadLocal : public ThreadLocalBase { #elif GTEST_HAS_PTHREAD // MutexBase and Mutex implement mutex on pthreads-based platforms. -class MutexBase { +class [[nodiscard]] MutexBase { public: // Acquires this mutex. void lock() { @@ -1695,7 +1697,7 @@ class MutexBase { // The Mutex class can only be used for mutexes created at runtime. It // shares its API with MutexBase otherwise. -class Mutex : public MutexBase { +class [[nodiscard]] Mutex : public MutexBase { public: Mutex() { GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr)); @@ -1713,7 +1715,7 @@ class Mutex : public MutexBase { // platforms. That macro is used as a defensive measure to prevent against // inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than // "MutexLock l(&mu)". Hence the typedef trick below. -class GTestMutexLock { +class [[nodiscard]] GTestMutexLock { public: explicit GTestMutexLock(MutexBase& mutex) : mutex_(mutex) { mutex_.lock(); } ~GTestMutexLock() { mutex_.unlock(); } @@ -1733,7 +1735,7 @@ typedef GTestMutexLock MutexLock; // C-linkage. Therefore it cannot be templatized to access // ThreadLocal. Hence the need for class // ThreadLocalValueHolderBase. -class GTEST_API_ ThreadLocalValueHolderBase { +class GTEST_API_ [[nodiscard]] ThreadLocalValueHolderBase { public: virtual ~ThreadLocalValueHolderBase() = default; }; @@ -1746,7 +1748,7 @@ extern "C" inline void DeleteThreadLocalValue(void* value_holder) { // Implements thread-local storage on pthreads-based systems. template -class GTEST_API_ ThreadLocal { +class GTEST_API_ [[nodiscard]] ThreadLocal { public: ThreadLocal() : key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {} @@ -1859,7 +1861,7 @@ class GTEST_API_ ThreadLocal { // mutex is not supported - using Google Test in multiple threads is not // supported on such platforms. -class Mutex { +class [[nodiscard]] Mutex { public: Mutex() {} void lock() {} @@ -1877,7 +1879,7 @@ class Mutex { // platforms. That macro is used as a defensive measure to prevent against // inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than // "MutexLock l(&mu)". Hence the typedef trick below. -class GTestMutexLock { +class [[nodiscard]] GTestMutexLock { public: explicit GTestMutexLock(Mutex&) {} // NOLINT }; @@ -1885,7 +1887,7 @@ class GTestMutexLock { typedef GTestMutexLock MutexLock; template -class GTEST_API_ ThreadLocal { +class GTEST_API_ [[nodiscard]] ThreadLocal { public: ThreadLocal() : value_() {} explicit ThreadLocal(const T& value) : value_(value) {} @@ -2193,7 +2195,7 @@ constexpr BiggestInt kMaxBiggestInt = (std::numeric_limits::max)(); // needs. Other types can be easily added in the future if need // arises. template -class TypeWithSize { +class [[nodiscard]] TypeWithSize { public: // This prevents the user from using TypeWithSize with incorrect // values of N. @@ -2202,7 +2204,7 @@ class TypeWithSize { // The specialization for size 4. template <> -class TypeWithSize<4> { +class [[nodiscard]] TypeWithSize<4> { public: using Int = std::int32_t; using UInt = std::uint32_t; @@ -2210,7 +2212,7 @@ class TypeWithSize<4> { // The specialization for size 8. template <> -class TypeWithSize<8> { +class [[nodiscard]] TypeWithSize<8> { public: using Int = std::int64_t; using UInt = std::uint64_t; diff --git a/deps/googletest/include/gtest/internal/gtest-string.h b/deps/googletest/include/gtest/internal/gtest-string.h index 7c05b58339f681..2363034fc0dbcb 100644 --- a/deps/googletest/include/gtest/internal/gtest-string.h +++ b/deps/googletest/include/gtest/internal/gtest-string.h @@ -60,7 +60,7 @@ namespace testing { namespace internal { // String - an abstract class holding static string utilities. -class GTEST_API_ String { +class GTEST_API_ [[nodiscard]] String { public: // Static utility methods @@ -166,7 +166,7 @@ class GTEST_API_ String { private: String(); // Not meant to be instantiated. -}; // class String +}; // class String // Gets the content of the stringstream's buffer as an std::string. Each '\0' // character in the buffer is replaced with "\\0".