Commit 739bee71 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[api] Use C++14 [[deprecated]] attribute

Since C++14, there is a spec'ed attribute for deprecation of methods,
functions, types, aliases or anything else.
This CL switches from the GCC __attribute__ to this standard attribute.
This allows to use the V8_DEPRECATED and V8_DEPRECATE_SOON macros on
anything where the standard attribute can be used (including {using}
statements that were not working before). It also avoids the need to
nest the whole declaration in the macro, making the code more readable.

R=adamk@chromium.org

Bug: v8:9810
Change-Id: I7adab7694af75423fb31ade2fc982dbf9c9bc699
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1847361Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64174}
parent 1c917ed3
......@@ -72,11 +72,10 @@ V8_PLATFORM_EXPORT void RunIdleTasks(v8::Platform* platform,
* The |platform| has to be created using |NewDefaultPlatform|.
*
*/
V8_PLATFORM_EXPORT V8_DEPRECATE_SOON(
"Access the DefaultPlatform directly",
void SetTracingController(
v8::Platform* platform,
v8::platform::tracing::TracingController* tracing_controller));
V8_DEPRECATE_SOON("Access the DefaultPlatform directly")
V8_PLATFORM_EXPORT void SetTracingController(
v8::Platform* platform,
v8::platform::tracing::TracingController* tracing_controller);
} // namespace platform
} // namespace v8
......
......@@ -368,8 +368,8 @@ class Platform {
* scheduling. The definition of "foreground" is opaque to V8.
*/
V8_DEPRECATE_SOON(
"Use a taskrunner acquired by GetForegroundTaskRunner instead.",
virtual void CallOnForegroundThread(Isolate* isolate, Task* task)) = 0;
"Use a taskrunner acquired by GetForegroundTaskRunner instead.")
virtual void CallOnForegroundThread(Isolate* isolate, Task* task) = 0;
/**
* Schedules a task to be invoked on a foreground thread wrt a specific
......@@ -378,9 +378,9 @@ class Platform {
* scheduling. The definition of "foreground" is opaque to V8.
*/
V8_DEPRECATE_SOON(
"Use a taskrunner acquired by GetForegroundTaskRunner instead.",
virtual void CallDelayedOnForegroundThread(Isolate* isolate, Task* task,
double delay_in_seconds)) = 0;
"Use a taskrunner acquired by GetForegroundTaskRunner instead.")
virtual void CallDelayedOnForegroundThread(Isolate* isolate, Task* task,
double delay_in_seconds) = 0;
/**
* Schedules a task to be invoked on a foreground thread wrt a specific
......@@ -391,9 +391,8 @@ class Platform {
* The definition of "foreground" is opaque to V8.
*/
V8_DEPRECATE_SOON(
"Use a taskrunner acquired by GetForegroundTaskRunner instead.",
virtual void CallIdleOnForegroundThread(Isolate* isolate,
IdleTask* task)) {
"Use a taskrunner acquired by GetForegroundTaskRunner instead.")
virtual void CallIdleOnForegroundThread(Isolate* isolate, IdleTask* task) {
// This must be overriden if |IdleTasksEnabled()|.
abort();
}
......
......@@ -145,8 +145,8 @@ class V8_EXPORT CpuProfileNode {
unsigned GetHitCount() const;
/** Returns function entry UID. */
V8_DEPRECATED("Use GetScriptId, GetLineNumber, and GetColumnNumber instead.",
unsigned GetCallUid() const);
V8_DEPRECATED("Use GetScriptId, GetLineNumber, and GetColumnNumber instead.")
unsigned GetCallUid() const;
/** Returns id of the node. The id is unique within the tree */
unsigned GetNodeId() const;
......
......@@ -1741,8 +1741,8 @@ class V8_EXPORT ScriptCompiler {
V8_DEPRECATE_SOON(
"This class takes ownership of source_stream, so use the constructor "
"taking a unique_ptr to make these semantics clearer",
StreamedSource(ExternalSourceStream* source_stream, Encoding encoding));
"taking a unique_ptr to make these semantics clearer")
StreamedSource(ExternalSourceStream* source_stream, Encoding encoding);
StreamedSource(std::unique_ptr<ExternalSourceStream> source_stream,
Encoding encoding);
~StreamedSource();
......@@ -5466,11 +5466,10 @@ class V8_EXPORT SharedArrayBuffer : public Object {
* Create a new SharedArrayBuffer over an existing memory block. Propagate
* flags to indicate whether the underlying buffer can be grown.
*/
V8_DEPRECATED("Use New method with data, and byte_length instead.",
static Local<SharedArrayBuffer> New(
Isolate* isolate, const SharedArrayBuffer::Contents&,
ArrayBufferCreationMode mode =
ArrayBufferCreationMode::kExternalized));
V8_DEPRECATED("Use New method with data, and byte_length instead.")
static Local<SharedArrayBuffer> New(
Isolate* isolate, const SharedArrayBuffer::Contents&,
ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
/**
* Returns true if SharedArrayBuffer is externalized, that is, does not
......@@ -6857,34 +6856,26 @@ class V8_EXPORT ResourceConstraints {
/**
* Deprecated functions. Do not use in new code.
*/
V8_DEPRECATE_SOON("Use code_range_size_in_bytes.",
size_t code_range_size() const) {
return code_range_size_ / kMB;
}
V8_DEPRECATE_SOON("Use set_code_range_size_in_bytes.",
void set_code_range_size(size_t limit_in_mb)) {
V8_DEPRECATE_SOON("Use code_range_size_in_bytes.")
size_t code_range_size() const { return code_range_size_ / kMB; }
V8_DEPRECATE_SOON("Use set_code_range_size_in_bytes.")
void set_code_range_size(size_t limit_in_mb) {
code_range_size_ = limit_in_mb * kMB;
}
V8_DEPRECATE_SOON("Use max_young_generation_size_in_bytes.",
size_t max_semi_space_size_in_kb() const);
V8_DEPRECATE_SOON("Use set_max_young_generation_size_in_bytes.",
void set_max_semi_space_size_in_kb(size_t limit_in_kb));
V8_DEPRECATE_SOON("Use max_old_generation_size_in_bytes.",
size_t max_old_space_size() const) {
return max_old_generation_size_ / kMB;
}
V8_DEPRECATE_SOON("Use set_max_old_generation_size_in_bytes.",
void set_max_old_space_size(size_t limit_in_mb)) {
V8_DEPRECATE_SOON("Use max_young_generation_size_in_bytes.")
size_t max_semi_space_size_in_kb() const;
V8_DEPRECATE_SOON("Use set_max_young_generation_size_in_bytes.")
void set_max_semi_space_size_in_kb(size_t limit_in_kb);
V8_DEPRECATE_SOON("Use max_old_generation_size_in_bytes.")
size_t max_old_space_size() const { return max_old_generation_size_ / kMB; }
V8_DEPRECATE_SOON("Use set_max_old_generation_size_in_bytes.")
void set_max_old_space_size(size_t limit_in_mb) {
max_old_generation_size_ = limit_in_mb * kMB;
}
V8_DEPRECATE_SOON("Zone does not pool memory any more.",
size_t max_zone_pool_size() const) {
return max_zone_pool_size_;
}
V8_DEPRECATE_SOON("Zone does not pool memory any more.",
void set_max_zone_pool_size(size_t bytes)) {
max_zone_pool_size_ = bytes;
}
V8_DEPRECATE_SOON("Zone does not pool memory any more.")
size_t max_zone_pool_size() const { return max_zone_pool_size_; }
V8_DEPRECATE_SOON("Zone does not pool memory any more.")
void set_max_zone_pool_size(size_t bytes) { max_zone_pool_size_ = bytes; }
private:
static constexpr size_t kMB = 1048576u;
......@@ -7078,8 +7069,8 @@ class PromiseRejectMessage {
typedef void (*PromiseRejectCallback)(PromiseRejectMessage message);
// --- Microtasks Callbacks ---
V8_DEPRECATE_SOON("Use *WithData version.",
typedef void (*MicrotasksCompletedCallback)(Isolate*));
V8_DEPRECATE_SOON("Use *WithData version.")
typedef void (*MicrotasksCompletedCallback)(Isolate*);
typedef void (*MicrotasksCompletedCallbackWithData)(Isolate*, void*);
typedef void (*MicrotaskCallback)(void* data);
......@@ -7659,7 +7650,7 @@ class V8_EXPORT EmbedderHeapTracer {
* overriden to fill a |TraceSummary| that is used by V8 to schedule future
* garbage collections.
*/
V8_DEPRECATED("Use version with parameter.", virtual void TraceEpilogue()) {}
V8_DEPRECATED("Use version with parameter.") virtual void TraceEpilogue() {}
virtual void TraceEpilogue(TraceSummary* trace_summary);
/**
......@@ -7712,9 +7703,9 @@ class V8_EXPORT EmbedderHeapTracer {
virtual void ResetHandleInNonTracingGC(
const v8::TracedReference<v8::Value>& handle);
V8_DEPRECATE_SOON(
"Use TracedReference version when not requiring destructors.",
virtual void ResetHandleInNonTracingGC(
const v8::TracedGlobal<v8::Value>& handle));
"Use TracedReference version when not requiring destructors.")
virtual void ResetHandleInNonTracingGC(
const v8::TracedGlobal<v8::Value>& handle);
/*
* Called by the embedder to immediately perform a full garbage collection.
......@@ -8375,8 +8366,8 @@ class V8_EXPORT Isolate {
Local<Context> GetCurrentContext();
/** Returns the last context entered through V8's C++ API. */
V8_DEPRECATED("Use GetEnteredOrMicrotaskContext().",
Local<Context> GetEnteredContext());
V8_DEPRECATED("Use GetEnteredOrMicrotaskContext().")
Local<Context> GetEnteredContext();
/**
* Returns either the last context entered through V8's C++ API, or the
......@@ -8688,18 +8679,16 @@ class V8_EXPORT Isolate {
* Executing scripts inside the callback will not re-trigger microtasks and
* the callback.
*/
V8_DEPRECATE_SOON("Use *WithData version.",
void AddMicrotasksCompletedCallback(
MicrotasksCompletedCallback callback));
V8_DEPRECATE_SOON("Use *WithData version.")
void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
void AddMicrotasksCompletedCallback(
MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
/**
* Removes callback that was installed by AddMicrotasksCompletedCallback.
*/
V8_DEPRECATE_SOON("Use *WithData version.",
void RemoveMicrotasksCompletedCallback(
MicrotasksCompletedCallback callback));
V8_DEPRECATE_SOON("Use *WithData version.")
void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
void RemoveMicrotasksCompletedCallback(
MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
......@@ -9129,8 +9118,8 @@ class V8_EXPORT V8 {
* handled entirely on the embedders' side.
* - The call will abort if the data is invalid.
*/
V8_DEPRECATED("The natives blob is deprecated (https://crbug.com/v8/7624).",
static void SetNativesDataBlob(StartupData* startup_blob));
V8_DEPRECATED("The natives blob is deprecated (https://crbug.com/v8/7624).")
static void SetNativesDataBlob(StartupData* startup_blob);
static void SetSnapshotDataBlob(StartupData* startup_blob);
/** Set the callback to invoke in case of Dcheck failures. */
......@@ -9142,8 +9131,8 @@ class V8_EXPORT V8 {
*/
static void SetFlagsFromString(const char* str);
static void SetFlagsFromString(const char* str, size_t length);
V8_DEPRECATED("use size_t version",
static void SetFlagsFromString(const char* str, int length));
V8_DEPRECATED("use size_t version")
static void SetFlagsFromString(const char* str, int length);
/**
* Sets V8 flags from the command line.
......@@ -9226,9 +9215,9 @@ class V8_EXPORT V8 {
* not perform any file IO.
*/
static void InitializeExternalStartupData(const char* directory_path);
V8_DEPRECATED("The natives blob is deprecated (https://crbug.com/v8/7624).",
static void InitializeExternalStartupData(
const char* natives_blob, const char* snapshot_blob));
V8_DEPRECATED("The natives blob is deprecated (https://crbug.com/v8/7624).")
static void InitializeExternalStartupData(const char* natives_blob,
const char* snapshot_blob);
static void InitializeExternalStartupDataFromFile(const char* snapshot_blob);
/**
......@@ -9263,9 +9252,8 @@ class V8_EXPORT V8 {
* \param context The third argument passed to the Linux signal handler, which
* points to a ucontext_t structure.
*/
V8_DEPRECATE_SOON("Use TryHandleWebAssemblyTrapPosix",
static bool TryHandleSignal(int signal_number, void* info,
void* context));
V8_DEPRECATE_SOON("Use TryHandleWebAssemblyTrapPosix")
static bool TryHandleSignal(int signal_number, void* info, void* context);
#endif // V8_OS_POSIX
/**
......
......@@ -230,7 +230,6 @@
//
// V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline))
// supported
// V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported
// V8_HAS_ATTRIBUTE_NONNULL - __attribute__((nonnull)) supported
// V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported
// V8_HAS_ATTRIBUTE_UNUSED - __attribute__((unused)) supported
......@@ -250,7 +249,6 @@
// V8_HAS_BUILTIN_UADD_OVERFLOW - __builtin_uadd_overflow() supported
// V8_HAS_COMPUTED_GOTO - computed goto/labels as values
// supported
// V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported
// V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported
// V8_HAS_DECLSPEC_SELECTANY - __declspec(selectany) supported
// V8_HAS_DECLSPEC_NORETURN - __declspec(noreturn) supported
......@@ -269,9 +267,6 @@
#endif
# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline))
# define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated))
# define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE \
(__has_extension(attribute_deprecated_with_message))
# define V8_HAS_ATTRIBUTE_NONNULL (__has_attribute(nonnull))
# define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline))
# define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused))
......@@ -318,8 +313,6 @@
// Works around "sorry, unimplemented: inlining failed" build errors with
// older compilers.
# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0))
# define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0))
# define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE (V8_GNUC_PREREQ(4, 5, 0))
# define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0))
# define V8_HAS_ATTRIBUTE_UNUSED (V8_GNUC_PREREQ(2, 95, 0))
# define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0))
......@@ -341,7 +334,6 @@
#if defined(_MSC_VER)
# define V8_CC_MSVC 1
# define V8_HAS_DECLSPEC_DEPRECATED 1
# define V8_HAS_DECLSPEC_NOINLINE 1
# define V8_HAS_DECLSPEC_SELECTANY 1
# define V8_HAS_DECLSPEC_NORETURN 1
......@@ -397,31 +389,18 @@
// A macro (V8_DEPRECATED) to mark classes or functions as deprecated.
#if defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE
#define V8_DEPRECATED(message, declarator) \
declarator __attribute__((deprecated(message)))
#elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED
#define V8_DEPRECATED(message, declarator) \
declarator __attribute__((deprecated))
#elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED
#define V8_DEPRECATED(message, declarator) __declspec(deprecated) declarator
#if defined(V8_DEPRECATION_WARNINGS)
# define V8_DEPRECATED(message) [[deprecated(message)]]
#else
#define V8_DEPRECATED(message, declarator) declarator
# define V8_DEPRECATED(message)
#endif
// A macro (V8_DEPRECATE_SOON) to make it easier to see what will be deprecated.
#if defined(V8_IMMINENT_DEPRECATION_WARNINGS) && \
V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE
#define V8_DEPRECATE_SOON(message, declarator) \
declarator __attribute__((deprecated(message)))
#elif defined(V8_IMMINENT_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED
#define V8_DEPRECATE_SOON(message, declarator) \
declarator __attribute__((deprecated))
#elif defined(V8_IMMINENT_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED
#define V8_DEPRECATE_SOON(message, declarator) __declspec(deprecated) declarator
#if defined(V8_IMMINENT_DEPRECATION_WARNINGS)
# define V8_DEPRECATE_SOON(message) [[deprecated(message)]]
#else
#define V8_DEPRECATE_SOON(message, declarator) declarator
# define V8_DEPRECATE_SOON(message)
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment