Fixes -Wtautological-pointer-compare in gmock-matchers

PiperOrigin-RevId: 948667420
Change-Id: Ibb35d7e6469a193607a72f10377ef3a494f9525f
This commit is contained in:
Bogdan Graur 2026-07-15 18:50:43 -07:00 committed by Copybara-Service
parent b973ccb9ab
commit a25f43576e

View File

@ -821,8 +821,12 @@ class [[nodiscard]] IsNullMatcher {
template <typename Pointer>
bool MatchAndExplain(const Pointer& p,
MatchResultListener* /* listener */) const {
if constexpr (std::is_function_v<Pointer>) {
return false;
} else {
return p == nullptr;
}
}
void DescribeTo(::std::ostream* os) const { *os << "is NULL"; }
void DescribeNegationTo(::std::ostream* os) const { *os << "isn't NULL"; }
@ -835,8 +839,12 @@ class [[nodiscard]] NotNullMatcher {
template <typename Pointer>
bool MatchAndExplain(const Pointer& p,
MatchResultListener* /* listener */) const {
if constexpr (std::is_function_v<Pointer>) {
return true;
} else {
return p != nullptr;
}
}
void DescribeTo(::std::ostream* os) const { *os << "isn't NULL"; }
void DescribeNegationTo(::std::ostream* os) const { *os << "is NULL"; }