Skip to content

Commit 5a37b51

Browse files
derekmaurocopybara-github
authored andcommitted
Use [[maybe_unused]] when it is available to avoid
-Wused-but-marked-unused warnings PiperOrigin-RevId: 625430612 Change-Id: Ia9d2e47984e1e6f91966afae8a6750119ae69446
1 parent 5197b1a commit 5a37b51

File tree

7 files changed

+150
-124
lines changed

7 files changed

+150
-124
lines changed

googlemock/include/gmock/gmock-actions.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,9 +2174,9 @@ ::testing::Action<F> MakeAction(std::shared_ptr<Impl> impl) {
21742174
}
21752175

21762176
#define GMOCK_INTERNAL_ARG_UNUSED(i, data, el) \
2177-
, const arg##i##_type& arg##i GTEST_ATTRIBUTE_UNUSED_
2178-
#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_ \
2179-
const args_type& args GTEST_ATTRIBUTE_UNUSED_ GMOCK_PP_REPEAT( \
2177+
, GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED const arg##i##_type& arg##i
2178+
#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_ \
2179+
GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED const args_type& args GMOCK_PP_REPEAT( \
21802180
GMOCK_INTERNAL_ARG_UNUSED, , 10)
21812181

21822182
#define GMOCK_INTERNAL_ARG(i, data, el) , const arg##i##_type& arg##i

googlemock/include/gmock/gmock-matchers.h

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5445,47 +5445,47 @@ PolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> ThrowsMessage(
54455445
::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
54465446

54475447
// MATCHER* macros itself are listed below.
5448-
#define MATCHER(name, description) \
5449-
class name##Matcher \
5450-
: public ::testing::internal::MatcherBaseImpl<name##Matcher> { \
5451-
public: \
5452-
template <typename arg_type> \
5453-
class gmock_Impl : public ::testing::MatcherInterface<const arg_type&> { \
5454-
public: \
5455-
gmock_Impl() {} \
5456-
bool MatchAndExplain( \
5457-
const arg_type& arg, \
5458-
::testing::MatchResultListener* result_listener) const override; \
5459-
void DescribeTo(::std::ostream* gmock_os) const override { \
5460-
*gmock_os << FormatDescription(false); \
5461-
} \
5462-
void DescribeNegationTo(::std::ostream* gmock_os) const override { \
5463-
*gmock_os << FormatDescription(true); \
5464-
} \
5465-
\
5466-
private: \
5467-
::std::string FormatDescription(bool negation) const { \
5468-
/* NOLINTNEXTLINE readability-redundant-string-init */ \
5469-
::std::string gmock_description = (description); \
5470-
if (!gmock_description.empty()) { \
5471-
return gmock_description; \
5472-
} \
5473-
return ::testing::internal::FormatMatcherDescription(negation, #name, \
5474-
{}, {}); \
5475-
} \
5476-
}; \
5477-
}; \
5478-
inline name##Matcher GMOCK_INTERNAL_WARNING_PUSH() \
5479-
GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-function") \
5480-
GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-member-function") \
5481-
name GMOCK_INTERNAL_WARNING_POP()() { \
5482-
return {}; \
5483-
} \
5484-
template <typename arg_type> \
5485-
bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain( \
5486-
const arg_type& arg, \
5487-
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_) \
5488-
const
5448+
#define MATCHER(name, description) \
5449+
class name##Matcher \
5450+
: public ::testing::internal::MatcherBaseImpl<name##Matcher> { \
5451+
public: \
5452+
template <typename arg_type> \
5453+
class gmock_Impl : public ::testing::MatcherInterface<const arg_type&> { \
5454+
public: \
5455+
gmock_Impl() {} \
5456+
bool MatchAndExplain( \
5457+
const arg_type& arg, \
5458+
::testing::MatchResultListener* result_listener) const override; \
5459+
void DescribeTo(::std::ostream* gmock_os) const override { \
5460+
*gmock_os << FormatDescription(false); \
5461+
} \
5462+
void DescribeNegationTo(::std::ostream* gmock_os) const override { \
5463+
*gmock_os << FormatDescription(true); \
5464+
} \
5465+
\
5466+
private: \
5467+
::std::string FormatDescription(bool negation) const { \
5468+
/* NOLINTNEXTLINE readability-redundant-string-init */ \
5469+
::std::string gmock_description = (description); \
5470+
if (!gmock_description.empty()) { \
5471+
return gmock_description; \
5472+
} \
5473+
return ::testing::internal::FormatMatcherDescription(negation, #name, \
5474+
{}, {}); \
5475+
} \
5476+
}; \
5477+
}; \
5478+
inline name##Matcher GMOCK_INTERNAL_WARNING_PUSH() \
5479+
GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-function") \
5480+
GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-member-function") \
5481+
name GMOCK_INTERNAL_WARNING_POP()() { \
5482+
return {}; \
5483+
} \
5484+
template <typename arg_type> \
5485+
bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain( \
5486+
const arg_type& arg, \
5487+
GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED ::testing::MatchResultListener* \
5488+
result_listener) const
54895489

54905490
#define MATCHER_P(name, p0, description) \
54915491
GMOCK_INTERNAL_MATCHER(name, name##MatcherP, description, (#p0), (p0))
@@ -5567,11 +5567,11 @@ PolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> ThrowsMessage(
55675567
} \
55685568
template <GMOCK_INTERNAL_MATCHER_TEMPLATE_PARAMS(args)> \
55695569
template <typename arg_type> \
5570-
bool full_name<GMOCK_INTERNAL_MATCHER_TYPE_PARAMS(args)>::gmock_Impl< \
5571-
arg_type>::MatchAndExplain(const arg_type& arg, \
5572-
::testing::MatchResultListener* \
5573-
result_listener GTEST_ATTRIBUTE_UNUSED_) \
5574-
const
5570+
bool full_name<GMOCK_INTERNAL_MATCHER_TYPE_PARAMS(args)>:: \
5571+
gmock_Impl<arg_type>::MatchAndExplain( \
5572+
const arg_type& arg, \
5573+
GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED ::testing:: \
5574+
MatchResultListener* result_listener) const
55755575

55765576
#define GMOCK_INTERNAL_MATCHER_TEMPLATE_PARAMS(args) \
55775577
GMOCK_PP_TAIL( \

googletest/include/gtest/gtest-param-test.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ internal::ParamConverterGenerator<T> ConvertGenerator(
469469
::testing::internal::CodeLocation(__FILE__, __LINE__)); \
470470
return 0; \
471471
} \
472-
static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \
472+
GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static int gtest_registering_dummy_; \
473473
}; \
474474
int GTEST_TEST_CLASS_NAME_(test_suite_name, \
475475
test_name)::gtest_registering_dummy_ = \
@@ -514,8 +514,8 @@ internal::ParamConverterGenerator<T> ConvertGenerator(
514514
::testing::internal::DefaultParamName<test_suite_name::ParamType>, \
515515
DUMMY_PARAM_))))(info); \
516516
} \
517-
static int gtest_##prefix##test_suite_name##_dummy_ \
518-
GTEST_ATTRIBUTE_UNUSED_ = \
517+
GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static int \
518+
gtest_##prefix##test_suite_name##_dummy_ = \
519519
::testing::UnitTest::GetInstance() \
520520
->parameterized_test_registry() \
521521
.GetTestSuitePatternHolder<test_suite_name>( \

0 commit comments

Comments
 (0)