Skip to content

Commit ee39d7a

Browse files
derekmauronetkex
authored andcommitted
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
1 parent 09a7205 commit ee39d7a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

absl/base/macros.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,40 @@ ABSL_NAMESPACE_END
138138
#define ABSL_INTERNAL_RETHROW do {} while (false)
139139
#endif // ABSL_HAVE_EXCEPTIONS
140140

141+
// ABSL_DEPRECATE_AND_INLINE()
142+
//
143+
// Marks a function or type alias as deprecated and tags it to be picked up for
144+
// automated refactoring by go/cpp-inliner. It can added to inline function
145+
// definitions or type aliases. It should only be used within a header file. It
146+
// differs from `ABSL_DEPRECATED` in the following ways:
147+
//
148+
// 1. New uses of the function or type will be discouraged via Tricorder
149+
// warnings.
150+
// 2. If enabled via `METADATA`, automated changes will be sent out inlining the
151+
// functions's body or replacing the type where it is used.
152+
//
153+
// For example:
154+
//
155+
// ABSL_DEPRECATE_AND_INLINE() inline int OldFunc(int x) {
156+
// return NewFunc(x, 0);
157+
// }
158+
//
159+
// will mark `OldFunc` as deprecated, and the go/cpp-inliner service will
160+
// replace calls to `OldFunc(x)` with calls to `NewFunc(x, 0)`. Once all calls
161+
// to `OldFunc` have been replaced, `OldFunc` can be deleted.
162+
//
163+
// See go/cpp-inliner for more information.
164+
//
165+
// Note: go/cpp-inliner is Google-internal service for automated refactoring.
166+
// While open-source users do not have access to this service, the macro is
167+
// provided for compatibility, and so that users receive deprecation warnings.
168+
#if ABSL_HAVE_CPP_ATTRIBUTE(deprecated) && \
169+
ABSL_HAVE_CPP_ATTRIBUTE(clang::annotate)
170+
#define ABSL_DEPRECATE_AND_INLINE() [[deprecated, clang::annotate("inline-me")]]
171+
#elif ABSL_HAVE_CPP_ATTRIBUTE(deprecated)
172+
#define ABSL_DEPRECATE_AND_INLINE() [[deprecated]]
173+
#else
174+
#define ABSL_DEPRECATE_AND_INLINE()
175+
#endif
176+
141177
#endif // ABSL_BASE_MACROS_H_

0 commit comments

Comments
 (0)