diff options
author | Derek Mauro <dmauro@google.com> | 2024-02-08 08:16:36 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-02-08 08:17:37 -0800 |
commit | 36442dd87ed5f568f483f702252c6c5e6028aeb3 (patch) | |
tree | 615411f605777b2ab559c62409f11e3d26d6c290 | |
parent | 19c20d73aacfb32968493bf083574f05e68ea051 (diff) |
Add the ABSL_DEPRECATE_AND_INLINE() macro
This macro is used by a Google-internal service for automated
refactoring. It is being released so that Google projects that
use this service can also open-source their code that uses it.
PiperOrigin-RevId: 605322286
Change-Id: I16babcc56c454e07461690a8bb58be5da72d283f
-rw-r--r-- | absl/base/macros.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/absl/base/macros.h b/absl/base/macros.h index f33cd192..33c1cd1e 100644 --- a/absl/base/macros.h +++ b/absl/base/macros.h @@ -138,4 +138,40 @@ ABSL_NAMESPACE_END #define ABSL_INTERNAL_RETHROW do {} while (false) #endif // ABSL_HAVE_EXCEPTIONS +// ABSL_DEPRECATE_AND_INLINE() +// +// Marks a function or type alias as deprecated and tags it to be picked up for +// automated refactoring by go/cpp-inliner. It can added to inline function +// definitions or type aliases. It should only be used within a header file. It +// differs from `ABSL_DEPRECATED` in the following ways: +// +// 1. New uses of the function or type will be discouraged via Tricorder +// warnings. +// 2. If enabled via `METADATA`, automated changes will be sent out inlining the +// functions's body or replacing the type where it is used. +// +// For example: +// +// ABSL_DEPRECATE_AND_INLINE() inline int OldFunc(int x) { +// return NewFunc(x, 0); +// } +// +// will mark `OldFunc` as deprecated, and the go/cpp-inliner service will +// replace calls to `OldFunc(x)` with calls to `NewFunc(x, 0)`. Once all calls +// to `OldFunc` have been replaced, `OldFunc` can be deleted. +// +// See go/cpp-inliner for more information. +// +// Note: go/cpp-inliner is Google-internal service for automated refactoring. +// While open-source users do not have access to this service, the macro is +// provided for compatibility, and so that users receive deprecation warnings. +#if ABSL_HAVE_CPP_ATTRIBUTE(deprecated) && \ + ABSL_HAVE_CPP_ATTRIBUTE(clang::annotate) +#define ABSL_DEPRECATE_AND_INLINE() [[deprecated, clang::annotate("inline-me")]] +#elif ABSL_HAVE_CPP_ATTRIBUTE(deprecated) +#define ABSL_DEPRECATE_AND_INLINE() [[deprecated]] +#else +#define ABSL_DEPRECATE_AND_INLINE() +#endif + #endif // ABSL_BASE_MACROS_H_ |