From 7bc47cba2e69a5c5b97a096306d41150665428e5 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Tue, 16 Apr 2019 23:20:38 +0800 Subject: [PATCH] src: apply clang-tidy rule modernize-use-equals-default PR-URL: https://github.com/nodejs/node/pull/27264 Reviewed-By: Refael Ackermann --- src/debug_utils.h | 2 +- src/env.h | 2 +- src/fs_event_wrap.cc | 5 +---- src/inspector/main_thread_interface.h | 4 ++-- src/inspector/worker_inspector.h | 2 +- src/inspector_agent.cc | 2 +- src/inspector_agent.h | 2 +- src/inspector_io.cc | 3 +-- src/inspector_socket.h | 2 +- src/inspector_socket_server.h | 2 +- src/js_native_api_v8.h | 5 ++--- src/memory_tracker.h | 2 +- src/node.h | 2 +- src/node_api.cc | 2 +- src/node_crypto.cc | 2 +- src/node_env_var.cc | 2 +- src/node_file.cc | 2 +- src/node_http2.h | 4 ++-- src/node_i18n.cc | 2 +- src/node_options.h | 6 +++--- src/node_perf.h | 2 +- src/node_platform.h | 4 ++-- src/node_serdes.cc | 4 ++-- src/node_v8_platform-inl.h | 2 +- src/req_wrap.h | 2 +- src/spawn_sync.cc | 5 ----- src/spawn_sync.h | 2 +- src/stream_base.h | 2 +- src/tracing/agent.h | 4 ++-- src/tracing/traced_value.cc | 2 -- src/tracing/traced_value.h | 2 +- src/util.h | 2 +- 32 files changed, 38 insertions(+), 50 deletions(-) diff --git a/src/debug_utils.h b/src/debug_utils.h index 05a9370e562f82..ef5a4c0c47590c 100644 --- a/src/debug_utils.h +++ b/src/debug_utils.h @@ -100,7 +100,7 @@ class NativeSymbolDebuggingContext { }; NativeSymbolDebuggingContext() = default; - virtual ~NativeSymbolDebuggingContext() {} + virtual ~NativeSymbolDebuggingContext() = default; virtual SymbolInfo LookupSymbol(void* address) { return {}; } virtual bool IsMapped(void* address) { return false; } diff --git a/src/env.h b/src/env.h index a871f8fcc1357f..9e6892d18259ce 100644 --- a/src/env.h +++ b/src/env.h @@ -540,7 +540,7 @@ struct AllocatedBuffer { class AsyncRequest : public MemoryRetainer { public: - AsyncRequest() {} + AsyncRequest() = default; ~AsyncRequest(); void Install(Environment* env, void* data, uv_async_cb target); void Uninstall(); diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index b5807dd3ffc9ab..5033f027b1f2e0 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -65,7 +65,7 @@ class FSEventWrap: public HandleWrap { static const encoding kDefaultEncoding = UTF8; FSEventWrap(Environment* env, Local object); - ~FSEventWrap() override; + ~FSEventWrap() = default; static void OnEvent(uv_fs_event_t* handle, const char* filename, int events, int status); @@ -84,9 +84,6 @@ FSEventWrap::FSEventWrap(Environment* env, Local object) } -FSEventWrap::~FSEventWrap() { -} - void FSEventWrap::GetInitialized(const FunctionCallbackInfo& args) { FSEventWrap* wrap = Unwrap(args.This()); CHECK_NOT_NULL(wrap); diff --git a/src/inspector/main_thread_interface.h b/src/inspector/main_thread_interface.h index e3f2a7fb1637ee..9a48192cd374e5 100644 --- a/src/inspector/main_thread_interface.h +++ b/src/inspector/main_thread_interface.h @@ -26,12 +26,12 @@ class MainThreadInterface; class Request { public: virtual void Call(MainThreadInterface*) = 0; - virtual ~Request() {} + virtual ~Request() = default; }; class Deletable { public: - virtual ~Deletable() {} + virtual ~Deletable() = default; }; std::unique_ptr Utf8ToStringView( diff --git a/src/inspector/worker_inspector.h b/src/inspector/worker_inspector.h index c1d3b8a5711740..9f5604e79aba2d 100644 --- a/src/inspector/worker_inspector.h +++ b/src/inspector/worker_inspector.h @@ -21,7 +21,7 @@ class WorkerDelegate { const std::string& url, bool waiting, std::shared_ptr worker) = 0; - virtual ~WorkerDelegate() {} + virtual ~WorkerDelegate() = default; }; class WorkerManagerEventHandle { diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index cda5cdbbd8dc46..10b607ff6c53c2 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -354,7 +354,7 @@ class InspectorTimer { // Unique_ptr goes out of scope here and pointer is deleted. } - ~InspectorTimer() {} + ~InspectorTimer() = default; Environment* env_; uv_timer_t timer_; diff --git a/src/inspector_agent.h b/src/inspector_agent.h index aa89fbba6bc099..b079ea675fbafa 100644 --- a/src/inspector_agent.h +++ b/src/inspector_agent.h @@ -30,7 +30,7 @@ class WorkerManager; class InspectorSession { public: - virtual ~InspectorSession() {} + virtual ~InspectorSession() = default; virtual void Dispatch(const v8_inspector::StringView& message) = 0; }; diff --git a/src/inspector_io.cc b/src/inspector_io.cc index 20785fc67787df..75bcfff5f75abe 100644 --- a/src/inspector_io.cc +++ b/src/inspector_io.cc @@ -217,8 +217,7 @@ class InspectorIoDelegate: public node::inspector::SocketServerDelegate { const std::string& target_id, const std::string& script_path, const std::string& script_name); - ~InspectorIoDelegate() override { - } + ~InspectorIoDelegate() override = default; void StartSession(int session_id, const std::string& target_id) override; void MessageReceived(int session_id, const std::string& message) override; diff --git a/src/inspector_socket.h b/src/inspector_socket.h index 3f4fc0c295040c..649b7f445dff0b 100644 --- a/src/inspector_socket.h +++ b/src/inspector_socket.h @@ -25,7 +25,7 @@ class InspectorSocket { const std::string& path, const std::string& accept_key) = 0; virtual void OnWsFrame(const std::vector& frame) = 0; - virtual ~Delegate() {} + virtual ~Delegate() = default; }; using DelegatePointer = std::unique_ptr; diff --git a/src/inspector_socket_server.h b/src/inspector_socket_server.h index 1ee9cce8f387c9..8d38cd50546d2c 100644 --- a/src/inspector_socket_server.h +++ b/src/inspector_socket_server.h @@ -31,7 +31,7 @@ class SocketServerDelegate { virtual std::vector GetTargetIds() = 0; virtual std::string GetTargetTitle(const std::string& id) = 0; virtual std::string GetTargetUrl(const std::string& id) = 0; - virtual ~SocketServerDelegate() {} + virtual ~SocketServerDelegate() = default; }; // HTTP Server, writes messages requested as TransportActions, and responds diff --git a/src/js_native_api_v8.h b/src/js_native_api_v8.h index 4e1779e8f00890..9d896ae1f2fa21 100644 --- a/src/js_native_api_v8.h +++ b/src/js_native_api_v8.h @@ -12,7 +12,7 @@ struct napi_env__ { context_persistent(isolate, context) { CHECK_EQ(isolate, context->GetIsolate()); } - virtual ~napi_env__() {} + virtual ~napi_env__() = default; v8::Isolate* const isolate; // Shortcut for context()->GetIsolate() v8impl::Persistent context_persistent; @@ -167,8 +167,7 @@ class Finalizer { _finalize_hint(finalize_hint) { } - ~Finalizer() { - } + ~Finalizer() = default; public: static Finalizer* New(napi_env env, diff --git a/src/memory_tracker.h b/src/memory_tracker.h index 07b1b472169ce7..6a5ab155117297 100644 --- a/src/memory_tracker.h +++ b/src/memory_tracker.h @@ -109,7 +109,7 @@ class CleanupHookCallback; */ class MemoryRetainer { public: - virtual ~MemoryRetainer() {} + virtual ~MemoryRetainer() = default; // Subclasses should implement these methods to provide information // for the V8 heap snapshot generator. diff --git a/src/node.h b/src/node.h index e638ff24182201..cbf9b938f1ed9e 100644 --- a/src/node.h +++ b/src/node.h @@ -248,7 +248,7 @@ NODE_EXTERN void FreeArrayBufferAllocator(ArrayBufferAllocator* allocator); class NODE_EXTERN MultiIsolatePlatform : public v8::Platform { public: - ~MultiIsolatePlatform() override { } + ~MultiIsolatePlatform() override = default; // 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 fa68323b3c1777..ecacd7013f66fe 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -841,7 +841,7 @@ class Work : public node::AsyncResource, public node::ThreadPoolWork { _complete(complete) { } - ~Work() override { } + ~Work() override = default; public: static Work* New(node_napi_env env, diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 70d873eeb63a21..49d1d417796daa 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -6069,7 +6069,7 @@ class KeyPairGenerationConfig { virtual bool Configure(const EVPKeyCtxPointer& ctx) { return true; } - virtual ~KeyPairGenerationConfig() {} + virtual ~KeyPairGenerationConfig() = default; }; class RSAKeyPairGenerationConfig : public KeyPairGenerationConfig { diff --git a/src/node_env_var.cc b/src/node_env_var.cc index b7b862304d6dab..abcf91850651f9 100644 --- a/src/node_env_var.cc +++ b/src/node_env_var.cc @@ -50,7 +50,7 @@ class MapKVStore final : public KVStore { std::shared_ptr Clone(Isolate* isolate) const override; - MapKVStore() {} + MapKVStore() = default; MapKVStore(const MapKVStore& other) : map_(other.map_) {} private: diff --git a/src/node_file.cc b/src/node_file.cc index 5d3b48cfa4d781..acdf01a5fea5a7 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -681,7 +681,7 @@ void AfterScanDirWithTypes(uv_fs_t* req) { // For async calls FSReqCallback is used. class FSReqWrapSync { public: - FSReqWrapSync() {} + FSReqWrapSync() = default; ~FSReqWrapSync() { uv_fs_req_cleanup(&req); } uv_fs_t req; diff --git a/src/node_http2.h b/src/node_http2.h index 06adfd55cd8ec2..c8ffa69f2e49a8 100644 --- a/src/node_http2.h +++ b/src/node_http2.h @@ -1208,7 +1208,7 @@ class ExternalHeader : class Headers { public: Headers(Isolate* isolate, Local context, Local headers); - ~Headers() {} + ~Headers() = default; nghttp2_nv* operator*() { return reinterpret_cast(*buf_); @@ -1229,7 +1229,7 @@ class Origins { Local context, Local origin_string, size_t origin_count); - ~Origins() {} + ~Origins() = default; nghttp2_origin_entry* operator*() { return reinterpret_cast(*buf_); diff --git a/src/node_i18n.cc b/src/node_i18n.cc index 1ea7efc7d273e6..0c565c447fb862 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -152,7 +152,7 @@ class ConverterObject : public BaseObject, Converter { CONVERTER_FLAGS_IGNORE_BOM = 0x4 }; - ~ConverterObject() override {} + ~ConverterObject() override = default; static void Has(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); diff --git a/src/node_options.h b/src/node_options.h index f92261569002e0..3b2513a183bc1b 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -47,7 +47,7 @@ class HostPort { class Options { public: virtual void CheckOptions(std::vector* errors) {} - virtual ~Options() {} + virtual ~Options() = default; }; // These options are currently essentially per-Environment, but it can be nice @@ -240,7 +240,7 @@ enum OptionType { template class OptionsParser { public: - virtual ~OptionsParser() {} + virtual ~OptionsParser() = default; typedef Options TargetType; @@ -338,7 +338,7 @@ class OptionsParser { // Represents a field within `Options`. class BaseOptionField { public: - virtual ~BaseOptionField() {} + virtual ~BaseOptionField() = default; virtual void* LookupImpl(Options* options) const = 0; template diff --git a/src/node_perf.h b/src/node_perf.h index 2e77c6f25ef744..4c7585d65ff276 100644 --- a/src/node_perf.h +++ b/src/node_perf.h @@ -71,7 +71,7 @@ class PerformanceEntry { startTime_(startTime), endTime_(endTime) { } - virtual ~PerformanceEntry() { } + virtual ~PerformanceEntry() = default; virtual v8::MaybeLocal ToObject() const; diff --git a/src/node_platform.h b/src/node_platform.h index c3a1fb04fa7ca5..66f86cfa7e74d5 100644 --- a/src/node_platform.h +++ b/src/node_platform.h @@ -24,7 +24,7 @@ template class TaskQueue { public: TaskQueue(); - ~TaskQueue() {} + ~TaskQueue() = default; void Push(std::unique_ptr task); std::unique_ptr Pop(); @@ -134,7 +134,7 @@ class NodePlatform : public MultiIsolatePlatform { public: NodePlatform(int thread_pool_size, node::tracing::TracingController* tracing_controller); - ~NodePlatform() override {} + ~NodePlatform() override = default; 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 682f90f0c3d0df..6e4bab5ce1814c 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() override {} + ~SerializerContext() override = default; 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() override {} + ~DeserializerContext() override = default; MaybeLocal ReadHostObject(Isolate* isolate) override; diff --git a/src/node_v8_platform-inl.h b/src/node_v8_platform-inl.h index 8b642caf938d2b..e36f0a7d88bea4 100644 --- a/src/node_v8_platform-inl.h +++ b/src/node_v8_platform-inl.h @@ -72,7 +72,7 @@ class NodeTraceStateObserver explicit NodeTraceStateObserver(v8::TracingController* controller) : controller_(controller) {} - ~NodeTraceStateObserver() override {} + ~NodeTraceStateObserver() override = default; private: v8::TracingController* controller_; diff --git a/src/req_wrap.h b/src/req_wrap.h index 890eb6cb61848c..c20912cc95e22f 100644 --- a/src/req_wrap.h +++ b/src/req_wrap.h @@ -14,7 +14,7 @@ class ReqWrapBase { public: explicit inline ReqWrapBase(Environment* env); - virtual ~ReqWrapBase() {} + virtual ~ReqWrapBase() = default; virtual void Cancel() = 0; virtual AsyncWrap* GetAsyncWrap() = 0; diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc index fb233a07daa0eb..4c8885f04a7915 100644 --- a/src/spawn_sync.cc +++ b/src/spawn_sync.cc @@ -49,11 +49,6 @@ using v8::Object; using v8::String; using v8::Value; - -SyncProcessOutputBuffer::SyncProcessOutputBuffer() { -} - - void SyncProcessOutputBuffer::OnAlloc(size_t suggested_size, uv_buf_t* buf) const { if (used() == kBufferSize) diff --git a/src/spawn_sync.h b/src/spawn_sync.h index 0ed6b9dff3a663..81a2f2aaa899ba 100644 --- a/src/spawn_sync.h +++ b/src/spawn_sync.h @@ -41,7 +41,7 @@ class SyncProcessOutputBuffer { static const unsigned int kBufferSize = 65536; public: - inline SyncProcessOutputBuffer(); + inline SyncProcessOutputBuffer() = default; inline void OnAlloc(size_t suggested_size, uv_buf_t* buf) const; inline void OnRead(const uv_buf_t* buf, size_t nread); diff --git a/src/stream_base.h b/src/stream_base.h index b61c742971013a..3550233290ce20 100644 --- a/src/stream_base.h +++ b/src/stream_base.h @@ -36,7 +36,7 @@ class StreamReq { AttachToObject(req_wrap_obj); } - virtual ~StreamReq() {} + virtual ~StreamReq() = default; virtual AsyncWrap* GetAsyncWrap() = 0; v8::Local object(); diff --git a/src/tracing/agent.h b/src/tracing/agent.h index 0039cc36793054..a129f954d7bfb7 100644 --- a/src/tracing/agent.h +++ b/src/tracing/agent.h @@ -22,7 +22,7 @@ class Agent; class AsyncTraceWriter { public: - virtual ~AsyncTraceWriter() {} + virtual ~AsyncTraceWriter() = default; virtual void AppendTraceEvent(TraceObject* trace_event) = 0; virtual void Flush(bool blocking) = 0; virtual void InitializeOnThread(uv_loop_t* loop) {} @@ -48,7 +48,7 @@ class TracingController : public v8::platform::tracing::TracingController { class AgentWriterHandle { public: - inline AgentWriterHandle() {} + inline AgentWriterHandle() = default; inline ~AgentWriterHandle() { reset(); } inline AgentWriterHandle(AgentWriterHandle&& other); diff --git a/src/tracing/traced_value.cc b/src/tracing/traced_value.cc index df4d862fb6b9c2..dfc11658e7e4e3 100644 --- a/src/tracing/traced_value.cc +++ b/src/tracing/traced_value.cc @@ -113,8 +113,6 @@ std::unique_ptr TracedValue::CreateArray() { TracedValue::TracedValue(bool root_is_array) : first_item_(true), root_is_array_(root_is_array) {} -TracedValue::~TracedValue() {} - void TracedValue::SetInteger(const char* name, int value) { WriteName(name); data_ += std::to_string(value); diff --git a/src/tracing/traced_value.h b/src/tracing/traced_value.h index 62782b238fe350..aa1dcd15c63d29 100644 --- a/src/tracing/traced_value.h +++ b/src/tracing/traced_value.h @@ -18,7 +18,7 @@ namespace tracing { class TracedValue : public v8::ConvertableToTraceFormat { public: - ~TracedValue() override; + ~TracedValue() = default; static std::unique_ptr Create(); static std::unique_ptr CreateArray(); diff --git a/src/util.h b/src/util.h index 7d371809cba7c3..3a6cef2e3524a4 100644 --- a/src/util.h +++ b/src/util.h @@ -427,7 +427,7 @@ class MaybeStackBuffer { template class ArrayBufferViewContents { public: - ArrayBufferViewContents() {} + ArrayBufferViewContents() = default; explicit inline ArrayBufferViewContents(v8::Local value); explicit inline ArrayBufferViewContents(v8::Local abv);