Skip to content

Commit 0934b7e

Browse files
derekmaurocopybara-github
authored andcommitted
Use an internal symbol for deprecate-and-inline that allows
the use of a deprecation message PiperOrigin-RevId: 807753856 Change-Id: I34b0c7c6faf34cad11ea2aca5ccd16bca16acdec
1 parent 4969d0a commit 0934b7e

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

googlemock/include/gmock/gmock-actions.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,7 +1868,7 @@ typedef internal::IgnoredValue Unused;
18681868

18691869
// Deprecated single-argument DoAll.
18701870
template <typename Action>
1871-
GMOCK_DEPRECATE_AND_INLINE()
1871+
GTEST_INTERNAL_DEPRECATE_AND_INLINE("Avoid using DoAll() for single actions")
18721872
typename std::decay<Action>::type DoAll(Action&& action) {
18731873
return std::forward<Action>(action);
18741874
}
@@ -2038,11 +2038,11 @@ PolymorphicAction<internal::SetErrnoAndReturnAction<T>> SetErrnoAndReturn(
20382038
// Various overloads for Invoke().
20392039

20402040
// Legacy function.
2041-
// Actions can now be implicitly constructed from callables. No need to create
2042-
// wrapper objects.
20432041
// This function exists for backwards compatibility.
20442042
template <typename FunctionImpl>
2045-
GMOCK_DEPRECATE_AND_INLINE()
2043+
GTEST_INTERNAL_DEPRECATE_AND_INLINE(
2044+
"Actions can now be implicitly constructed from callables. No need to "
2045+
"create wrapper objects using Invoke().")
20462046
typename std::decay<FunctionImpl>::type Invoke(FunctionImpl&& function_impl) {
20472047
return std::forward<FunctionImpl>(function_impl);
20482048
}

googlemock/include/gmock/internal/gmock-port.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,10 @@
5757
#include "gmock/internal/custom/gmock-port.h"
5858
#include "gtest/internal/gtest-port.h"
5959

60-
#if defined(GTEST_HAS_ABSL)
61-
#include "absl/base/macros.h"
62-
63-
#define GMOCK_DEPRECATE_AND_INLINE() ABSL_DEPRECATE_AND_INLINE()
64-
65-
#if !defined(GTEST_NO_ABSL_FLAGS)
60+
#if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
6661
#include "absl/flags/declare.h"
6762
#include "absl/flags/flag.h"
68-
#endif // !defined(GTEST_NO_ABSL_FLAGS)
69-
70-
#else // defined(GTEST_HAS_ABSL)
71-
#define GMOCK_DEPRECATE_AND_INLINE()
72-
#endif // defined(GTEST_HAS_ABSL)
63+
#endif
7364

7465
// For MS Visual C++, check the compiler version. At least VS 2015 is
7566
// required to compile Google Mock.

googletest/include/gtest/internal/gtest-port.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,6 +2322,13 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val);
23222322
} // namespace internal
23232323
} // namespace testing
23242324

2325+
#if GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(clang::annotate)
2326+
#define GTEST_INTERNAL_DEPRECATE_AND_INLINE(msg) \
2327+
[[deprecated(msg), clang::annotate("inline-me")]]
2328+
#else
2329+
#define GTEST_INTERNAL_DEPRECATE_AND_INLINE(msg) [[deprecated(msg)]]
2330+
#endif
2331+
23252332
#if defined(__cpp_lib_span) || (GTEST_INTERNAL_HAS_INCLUDE(<span>) && \
23262333
GTEST_INTERNAL_CPLUSPLUS_LANG >= 202002L)
23272334
#define GTEST_INTERNAL_HAS_STD_SPAN 1

0 commit comments

Comments
 (0)