From c3d889182b0c958e922aec96e3aab43766884536 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Thu, 14 Feb 2019 23:12:43 +0800 Subject: [PATCH] src: apply clang-tidy rule modernize-use-override PR-URL: https://github.com/nodejs/node/pull/26103 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- src/async_wrap.h | 4 ++-- src/base_object.h | 2 +- src/cares_wrap.cc | 2 +- src/inspector/main_thread_interface.cc | 2 +- src/inspector_agent.cc | 2 +- src/inspector_io.cc | 2 +- src/inspector_socket_server.cc | 2 +- src/module_wrap.h | 2 +- src/node.h | 2 +- src/node_api.cc | 4 ++-- src/node_contextify.h | 2 +- src/node_crypto_bio.h | 2 +- src/node_file.h | 2 +- src/node_internals.h | 6 +++--- src/node_messaging.h | 4 ++-- src/node_options.h | 8 ++++---- src/node_platform.h | 4 ++-- src/node_serdes.cc | 4 ++-- src/node_worker.h | 2 +- src/stream_base.h | 2 +- src/stream_pipe.h | 2 +- src/tracing/node_trace_buffer.h | 2 +- src/tracing/node_trace_writer.h | 2 +- test/cctest/node_test_fixture.h | 4 ++-- test/cctest/test_environment.cc | 2 +- test/cctest/test_inspector_socket.cc | 6 +++--- test/cctest/test_inspector_socket_server.cc | 2 +- 27 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/async_wrap.h b/src/async_wrap.h index f7fc149c941ef0..6d5da4e4ee16db 100644 --- a/src/async_wrap.h +++ b/src/async_wrap.h @@ -109,7 +109,7 @@ class AsyncWrap : public BaseObject { ProviderType provider, double execution_async_id = -1); - virtual ~AsyncWrap(); + ~AsyncWrap() override; static v8::Local GetConstructorTemplate( Environment* env); @@ -169,7 +169,7 @@ class AsyncWrap : public BaseObject { v8::Local* argv); virtual std::string diagnostic_name() const; - virtual std::string MemoryInfoName() const; + std::string MemoryInfoName() const override; static void WeakCallback(const v8::WeakCallbackInfo &info); diff --git a/src/base_object.h b/src/base_object.h index e0f3f27950e7d0..090bb70aebeaf8 100644 --- a/src/base_object.h +++ b/src/base_object.h @@ -38,7 +38,7 @@ class BaseObject : public MemoryRetainer { // Associates this object with `object`. It uses the 0th internal field for // that, and in particular aborts if there is no such field. inline BaseObject(Environment* env, v8::Local object); - virtual inline ~BaseObject(); + inline ~BaseObject() override; // Returns the wrapped object. Returns an empty handle when // persistent.IsEmpty() is true. diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index de05123c22cf4a..91226ebdf7c4fb 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -149,7 +149,7 @@ using node_ares_task_list = class ChannelWrap : public AsyncWrap { public: ChannelWrap(Environment* env, Local object); - ~ChannelWrap(); + ~ChannelWrap() override; static void New(const FunctionCallbackInfo& args); diff --git a/src/inspector/main_thread_interface.cc b/src/inspector/main_thread_interface.cc index 25b6270e412464..25a82864c1ee3a 100644 --- a/src/inspector/main_thread_interface.cc +++ b/src/inspector/main_thread_interface.cc @@ -42,7 +42,7 @@ class CreateObjectRequest : public Request { CreateObjectRequest(int object_id, Factory factory) : object_id_(object_id), factory_(std::move(factory)) {} - void Call(MainThreadInterface* thread) { + void Call(MainThreadInterface* thread) override { thread->AddObject(object_id_, WrapInDeletable(factory_(thread))); } diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index ef5646eb56695f..15edf7f00c3ecd 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -228,7 +228,7 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel, worker_agent_->Wire(node_dispatcher_.get()); } - virtual ~ChannelImpl() { + ~ChannelImpl() override { tracing_agent_->disable(); tracing_agent_.reset(); // Dispose before the dispatchers worker_agent_->disable(); diff --git a/src/inspector_io.cc b/src/inspector_io.cc index 7686294b2e2842..42643fa6f6d3d6 100644 --- a/src/inspector_io.cc +++ b/src/inspector_io.cc @@ -215,7 +215,7 @@ class InspectorIoDelegate: public node::inspector::SocketServerDelegate { const std::string& target_id, const std::string& script_path, const std::string& script_name); - ~InspectorIoDelegate() { + ~InspectorIoDelegate() override { } void StartSession(int session_id, const std::string& target_id) override; diff --git a/src/inspector_socket_server.cc b/src/inspector_socket_server.cc index 5e77ff5b3f403a..7ddbcd38fe299d 100644 --- a/src/inspector_socket_server.cc +++ b/src/inspector_socket_server.cc @@ -184,7 +184,7 @@ class SocketSession { public: Delegate(InspectorSocketServer* server, int session_id) : server_(server), session_id_(session_id) { } - ~Delegate() { + ~Delegate() override { server_->SessionTerminated(session_id_); } void OnHttpGet(const std::string& host, const std::string& path) override; diff --git a/src/module_wrap.h b/src/module_wrap.h index 6d231631d6a69e..372e02bc5d1b83 100644 --- a/src/module_wrap.h +++ b/src/module_wrap.h @@ -61,7 +61,7 @@ class ModuleWrap : public BaseObject { v8::Local object, v8::Local module, v8::Local url); - ~ModuleWrap(); + ~ModuleWrap() override; static void New(const v8::FunctionCallbackInfo& args); static void Link(const v8::FunctionCallbackInfo& args); diff --git a/src/node.h b/src/node.h index 0bdd37421b150e..53fb5fb51a9b93 100644 --- a/src/node.h +++ b/src/node.h @@ -220,7 +220,7 @@ class Environment; class NODE_EXTERN MultiIsolatePlatform : public v8::Platform { public: - virtual ~MultiIsolatePlatform() { } + ~MultiIsolatePlatform() override { } // Returns true if work was dispatched or executed. New tasks that are // posted during flushing of the queue are postponed until the next // flushing. diff --git a/src/node_api.cc b/src/node_api.cc index 282ef255dcaab4..4e1a779c42e6f6 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -134,7 +134,7 @@ class ThreadSafeFunction : public node::AsyncResource { env->Ref(); } - ~ThreadSafeFunction() { + ~ThreadSafeFunction() override { node::RemoveEnvironmentCleanupHook(env->isolate, Cleanup, this); env->Unref(); } @@ -839,7 +839,7 @@ class Work : public node::AsyncResource, public node::ThreadPoolWork { _complete(complete) { } - virtual ~Work() { } + ~Work() override { } public: static Work* New(node_napi_env env, diff --git a/src/node_contextify.h b/src/node_contextify.h index 71c4bfc0d61f5a..631671cbf1a161 100644 --- a/src/node_contextify.h +++ b/src/node_contextify.h @@ -108,7 +108,7 @@ class ContextifyScript : public BaseObject { SET_SELF_SIZE(ContextifyScript) ContextifyScript(Environment* env, v8::Local object); - ~ContextifyScript(); + ~ContextifyScript() override; static void Init(Environment* env, v8::Local target); static void New(const v8::FunctionCallbackInfo& args); diff --git a/src/node_crypto_bio.h b/src/node_crypto_bio.h index b7f1d4f169edfe..ef7012ba728eb5 100644 --- a/src/node_crypto_bio.h +++ b/src/node_crypto_bio.h @@ -40,7 +40,7 @@ namespace crypto { // (a.k.a. std::unique_ptr). class NodeBIO : public MemoryRetainer { public: - ~NodeBIO(); + ~NodeBIO() override; static BIOPointer New(Environment* env = nullptr); diff --git a/src/node_file.h b/src/node_file.h index 034e3c0427da3d..f0c8f1dfbf6777 100644 --- a/src/node_file.h +++ b/src/node_file.h @@ -357,7 +357,7 @@ class FileHandle : public AsyncWrap, public StreamBase { static FileHandle* New(Environment* env, int fd, v8::Local obj = v8::Local()); - virtual ~FileHandle(); + ~FileHandle() override; static void New(const v8::FunctionCallbackInfo& args); diff --git a/src/node_internals.h b/src/node_internals.h index c94be6ebe9155d..6cbad8959415aa 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -105,10 +105,10 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { public: inline uint32_t* zero_fill_field() { return &zero_fill_field_; } - virtual void* Allocate(size_t size); // Defined in src/node.cc - virtual void* AllocateUninitialized(size_t size) + void* Allocate(size_t size) override; // Defined in src/node.cc + void* AllocateUninitialized(size_t size) override { return node::UncheckedMalloc(size); } - virtual void Free(void* data, size_t) { free(data); } + void Free(void* data, size_t) override { free(data); } private: uint32_t zero_fill_field_ = 1; // Boolean but exposed as uint32 to JS land. diff --git a/src/node_messaging.h b/src/node_messaging.h index 3c79e24f24b896..e1ced4f3fdedd8 100644 --- a/src/node_messaging.h +++ b/src/node_messaging.h @@ -78,7 +78,7 @@ class Message : public MemoryRetainer { class MessagePortData : public MemoryRetainer { public: explicit MessagePortData(MessagePort* owner); - ~MessagePortData(); + ~MessagePortData() override; MessagePortData(MessagePortData&& other) = delete; MessagePortData& operator=(MessagePortData&& other) = delete; @@ -138,7 +138,7 @@ class MessagePort : public HandleWrap { MessagePort(Environment* env, v8::Local context, v8::Local wrap); - ~MessagePort(); + ~MessagePort() override; // Create a new message port instance, optionally over an existing // `MessagePortData` object. diff --git a/src/node_options.h b/src/node_options.h index e68e1cdfd734ca..190f6380e92f13 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -79,7 +79,7 @@ class DebugOptions : public Options { return break_first_line || break_node_first_line; } - void CheckOptions(std::vector* errors); + void CheckOptions(std::vector* errors) override; }; class EnvironmentOptions : public Options { @@ -125,7 +125,7 @@ class EnvironmentOptions : public Options { inline DebugOptions* get_debug_options(); inline const DebugOptions& debug_options() const; - void CheckOptions(std::vector* errors); + void CheckOptions(std::vector* errors) override; private: DebugOptions debug_options_; @@ -146,7 +146,7 @@ class PerIsolateOptions : public Options { bool report_verbose; #endif // NODE_REPORT inline EnvironmentOptions* get_per_env_options(); - void CheckOptions(std::vector* errors); + void CheckOptions(std::vector* errors) override; }; class PerProcessOptions : public Options { @@ -192,7 +192,7 @@ class PerProcessOptions : public Options { #endif // NODE_REPORT inline PerIsolateOptions* get_per_isolate_options(); - void CheckOptions(std::vector* errors); + void CheckOptions(std::vector* errors) override; }; // The actual options parser, as opposed to the structs containing them: diff --git a/src/node_platform.h b/src/node_platform.h index 1308d4df6aa249..ec48296b31e16b 100644 --- a/src/node_platform.h +++ b/src/node_platform.h @@ -56,7 +56,7 @@ class PerIsolatePlatformData : public std::enable_shared_from_this { public: PerIsolatePlatformData(v8::Isolate* isolate, uv_loop_t* loop); - ~PerIsolatePlatformData(); + ~PerIsolatePlatformData() override; void PostTask(std::unique_ptr task) override; void PostIdleTask(std::unique_ptr task) override; @@ -123,7 +123,7 @@ class NodePlatform : public MultiIsolatePlatform { public: NodePlatform(int thread_pool_size, node::tracing::TracingController* tracing_controller); - virtual ~NodePlatform() {} + ~NodePlatform() override {} void DrainTasks(v8::Isolate* isolate) override; void CancelPendingDelayedTasks(v8::Isolate* isolate) override; diff --git a/src/node_serdes.cc b/src/node_serdes.cc index 58ce70b2e08b5e..ab3fca7efb0ae8 100644 --- a/src/node_serdes.cc +++ b/src/node_serdes.cc @@ -33,7 +33,7 @@ class SerializerContext : public BaseObject, SerializerContext(Environment* env, Local wrap); - ~SerializerContext() {} + ~SerializerContext() override {} void ThrowDataCloneError(Local message) override; Maybe WriteHostObject(Isolate* isolate, Local object) override; @@ -68,7 +68,7 @@ class DeserializerContext : public BaseObject, Local wrap, Local buffer); - ~DeserializerContext() {} + ~DeserializerContext() override {} MaybeLocal ReadHostObject(Isolate* isolate) override; diff --git a/src/node_worker.h b/src/node_worker.h index 68848c859990f0..dad0713fd92df2 100644 --- a/src/node_worker.h +++ b/src/node_worker.h @@ -18,7 +18,7 @@ class Worker : public AsyncWrap { v8::Local wrap, const std::string& url, std::shared_ptr per_isolate_opts); - ~Worker(); + ~Worker() override; // Run the worker. This is only called from the worker thread. void Run(); diff --git a/src/stream_base.h b/src/stream_base.h index cde3343d624fa4..d5b2235f0e6f71 100644 --- a/src/stream_base.h +++ b/src/stream_base.h @@ -82,7 +82,7 @@ class WriteWrap : public StreamReq { v8::Local req_wrap_obj) : StreamReq(stream, req_wrap_obj) { } - ~WriteWrap() { + ~WriteWrap() override { free(storage_); } diff --git a/src/stream_pipe.h b/src/stream_pipe.h index 51a33b7ef69776..ce0077749c868a 100644 --- a/src/stream_pipe.h +++ b/src/stream_pipe.h @@ -10,7 +10,7 @@ namespace node { class StreamPipe : public AsyncWrap { public: StreamPipe(StreamBase* source, StreamBase* sink, v8::Local obj); - ~StreamPipe(); + ~StreamPipe() override; void Unpipe(); diff --git a/src/tracing/node_trace_buffer.h b/src/tracing/node_trace_buffer.h index b59ae4f0a0e4ef..18e4f43efaae3a 100644 --- a/src/tracing/node_trace_buffer.h +++ b/src/tracing/node_trace_buffer.h @@ -51,7 +51,7 @@ class InternalTraceBuffer { class NodeTraceBuffer : public TraceBuffer { public: NodeTraceBuffer(size_t max_chunks, Agent* agent, uv_loop_t* tracing_loop); - ~NodeTraceBuffer(); + ~NodeTraceBuffer() override; TraceObject* AddTraceEvent(uint64_t* handle) override; TraceObject* GetEventByHandle(uint64_t handle) override; diff --git a/src/tracing/node_trace_writer.h b/src/tracing/node_trace_writer.h index f412587ab93219..cd965d77b7859f 100644 --- a/src/tracing/node_trace_writer.h +++ b/src/tracing/node_trace_writer.h @@ -17,7 +17,7 @@ using v8::platform::tracing::TraceWriter; class NodeTraceWriter : public AsyncTraceWriter { public: explicit NodeTraceWriter(const std::string& log_file_pattern); - ~NodeTraceWriter(); + ~NodeTraceWriter() override; void InitializeOnThread(uv_loop_t* loop) override; void AppendTraceEvent(TraceObject* trace_event) override; diff --git a/test/cctest/node_test_fixture.h b/test/cctest/node_test_fixture.h index f4c97b05027895..e34601af99a977 100644 --- a/test/cctest/node_test_fixture.h +++ b/test/cctest/node_test_fixture.h @@ -84,14 +84,14 @@ class NodeTestFixture : public ::testing::Test { CHECK_EQ(0, uv_loop_close(¤t_loop)); } - virtual void SetUp() { + void SetUp() override { allocator = ArrayBufferUniquePtr(node::CreateArrayBufferAllocator(), &node::FreeArrayBufferAllocator); isolate_ = NewIsolate(allocator.get(), ¤t_loop); CHECK_NE(isolate_, nullptr); } - virtual void TearDown() { + void TearDown() override { isolate_->Dispose(); platform->UnregisterIsolate(isolate_); isolate_ = nullptr; diff --git a/test/cctest/test_environment.cc b/test/cctest/test_environment.cc index 49dc700bb57716..aba4b719477e03 100644 --- a/test/cctest/test_environment.cc +++ b/test/cctest/test_environment.cc @@ -16,7 +16,7 @@ static std::string cb_1_arg; // NOLINT(runtime/string) class EnvironmentTest : public EnvironmentTestFixture { private: - virtual void TearDown() { + void TearDown() override { NodeTestFixture::TearDown(); called_cb_1 = false; called_cb_2 = false; diff --git a/test/cctest/test_inspector_socket.cc b/test/cctest/test_inspector_socket.cc index b96489db1f49d3..09df0fbbcd9406 100644 --- a/test/cctest/test_inspector_socket.cc +++ b/test/cctest/test_inspector_socket.cc @@ -107,7 +107,7 @@ class TestInspectorDelegate : public InspectorSocket::Delegate { handshake_delegate_(stop_if_stop_path), fail_on_ws_frame_(false) { } - ~TestInspectorDelegate() { + ~TestInspectorDelegate() override { assert_is_delegate(this); delegate = nullptr; } @@ -353,7 +353,7 @@ static void on_connection(uv_connect_t* connect, int status) { class InspectorSocketTest : public ::testing::Test { protected: - virtual void SetUp() { + void SetUp() override { connected = false; GTEST_ASSERT_EQ(0, uv_loop_init(&loop)); server = uv_tcp_t(); @@ -375,7 +375,7 @@ class InspectorSocketTest : public ::testing::Test { really_close(reinterpret_cast(&server)); } - virtual void TearDown() { + void TearDown() override { really_close(reinterpret_cast(&client_socket)); SPIN_WHILE(delegate != nullptr); const int err = uv_loop_close(&loop); diff --git a/test/cctest/test_inspector_socket_server.cc b/test/cctest/test_inspector_socket_server.cc index 349356ef56c9fc..30da5cf3d2ceaa 100644 --- a/test/cctest/test_inspector_socket_server.cc +++ b/test/cctest/test_inspector_socket_server.cc @@ -305,7 +305,7 @@ class TestSocketServerDelegate : public SocketServerDelegate { targets_(target_ids), session_id_(0) {} - ~TestSocketServerDelegate() { + ~TestSocketServerDelegate() override { harness_->Done(); }