From 6431970d8b60dd44f3241a89a17f2412d029b3f3 Mon Sep 17 00:00:00 2001 From: David Babenko-Sanders Date: Fri, 23 Oct 2026 14:53:40 -0700 Subject: [PATCH] build: enable more performance-* clang-tidy checks (#54024) * build: enable more performance-* clang-tidy checks * chore: performance-prefer-single-char-overloads Co-Authored-By: Claude Fable 5.1 * chore: performance-unnecessary-copy-initialization Co-Authored-By: Claude Fable 5.1 * chore: performance-use-std-move Co-Authored-By: Claude Fable 5.1 * chore: performance-move-const-arg Co-Authored-By: Claude Fable 5.1 * chore: performance-no-automatic-move Co-Authored-By: Claude Fable 5.1 * chore: address review feedback Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01MC6nEgyED2MtseZ9KdGMpt * chore: fix new clang-tidy performance findings Address performance-use-std-move, performance-move-const-arg, and performance-prefer-single-char-overloads findings in code that landed on main since the previous base. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01MC6nEgyED2MtseZ9KdGMpt * chore: fix new clang-tidy performance findings on macOS Silence performance-unnecessary-copy-initialization for task runners captured by Objective-C blocks in the macOS file and message box dialogs, matching the existing pattern: the copy is needed since a block would otherwise capture the reference by reference. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01MC6nEgyED2MtseZ9KdGMpt --------- Co-authored-by: Claude Fable 5.1 --- .clang-tidy | 7 +++++ shell/app/electron_content_client.cc | 3 ++- shell/browser/api/electron_api_app.cc | 9 +++---- shell/browser/api/electron_api_clipboard.cc | 2 +- .../api/electron_api_content_tracing.cc | 2 +- shell/browser/api/electron_api_debugger.cc | 6 ++++- shell/browser/api/electron_api_menu_mac.mm | 8 +++--- .../browser/api/electron_api_safe_storage.cc | 2 +- .../electron_api_service_worker_context.cc | 8 +++--- .../api/electron_api_service_worker_main.cc | 5 ++-- shell/browser/api/electron_api_session.cc | 3 +-- .../electron_api_system_preferences_mac.mm | 27 +++++++++---------- .../browser/api/electron_api_web_contents.cc | 12 ++++----- shell/browser/api/electron_api_web_contents.h | 2 +- shell/browser/api/electron_api_web_request.cc | 7 ++++- shell/browser/api/electron_api_web_request.h | 3 +++ shell/browser/api/message_port.cc | 2 +- shell/browser/app_package.cc | 3 ++- shell/browser/browser_linux.cc | 2 +- shell/browser/browser_mac.mm | 5 ++-- shell/browser/browser_win.cc | 6 +++-- shell/browser/electron_browser_client.cc | 2 +- shell/browser/electron_browser_context.cc | 2 +- .../electron_download_manager_delegate.cc | 6 ++--- shell/browser/extensions/api/tabs/tabs_api.cc | 4 +-- ...on_component_extension_resource_manager.cc | 3 +-- shell/browser/file_select_helper.cc | 2 +- shell/browser/login_handler.cc | 4 +-- shell/browser/native_window_mac.mm | 5 ++-- shell/browser/net/asar/asar_url_loader.cc | 2 +- .../client_certificate_responder_delegate.cc | 6 ++--- shell/browser/net/node_stream_loader.cc | 2 +- .../net/proxying_url_loader_factory.cc | 2 +- shell/browser/net/resolve_host_function.cc | 11 ++++---- .../notifications/mac/cocoa_notification.mm | 2 ++ .../mac/notification_presenter_mac.mm | 2 ++ .../win/windows_toast_activator.cc | 6 ++--- shell/browser/preload_script.cc | 2 +- shell/browser/ui/cocoa/electron_touch_bar.mm | 2 +- .../ui/devtools_ui_bundle_data_source.cc | 2 +- shell/browser/ui/file_dialog_mac.mm | 4 +++ shell/browser/ui/inspectable_web_contents.cc | 2 +- shell/browser/ui/message_box_mac.mm | 4 ++- .../views/freedesktop_nav_button_provider.cc | 3 ++- shell/browser/ui/webui/accessibility_ui.cc | 2 +- shell/browser/ui/win/notify_icon.cc | 4 ++- shell/common/api/electron_api_native_image.cc | 2 +- .../api/electron_api_native_image_win.cc | 3 +-- shell/common/api/electron_api_testing.cc | 2 +- shell/common/asar/archive.cc | 5 ++++ shell/common/asar/archive.h | 3 +++ shell/common/asar/scoped_temporary_file.cc | 3 ++- shell/common/electron_paths.cc | 4 ++- shell/common/electron_xcache_main.cc | 3 ++- shell/common/gin_converters/net_converter.cc | 2 +- shell/common/gin_helper/function_template.h | 2 +- shell/common/gin_helper/reply_channel.cc | 2 +- shell/common/node_bindings.cc | 2 +- shell/common/platform_util_linux.cc | 4 +-- shell/common/platform_util_mac.mm | 2 ++ .../api/electron_api_context_bridge.cc | 4 +-- shell/renderer/electron_api_service_impl.cc | 2 +- shell/renderer/renderer_client_base.cc | 2 +- shell/utility/ai/utility_ai_language_model.cc | 2 +- shell/utility/ai/utility_ai_manager.cc | 2 +- 65 files changed, 149 insertions(+), 112 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index c6000d672e..cc2e042b9b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -6,6 +6,13 @@ Checks: 'clang-analyzer-core.*, clang-analyzer-osx.*, clang-analyzer-security.*, clang-analyzer-unix.*, + performance-for-range-copy, + performance-implicit-conversion-in-loop, + performance-move-const-arg, + performance-no-automatic-move, + performance-prefer-single-char-overloads, + performance-unnecessary-copy-initialization, + performance-use-std-move, -bugprone-forward-declaration-namespace, -clang-analyzer-core.CallAndMessage, -clang-analyzer-security.PointerSub' diff --git a/shell/app/electron_content_client.cc b/shell/app/electron_content_client.cc index 98b5105434..d040b4b036 100644 --- a/shell/app/electron_content_client.cc +++ b/shell/app/electron_content_client.cc @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "base/command_line.h" @@ -164,7 +165,7 @@ bool TryGetBundledWidevineCdm( return false; } - *cdm_path = cdm_library_path; + *cdm_path = std::move(cdm_library_path); *capability_out = std::move(capability); return true; } diff --git a/shell/browser/api/electron_api_app.cc b/shell/browser/api/electron_api_app.cc index e6588a8ea0..a6ec1c969e 100644 --- a/shell/browser/api/electron_api_app.cc +++ b/shell/browser/api/electron_api_app.cc @@ -449,7 +449,7 @@ bool NotificationCallbackWrapper( const std::vector additional_data)>& callback, base::CommandLine cmd, const base::FilePath& cwd, - const std::vector additional_data) { + std::vector additional_data) { #if BUILDFLAG(IS_LINUX) // Set the global activation token sent as a command line switch by another // electron app instance. This also removes the switch after use to prevent @@ -464,11 +464,8 @@ bool NotificationCallbackWrapper( if (Browser::Get()->is_ready()) { callback.Run(std::move(cmd), cwd, std::move(additional_data)); } else { - scoped_refptr task_runner( - base::SingleThreadTaskRunner::GetCurrentDefault()); - // Make a copy of the span so that the data isn't lost. - task_runner->PostTask( + base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask( FROM_HERE, base::BindOnce(base::IgnoreResult(callback), std::move(cmd), cwd, std::move(additional_data))); } @@ -1105,7 +1102,7 @@ void App::OnSecondInstance(base::CommandLine cmd, v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::HandleScope handle_scope(isolate); v8::Local data_value = - DeserializeV8Value(isolate, std::move(additional_data)); + DeserializeV8Value(isolate, additional_data); Emit("second-instance", cmd.argv(), cwd, data_value); } diff --git a/shell/browser/api/electron_api_clipboard.cc b/shell/browser/api/electron_api_clipboard.cc index e8950ea83f..f8ecdcd3bc 100644 --- a/shell/browser/api/electron_api_clipboard.cc +++ b/shell/browser/api/electron_api_clipboard.cc @@ -274,7 +274,7 @@ v8::Local Clipboard::ReadText(ui::ClipboardBuffer buffer, return; } #endif - promise.Resolve(std::move(result)); + promise.Resolve(result); }, std::move(promise), buffer)); diff --git a/shell/browser/api/electron_api_content_tracing.cc b/shell/browser/api/electron_api_content_tracing.cc index 9ac10abc63..4a2a8fd8bc 100644 --- a/shell/browser/api/electron_api_content_tracing.cc +++ b/shell/browser/api/electron_api_content_tracing.cc @@ -92,7 +92,7 @@ struct Converter { base::DictValue memory_dump_config; if (ConvertFromV8(isolate, val, &memory_dump_config)) { - *out = base::trace_event::TraceConfig(std::move(memory_dump_config)); + *out = base::trace_event::TraceConfig(memory_dump_config); return true; } diff --git a/shell/browser/api/electron_api_debugger.cc b/shell/browser/api/electron_api_debugger.cc index d41c23e2ce..fe5acb9d6f 100644 --- a/shell/browser/api/electron_api_debugger.cc +++ b/shell/browser/api/electron_api_debugger.cc @@ -118,7 +118,11 @@ class Debugger::AgentHostLifecycle final promise.RejectWithErrorMessage(error_message ? *error_message : ""); } else { base::DictValue* result = dict.FindDict("result"); - promise.Resolve(result ? std::move(*result) : base::DictValue()); + if (result) { + promise.Resolve(*result); + } else { + promise.Resolve(base::DictValue()); + } } } diff --git a/shell/browser/api/electron_api_menu_mac.mm b/shell/browser/api/electron_api_menu_mac.mm index e762d75fd2..54fe594149 100644 --- a/shell/browser/api/electron_api_menu_mac.mm +++ b/shell/browser/api/electron_api_menu_mac.mm @@ -266,21 +266,21 @@ std::u16string MenuMac::GetAcceleratorTextAtForTesting(int index) const { text += u"Ctrl"; if (modifiers & NSEventModifierFlagShift) { if (!text.empty()) - text += u"+"; + text += u'+'; text += u"Shift"; } if (modifiers & NSEventModifierFlagOption) { if (!text.empty()) - text += u"+"; + text += u'+'; text += u"Alt"; } if (modifiers & NSEventModifierFlagCommand) { if (!text.empty()) - text += u"+"; + text += u'+'; text += u"Command"; } if (!text.empty()) - text += u"+"; + text += u'+'; auto key = base::ToUpperASCII(base::SysNSStringToUTF16([item keyEquivalent])); if (key == u"\t") text += u"Tab"; diff --git a/shell/browser/api/electron_api_safe_storage.cc b/shell/browser/api/electron_api_safe_storage.cc index 80e277c6dd..cd03bed0ab 100644 --- a/shell/browser/api/electron_api_safe_storage.cc +++ b/shell/browser/api/electron_api_safe_storage.cc @@ -231,7 +231,7 @@ v8::Local SafeStorage::encryptStringAsync( return handle; } - pending_encrypts_.emplace_back(std::move(promise), std::move(plaintext)); + pending_encrypts_.emplace_back(std::move(promise), plaintext); return handle; } diff --git a/shell/browser/api/electron_api_service_worker_context.cc b/shell/browser/api/electron_api_service_worker_context.cc index 4ba22ca8c6..6ffc6a9ac5 100644 --- a/shell/browser/api/electron_api_service_worker_context.cc +++ b/shell/browser/api/electron_api_service_worker_context.cc @@ -174,9 +174,8 @@ v8::Local ServiceWorkerContext::GetAllRunningWorkerInfo( const base::flat_map& info_map = service_worker_context_->GetRunningServiceWorkerInfos(); for (const auto& iter : info_map) { - builder.Set( - base::NumberToString(iter.first), - ServiceWorkerRunningInfoToDict(isolate, std::move(iter.second))); + builder.Set(base::NumberToString(iter.first), + ServiceWorkerRunningInfoToDict(isolate, iter.second)); } return builder.Build(); } @@ -191,8 +190,7 @@ v8::Local ServiceWorkerContext::GetInfoFromVersionID( thrower.ThrowError("Could not find service worker with that version_id"); return {}; } - return ServiceWorkerRunningInfoToDict(thrower.isolate(), - std::move(iter->second)); + return ServiceWorkerRunningInfoToDict(thrower.isolate(), iter->second); } v8::Local ServiceWorkerContext::GetFromVersionID( diff --git a/shell/browser/api/electron_api_service_worker_main.cc b/shell/browser/api/electron_api_service_worker_main.cc index 6c5197e8dc..dc020989e5 100644 --- a/shell/browser/api/electron_api_service_worker_main.cc +++ b/shell/browser/api/electron_api_service_worker_main.cc @@ -83,7 +83,7 @@ ServiceWorkerMain* ServiceWorkerMain::FromVersionID( content::StoragePartitionConfig storage_partition_config, int64_t version_id) { const ServiceWorkerKey key{std::move(browser_context_id), - std::move(storage_partition_config), version_id}; + storage_partition_config, version_id}; return FromServiceWorkerKey(key); } @@ -329,8 +329,7 @@ ServiceWorkerMain* ServiceWorkerMain::From( content::StoragePartitionConfig storage_partition_config, int64_t version_id) { ServiceWorkerKey service_worker_key{std::move(browser_context_id), - std::move(storage_partition_config), - version_id}; + storage_partition_config, version_id}; if (auto* service_worker = FromServiceWorkerKey(service_worker_key)) return service_worker; diff --git a/shell/browser/api/electron_api_session.cc b/shell/browser/api/electron_api_session.cc index 3cfdc9b4b7..852dd217f8 100644 --- a/shell/browser/api/electron_api_session.cc +++ b/shell/browser/api/electron_api_session.cc @@ -1847,8 +1847,7 @@ Session* Session::FromPath(gin::Arguments* args, return nullptr; } - browser_context = - ElectronBrowserContext::FromPath(std::move(path), std::move(options)); + browser_context = ElectronBrowserContext::FromPath(path, std::move(options)); return FromOrCreate(args->isolate(), browser_context); } diff --git a/shell/browser/api/electron_api_system_preferences_mac.mm b/shell/browser/api/electron_api_system_preferences_mac.mm index 65250043c3..606717c080 100644 --- a/shell/browser/api/electron_api_system_preferences_mac.mm +++ b/shell/browser/api/electron_api_system_preferences_mac.mm @@ -179,11 +179,10 @@ void SystemPreferences::PostNotification(const std::string& name, NSDistributedNotificationCenter* center = [NSDistributedNotificationCenter defaultCenter]; - [center - postNotificationName:base::SysUTF8ToNSString(name) - object:nil - userInfo:DictionaryValueToNSDictionary(std::move(user_info)) - deliverImmediately:immediate]; + [center postNotificationName:base::SysUTF8ToNSString(name) + object:nil + userInfo:DictionaryValueToNSDictionary(user_info) + deliverImmediately:immediate]; } int SystemPreferences::SubscribeNotification( @@ -202,10 +201,9 @@ void SystemPreferences::UnsubscribeNotification(int request_id) { void SystemPreferences::PostLocalNotification(const std::string& name, base::DictValue user_info) { NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; - [center - postNotificationName:base::SysUTF8ToNSString(name) - object:nil - userInfo:DictionaryValueToNSDictionary(std::move(user_info))]; + [center postNotificationName:base::SysUTF8ToNSString(name) + object:nil + userInfo:DictionaryValueToNSDictionary(user_info)]; } int SystemPreferences::SubscribeLocalNotification( @@ -224,10 +222,9 @@ void SystemPreferences::PostWorkspaceNotification(const std::string& name, base::DictValue user_info) { NSNotificationCenter* center = [[NSWorkspace sharedWorkspace] notificationCenter]; - [center - postNotificationName:base::SysUTF8ToNSString(name) - object:nil - userInfo:DictionaryValueToNSDictionary(std::move(user_info))]; + [center postNotificationName:base::SysUTF8ToNSString(name) + object:nil + userInfo:DictionaryValueToNSDictionary(user_info)]; } int SystemPreferences::SubscribeWorkspaceNotification( @@ -248,6 +245,8 @@ int SystemPreferences::DoSubscribeNotification( const NotificationCallback& callback, NotificationCenterKind kind) { int request_id = g_next_id++; + // A copy is needed: the block below would capture a reference by reference. + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) __block NotificationCallback copied_callback = callback; v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); @@ -346,7 +345,7 @@ void SystemPreferences::RegisterDefaults(gin::Arguments* args) { return; } @try { - NSDictionary* dict = DictionaryValueToNSDictionary(std::move(dict_value)); + NSDictionary* dict = DictionaryValueToNSDictionary(dict_value); for (id key in dict) { id value = [dict objectForKey:key]; if ([value isKindOfClass:[NSNull class]] || value == nil) { diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index dcc3687569..d066ec266f 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -438,7 +438,7 @@ struct Converter { if (!page_state.IsValid()) return false; - entry->SetPageState(std::move(page_state), restore_context.get()); + entry->SetPageState(page_state, restore_context.get()); } } @@ -3654,13 +3654,13 @@ void WebContents::DidFinishNavigation( } void WebContents::NotifyPageTitleUpdated( - content::NavigationEntry* entry, + const content::NavigationEntry* entry, bool from_same_document_history_navigation) { std::u16string final_title; bool explicit_set = true; if (entry) { - auto title = entry->GetTitle(); - auto url = entry->GetURL(); + const auto& title = entry->GetTitle(); + const auto& url = entry->GetURL(); if (url.SchemeIsFile() && title.empty()) { final_title = base::UTF8ToUTF16(url.ExtractFileName()); explicit_set = false; @@ -4017,7 +4017,7 @@ v8::Local WebContents::LoadURL(gin::Arguments* args, GURL base_url_for_data_url; if (options.Get("baseURLForDataURL", &base_url_for_data_url)) { - params.base_url_for_data_url = base_url_for_data_url; + params.base_url_for_data_url = std::move(base_url_for_data_url); params.load_type = content::NavigationController::LOAD_TYPE_DATA; } @@ -5884,7 +5884,7 @@ void WebContents::PostMessage(v8::Isolate* isolate, "webContents has no main frame to post to"); return; } - frame->PostMessage(isolate, channel, message, std::move(transfer)); + frame->PostMessage(isolate, channel, message, transfer); } void WebContents::SendInternal(gin::Arguments* args) { diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h index e276d5dd0d..5f6fd20907 100644 --- a/shell/browser/api/electron_api_web_contents.h +++ b/shell/browser/api/electron_api_web_contents.h @@ -714,7 +714,7 @@ class WebContents final : public gin::Wrappable, void DidUpdateFaviconURL(content::RenderFrameHost* render_frame_host, const std::vector& urls, blink::mojom::FaviconUpdateReason reason); - void NotifyPageTitleUpdated(content::NavigationEntry* entry, + void NotifyPageTitleUpdated(const content::NavigationEntry* entry, bool from_same_document_history_navigation); void MediaStartedPlaying(const MediaPlayerInfo& video_type, const content::MediaPlayerId& id); diff --git a/shell/browser/api/electron_api_web_request.cc b/shell/browser/api/electron_api_web_request.cc index a47d1fa9c2..2113d6183f 100644 --- a/shell/browser/api/electron_api_web_request.cc +++ b/shell/browser/api/electron_api_web_request.cc @@ -225,6 +225,11 @@ const gin::WrapperInfo WebRequest::kWrapperInfo = electron::MakeWrapperInfo(electron::kElectronWebRequest); WebRequest::RequestFilter::RequestFilter(const RequestFilter&) = default; +WebRequest::RequestFilter::RequestFilter(RequestFilter&&) = default; +WebRequest::RequestFilter& WebRequest::RequestFilter::operator=( + const RequestFilter&) = default; +WebRequest::RequestFilter& WebRequest::RequestFilter::operator=( + RequestFilter&&) = default; WebRequest::RequestFilter::RequestFilter() = default; WebRequest::RequestFilter::~RequestFilter() = default; @@ -949,7 +954,7 @@ WebRequest* WebRequest::Create( base::PassKey passkey, base::WeakPtr browser_context) { return cppgc::MakeGarbageCollected( - isolate->GetCppHeap()->GetAllocationHandle(), std::move(passkey), + isolate->GetCppHeap()->GetAllocationHandle(), passkey, std::move(browser_context)); } diff --git a/shell/browser/api/electron_api_web_request.h b/shell/browser/api/electron_api_web_request.h index d860c07a77..95d1453dfe 100644 --- a/shell/browser/api/electron_api_web_request.h +++ b/shell/browser/api/electron_api_web_request.h @@ -237,6 +237,9 @@ class WebRequest final : public gin::Wrappable { class RequestFilter { public: RequestFilter(const RequestFilter&); + RequestFilter(RequestFilter&&); + RequestFilter& operator=(const RequestFilter&); + RequestFilter& operator=(RequestFilter&&); RequestFilter(); ~RequestFilter(); diff --git a/shell/browser/api/message_port.cc b/shell/browser/api/message_port.cc index bf8c1b0724..3622d88385 100644 --- a/shell/browser/api/message_port.cc +++ b/shell/browser/api/message_port.cc @@ -190,7 +190,7 @@ bool MessagePort::EntanglePorts(v8::Isolate* isolate, v8::LocalVector result(isolate); for (auto& port : channels) { auto* wrapped_port = MessagePort::Create(isolate); - wrapped_port->Entangle(std::move(port)); + wrapped_port->Entangle(port); v8::Local wrapper; if (!wrapped_port->GetWrapper(isolate).ToLocal(&wrapper)) return false; diff --git a/shell/browser/app_package.cc b/shell/browser/app_package.cc index abec467dbd..8c977ab6a5 100644 --- a/shell/browser/app_package.cc +++ b/shell/browser/app_package.cc @@ -6,6 +6,7 @@ #include #include +#include #include #include "base/files/file_util.h" @@ -119,7 +120,7 @@ std::optional LoadAppPackage() { const base::DictValue& dict = manifest->GetDict(); Apply(dict); AppPackage package; - package.path = path; + package.path = std::move(path); const std::string* main = dict.FindString("main"); package.main = main && !main->empty() ? *main : "index.js"; if (const std::string* v8_flags = dict.FindString("v8Flags")) diff --git a/shell/browser/browser_linux.cc b/shell/browser/browser_linux.cc index 83c5cadcd5..c1cb95731d 100644 --- a/shell/browser/browser_linux.cc +++ b/shell/browser/browser_linux.cc @@ -81,7 +81,7 @@ bool SetDefaultWebClient(const std::string& protocol) { if (!found) return {}; - const auto path = base::FilePath::FromUTF8Unsafe(found); + auto path = base::FilePath::FromUTF8Unsafe(found); g_free(found); return path; } diff --git a/shell/browser/browser_mac.mm b/shell/browser/browser_mac.mm index 5cbb8f9e23..f334b39d5d 100644 --- a/shell/browser/browser_mac.mm +++ b/shell/browser/browser_mac.mm @@ -283,7 +283,7 @@ void Browser::SetUserActivity(const std::string& type, [[AtomApplication sharedApplication] setCurrentActivity:base::SysUTF8ToNSString(type) - withUserInfo:DictionaryValueToNSDictionary(std::move(user_info)) + withUserInfo:DictionaryValueToNSDictionary(user_info) withWebpageURL:net::NSURLWithGURL(GURL(url_string))]; } @@ -305,8 +305,7 @@ void Browser::UpdateCurrentActivity(const std::string& type, base::DictValue user_info) { [[AtomApplication sharedApplication] updateCurrentActivity:base::SysUTF8ToNSString(type) - withUserInfo:DictionaryValueToNSDictionary( - std::move(user_info))]; + withUserInfo:DictionaryValueToNSDictionary(user_info)]; } bool Browser::WillContinueUserActivity(const std::string& type) { diff --git a/shell/browser/browser_win.cc b/shell/browser/browser_win.cc index 5de7f53f5c..f7a16869fe 100644 --- a/shell/browser/browser_win.cc +++ b/shell/browser/browser_win.cc @@ -7,6 +7,8 @@ #include #include +#include + #include "base/base_paths.h" #include "base/command_line.h" #include "base/file_version_info.h" @@ -605,7 +607,7 @@ void Browser::UpdateBadgeContents( const std::string& badge_alt_string) { SkBitmap badge; if (badge_content) { - std::string content = badge_content.value(); + const std::string& content = badge_content.value(); constexpr int kOverlayIconSize = 16; // This is the color used by the Windows 10 Badge API, for platform // consistency. @@ -722,7 +724,7 @@ v8::Local Browser::GetLoginItemSettings( launch_items_hklm.end()); settings.executable_will_launch_at_login = executable_will_launch_at_login; - settings.launch_items = launch_items; + settings.launch_items = std::move(launch_items); return gin::ConvertToV8(JavascriptEnvironment::GetIsolate(), settings); } diff --git a/shell/browser/electron_browser_client.cc b/shell/browser/electron_browser_client.cc index 56b79e550d..1821c35310 100644 --- a/shell/browser/electron_browser_client.cc +++ b/shell/browser/electron_browser_client.cc @@ -1813,7 +1813,7 @@ void ElectronBrowserClient::WillCreateURLLoaderFactory( frame_host ? frame_host->GetRoutingID() : IPC::mojom::kRoutingIdNone, &next_id_, std::move(navigation_ui_data), - std::move(navigation_id), + navigation_id, std::move(proxied_receiver), std::move(target_factory_remote), std::move(header_client_receiver), diff --git a/shell/browser/electron_browser_context.cc b/shell/browser/electron_browser_context.cc index 8c5869e4c8..c9e7909b1c 100644 --- a/shell/browser/electron_browser_context.cc +++ b/shell/browser/electron_browser_context.cc @@ -393,7 +393,7 @@ ElectronBrowserContext::ElectronBrowserContext( std::get_if>( &partition_location)) { const base::FilePath& partition_path = filepath_partition->get(); - path_ = std::move(partition_path); + path_ = partition_path; } BrowserContextDependencyManager::GetInstance()->MarkBrowserContextLive(this); diff --git a/shell/browser/electron_download_manager_delegate.cc b/shell/browser/electron_download_manager_delegate.cc index 800ea35c88..7eae1e9bd9 100644 --- a/shell/browser/electron_download_manager_delegate.cc +++ b/shell/browser/electron_download_manager_delegate.cc @@ -274,7 +274,7 @@ void ElectronDownloadManagerDelegate::OnDownloadPathGenerated( } else { download::DownloadTargetInfo target_info; target_info.target_path = path; - target_info.intermediate_path = path; + target_info.intermediate_path = std::move(path); target_info.target_disposition = download::DownloadItem::TARGET_DISPOSITION_PROMPT; target_info.insecure_download_status = item->GetInsecureDownloadStatus(); @@ -316,7 +316,7 @@ void ElectronDownloadManagerDelegate::OnDownloadSaveDialogDone( : download::DOWNLOAD_INTERRUPT_REASON_NONE; download::DownloadTargetInfo target_info; target_info.target_path = path; - target_info.intermediate_path = path; + target_info.intermediate_path = std::move(path); target_info.target_disposition = download::DownloadItem::TARGET_DISPOSITION_PROMPT; target_info.insecure_download_status = item->GetInsecureDownloadStatus(); @@ -348,7 +348,7 @@ bool ElectronDownloadManagerDelegate::DetermineDownloadTarget( if (!save_path.empty()) { download::DownloadTargetInfo target_info; target_info.target_path = save_path; - target_info.intermediate_path = save_path; + target_info.intermediate_path = std::move(save_path); std::move(*callback).Run(std::move(target_info)); return true; } diff --git a/shell/browser/extensions/api/tabs/tabs_api.cc b/shell/browser/extensions/api/tabs/tabs_api.cc index 01e71bcc98..fa47b912fd 100644 --- a/shell/browser/extensions/api/tabs/tabs_api.cc +++ b/shell/browser/extensions/api/tabs/tabs_api.cc @@ -361,7 +361,7 @@ ExtensionFunction::ResponseAction TabsGetFunction::Run() { // TODO: Add proper support for split views tab.split_view_id = -1; - return RespondNow(ArgumentList(tabs::Get::Results::Create(std::move(tab)))); + return RespondNow(ArgumentList(tabs::Get::Results::Create(tab))); } ExtensionFunction::ResponseAction TabsSetZoomFunction::Run() { @@ -693,7 +693,7 @@ ExtensionFunction::ResponseValue TabsUpdateFunction::GetResult() { // TODO: Add proper support for split views tab.split_view_id = -1; - return ArgumentList(tabs::Get::Results::Create(std::move(tab))); + return ArgumentList(tabs::Get::Results::Create(tab)); } } // namespace extensions diff --git a/shell/browser/extensions/electron_component_extension_resource_manager.cc b/shell/browser/extensions/electron_component_extension_resource_manager.cc index 7f080fb8dd..193ea2a52e 100644 --- a/shell/browser/extensions/electron_component_extension_resource_manager.cc +++ b/shell/browser/extensions/electron_component_extension_resource_manager.cc @@ -130,11 +130,10 @@ bool ElectronComponentExtensionResourceManager::IsComponentExtensionResource( int* resource_id) const { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - base::FilePath directory_path = extension_path; base::FilePath resources_dir; base::FilePath relative_path; if (!base::PathService::Get(chrome::DIR_RESOURCES, &resources_dir) || - !resources_dir.AppendRelativePath(directory_path, &relative_path)) { + !resources_dir.AppendRelativePath(extension_path, &relative_path)) { return false; } relative_path = relative_path.Append(resource_path); diff --git a/shell/browser/file_select_helper.cc b/shell/browser/file_select_helper.cc index 91fba724ef..57eee45b3f 100644 --- a/shell/browser/file_select_helper.cc +++ b/shell/browser/file_select_helper.cc @@ -126,7 +126,7 @@ void FileSelectHelper::OnListFile( void FileSelectHelper::LaunchConfirmationDialog( const base::FilePath& path, std::vector selected_files) { - ConvertToFileChooserFileInfoList(std::move(selected_files)); + ConvertToFileChooserFileInfoList(selected_files); } void FileSelectHelper::OnListDone(int error) { diff --git a/shell/browser/login_handler.cc b/shell/browser/login_handler.cc index d88d71a6f5..1c1f3324fe 100644 --- a/shell/browser/login_handler.cc +++ b/shell/browser/login_handler.cc @@ -148,12 +148,12 @@ void LoginHandler::EmitEvent( // respondToAuthRequestsFromMainProcess. Without a session, auth falls // through to app.on('login') for backward compatibility. default_prevented = - utility_process->Emit("login", std::move(details), auth_info, + utility_process->Emit("login", details, auth_info, base::BindOnce(&LoginHandler::CallbackFromJS, weak_factory_.GetWeakPtr())); } else { default_prevented = - api::App::Get()->Emit("login", nullptr, std::move(details), auth_info, + api::App::Get()->Emit("login", nullptr, details, auth_info, base::BindOnce(&LoginHandler::CallbackFromJS, weak_factory_.GetWeakPtr())); } diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 6ab47cf7c9..df11dfccfb 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -1499,7 +1499,7 @@ bool NativeWindowMac::GetWindowButtonVisibility() const { void NativeWindowMac::SetWindowButtonPosition( std::optional position) { - traffic_light_position_ = std::move(position); + traffic_light_position_ = position; if (buttons_proxy_) { [buttons_proxy_ setMargin:traffic_light_position_]; NotifyLayoutWindowControlsOverlay(); @@ -1550,8 +1550,7 @@ void NativeWindowMac::RefreshTouchBarItem(const std::string& item_id) { void NativeWindowMac::SetEscapeTouchBarItem( gin_helper::PersistentDictionary item) { if (touch_bar_ && [window_ touchBar]) - [touch_bar_ setEscapeTouchBarItem:std::move(item) - forTouchBar:[window_ touchBar]]; + [touch_bar_ setEscapeTouchBarItem:item forTouchBar:[window_ touchBar]]; } void NativeWindowMac::SelectPreviousTab() { diff --git a/shell/browser/net/asar/asar_url_loader.cc b/shell/browser/net/asar/asar_url_loader.cc index 8d0e2d7775..773d215178 100644 --- a/shell/browser/net/asar/asar_url_loader.cc +++ b/shell/browser/net/asar/asar_url_loader.cc @@ -178,7 +178,7 @@ class AsarURLLoader : public network::mojom::URLLoader { archive->CopyFileOut(relative_path, &unpacked); info.offset = 0; if (root.empty()) { - real_path = unpacked; + real_path = std::move(unpacked); } else if (!base::NormalizeFilePath(unpacked, &real_path) || !real_archive.AddExtension(FILE_PATH_LITERAL("unpacked")) .AppendRelativePath(real_path, &logical) || diff --git a/shell/browser/net/client_certificate_responder_delegate.cc b/shell/browser/net/client_certificate_responder_delegate.cc index f34afdd4a2..c24417ee5f 100644 --- a/shell/browser/net/client_certificate_responder_delegate.cc +++ b/shell/browser/net/client_certificate_responder_delegate.cc @@ -98,9 +98,9 @@ class ClientCertificateResponderDelegate mojo::MakeSelfOwnedReceiver( std::make_unique(private_key), ssl_private_key.InitWithNewPipeAndPassReceiver()); - responder_->ContinueWithCertificate( - std::move(cert), private_key->GetProviderName(), - private_key->GetAlgorithmPreferences(), std::move(ssl_private_key)); + responder_->ContinueWithCertificate(cert, private_key->GetProviderName(), + private_key->GetAlgorithmPreferences(), + std::move(ssl_private_key)); } private: diff --git a/shell/browser/net/node_stream_loader.cc b/shell/browser/net/node_stream_loader.cc index 7da68ead9d..7a2e83c9b7 100644 --- a/shell/browser/net/node_stream_loader.cc +++ b/shell/browser/net/node_stream_loader.cc @@ -207,7 +207,7 @@ void NodeStreamLoader::On(const char* event, EventCallback callback) { // emitter.on(event, callback) v8::Local args[] = { gin::StringToV8(isolate_, event), - gin_helper::CallbackToV8Leaked(isolate_, std::move(callback)), + gin_helper::CallbackToV8Leaked(isolate_, callback), }; handlers_[event].Reset(isolate_, args[1]); node::MakeCallback(isolate_, emitter_.Get(isolate_), "on", diff --git a/shell/browser/net/proxying_url_loader_factory.cc b/shell/browser/net/proxying_url_loader_factory.cc index a4984e8c35..497954c6cb 100644 --- a/shell/browser/net/proxying_url_loader_factory.cc +++ b/shell/browser/net/proxying_url_loader_factory.cc @@ -806,7 +806,7 @@ ProxyingURLLoaderFactory::ProxyingURLLoaderFactory( frame_routing_id_(frame_routing_id), request_id_generator_(request_id_generator), navigation_ui_data_(std::move(navigation_ui_data)), - navigation_id_(std::move(navigation_id)), + navigation_id_(navigation_id), loader_factory_type_(loader_factory_type) { target_factory_.Bind(std::move(target_factory_remote)); target_factory_.set_disconnect_handler(base::BindOnce( diff --git a/shell/browser/net/resolve_host_function.cc b/shell/browser/net/resolve_host_function.cc index fdf92894cc..a7b06c315e 100644 --- a/shell/browser/net/resolve_host_function.cc +++ b/shell/browser/net/resolve_host_function.cc @@ -57,18 +57,17 @@ void ResolveHostFunction::Run() { /*endpoint_results_with_metadata=*/net::HostResolverEndpointResults())); if (electron::IsUtilityProcess()) { URLLoaderBundle::GetInstance()->GetHostResolver()->ResolveHost( - network::mojom::HostResolverHost::NewHostPortPair( - std::move(host_port_pair)), + network::mojom::HostResolverHost::NewHostPortPair(host_port_pair), net::NetworkAnonymizationKey(), std::move(params_), std::move(resolve_host_client)); } else { DCHECK_CURRENTLY_ON(BrowserThread::UI); browser_context_->GetDefaultStoragePartition() ->GetNetworkContext() - ->ResolveHost(network::mojom::HostResolverHost::NewHostPortPair( - std::move(host_port_pair)), - net::NetworkAnonymizationKey(), std::move(params_), - std::move(resolve_host_client)); + ->ResolveHost( + network::mojom::HostResolverHost::NewHostPortPair(host_port_pair), + net::NetworkAnonymizationKey(), std::move(params_), + std::move(resolve_host_client)); } } diff --git a/shell/browser/notifications/mac/cocoa_notification.mm b/shell/browser/notifications/mac/cocoa_notification.mm index e4c1c1b835..9297668dff 100644 --- a/shell/browser/notifications/mac/cocoa_notification.mm +++ b/shell/browser/notifications/mac/cocoa_notification.mm @@ -222,6 +222,8 @@ void CocoaNotification::ScheduleNotification( LOG(INFO) << "Notification created (" << [identifier UTF8String] << ")"; } + // A copy is needed: the block below would capture a reference by reference. + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) scoped_refptr task_runner = base::SequencedTaskRunner::GetCurrentDefault(); auto weak_self = GetWeakPtr(); diff --git a/shell/browser/notifications/mac/notification_presenter_mac.mm b/shell/browser/notifications/mac/notification_presenter_mac.mm index 1ceb1f514c..2548593ffd 100644 --- a/shell/browser/notifications/mac/notification_presenter_mac.mm +++ b/shell/browser/notifications/mac/notification_presenter_mac.mm @@ -78,6 +78,8 @@ Notification* NotificationPresenterMac::CreateNotificationObject( void NotificationPresenterMac::GetDeliveredNotifications( GetDeliveredNotificationsCallback callback) { + // A copy is needed: the block below would capture a reference by reference. + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) scoped_refptr task_runner = base::SequencedTaskRunner::GetCurrentDefault(); diff --git a/shell/browser/notifications/win/windows_toast_activator.cc b/shell/browser/notifications/win/windows_toast_activator.cc index 942cbd3d86..a6cef6274b 100644 --- a/shell/browser/notifications/win/windows_toast_activator.cc +++ b/shell/browser/notifications/win/windows_toast_activator.cc @@ -433,13 +433,13 @@ void HandleToastActivation(const std::wstring& invoked_args, // Expected invoked_args format: // type=&action=&tag= Parse simple key=value // pairs separated by '&'. - std::wstring args = invoked_args; std::wstring type; std::wstring action_index_str; std::wstring tag_str; - for (const auto& token : base::SplitString(args, L"&", base::KEEP_WHITESPACE, - base::SPLIT_WANT_NONEMPTY)) { + for (const auto& token : + base::SplitString(invoked_args, L"&", base::KEEP_WHITESPACE, + base::SPLIT_WANT_NONEMPTY)) { auto kv = base::SplitString(token, L"=", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); if (kv.size() != 2) diff --git a/shell/browser/preload_script.cc b/shell/browser/preload_script.cc index dae4187293..4ec61871f1 100644 --- a/shell/browser/preload_script.cc +++ b/shell/browser/preload_script.cc @@ -223,7 +223,7 @@ bool Converter::FromV8(v8::Isolate* isolate, return false; } if (base::FilePath file_path; options.Get("filePath", &file_path)) { - out->file_path = file_path; + out->file_path = std::move(file_path); } else { return false; } diff --git a/shell/browser/ui/cocoa/electron_touch_bar.mm b/shell/browser/ui/cocoa/electron_touch_bar.mm index 3b6d7aa6d2..1de32075e4 100644 --- a/shell/browser/ui/cocoa/electron_touch_bar.mm +++ b/shell/browser/ui/cocoa/electron_touch_bar.mm @@ -184,7 +184,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item"; identifier = [self identifierFromID:item_id type:type]; } if (identifier) { - [self addNonDefaultTouchBarItems:{std::move(item)}]; + [self addNonDefaultTouchBarItems:{item}]; touchBar.escapeKeyReplacementItemIdentifier = identifier; } else { touchBar.escapeKeyReplacementItemIdentifier = nil; diff --git a/shell/browser/ui/devtools_ui_bundle_data_source.cc b/shell/browser/ui/devtools_ui_bundle_data_source.cc index 139ddce230..60e42b5555 100644 --- a/shell/browser/ui/devtools_ui_bundle_data_source.cc +++ b/shell/browser/ui/devtools_ui_bundle_data_source.cc @@ -89,7 +89,7 @@ void BundledDataSource::StartDataRequest( const std::string path = content::URLDataSource::URLToRequestPath(url); // Serve request from local bundle. std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); - bundled_path_prefix += "/"; + bundled_path_prefix += '/'; if (base::StartsWith(path, bundled_path_prefix, base::CompareCase::INSENSITIVE_ASCII)) { StartBundledDataRequest(path.substr(bundled_path_prefix.length()), diff --git a/shell/browser/ui/file_dialog_mac.mm b/shell/browser/ui/file_dialog_mac.mm index 70001ec3ad..de9c0fcf22 100644 --- a/shell/browser/ui/file_dialog_mac.mm +++ b/shell/browser/ui/file_dialog_mac.mm @@ -524,6 +524,8 @@ void ShowOpenDialogForNSWindow(const DialogSettings& settings, SetupOpenDialogForProperties(dialog, settings.properties); __block OpenDialogCallback cb = std::move(callback); + // A copy is needed: the block below would capture a reference by reference. + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) scoped_refptr task_runner = base::SequencedTaskRunner::GetCurrentDefault(); [dialog @@ -643,6 +645,8 @@ void ShowSaveDialogForNSWindow(const DialogSettings& settings, [dialog setCanSelectHiddenExtension:YES]; __block SaveDialogCallback cb = std::move(callback); + // A copy is needed: the block below would capture a reference by reference. + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) scoped_refptr task_runner = base::SequencedTaskRunner::GetCurrentDefault(); [dialog diff --git a/shell/browser/ui/inspectable_web_contents.cc b/shell/browser/ui/inspectable_web_contents.cc index c4729f2144..1c798ee440 100644 --- a/shell/browser/ui/inspectable_web_contents.cc +++ b/shell/browser/ui/inspectable_web_contents.cc @@ -120,7 +120,7 @@ bool IsLocalDevToolsFrontendURL(const GURL& url) { return false; } std::string_view path = url.path(); - if (path.starts_with("/")) { + if (path.starts_with('/')) { path = path.substr(1); } return path.starts_with(chrome::kChromeUIDevToolsBundledPath) || diff --git a/shell/browser/ui/message_box_mac.mm b/shell/browser/ui/message_box_mac.mm index f886bd64b3..2df9727ea0 100644 --- a/shell/browser/ui/message_box_mac.mm +++ b/shell/browser/ui/message_box_mac.mm @@ -174,8 +174,10 @@ void ShowMessageBoxForNSWindow(const MessageBoxSettings& settings, // Duplicate the callback object here since c is a reference and gcd would // only store the pointer, by duplication we can force gcd to store a copy. __block MessageBoxCallback callback_ = std::move(callback); - __block std::optional id = std::move(settings.id); + __block std::optional id = settings.id; __block int cancel_id = settings.cancel_id; + // A copy is needed: the block below would capture a reference by reference. + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) scoped_refptr task_runner = base::SequencedTaskRunner::GetCurrentDefault(); diff --git a/shell/browser/ui/views/freedesktop_nav_button_provider.cc b/shell/browser/ui/views/freedesktop_nav_button_provider.cc index 1c58469060..529ad2f1db 100644 --- a/shell/browser/ui/views/freedesktop_nav_button_provider.cc +++ b/shell/browser/ui/views/freedesktop_nav_button_provider.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include "base/check.h" #include "base/memory/ptr_util.h" @@ -221,7 +222,7 @@ class FreedesktopButtonImageSource : public gfx::ImageSkiaSource { scaled.eraseColor(SK_ColorTRANSPARENT); bitmap.pixmap().scalePixels( scaled.pixmap(), SkSamplingOptions(SkCubicResampler::Mitchell())); - bitmap = scaled; + bitmap = std::move(scaled); } return gfx::ImageSkiaRep(bitmap, scale); diff --git a/shell/browser/ui/webui/accessibility_ui.cc b/shell/browser/ui/webui/accessibility_ui.cc index 77980d303d..e1435a1ed1 100644 --- a/shell/browser/ui/webui/accessibility_ui.cc +++ b/shell/browser/ui/webui/accessibility_ui.cc @@ -348,7 +348,7 @@ std::string RecursiveDumpAXPlatformNodeAsString( str += attribute + " "; } } - str += "\n"; + str += '\n'; for (size_t i = 0, child_count = node_delegate->GetChildCount(); i < child_count; i++) { gfx::NativeViewAccessible child = node_delegate->ChildAtIndex(i); diff --git a/shell/browser/ui/win/notify_icon.cc b/shell/browser/ui/win/notify_icon.cc index ec73ae4d21..562680ea28 100644 --- a/shell/browser/ui/win/notify_icon.cc +++ b/shell/browser/ui/win/notify_icon.cc @@ -6,6 +6,8 @@ #include +#include + #include "base/logging.h" #include "base/strings/string_util_win.h" #include "base/strings/utf_string_conversions.h" @@ -240,7 +242,7 @@ void NotifyIcon::CloseContextMenu() { } void NotifyIcon::SetContextMenu(raw_ptr menu_model) { - menu_model_ = menu_model; + menu_model_ = std::move(menu_model); } gfx::Rect NotifyIcon::GetBounds() { diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc index 23204c7285..492ea00ac1 100644 --- a/shell/common/api/electron_api_native_image.cc +++ b/shell/common/api/electron_api_native_image.cc @@ -207,7 +207,7 @@ bool NativeImage::TryConvertNativeImage(v8::Isolate* isolate, #if BUILDFLAG(IS_WIN) const auto img_path = base::WideToUTF8(icon_path.value()); #else - const auto img_path = icon_path.value(); + const auto& img_path = icon_path.value(); #endif error_message = "Failed to load image from path '" + img_path + "'"; } diff --git a/shell/common/api/electron_api_native_image_win.cc b/shell/common/api/electron_api_native_image_win.cc index d66f4209c6..e6bb66a637 100644 --- a/shell/common/api/electron_api_native_image_win.cc +++ b/shell/common/api/electron_api_native_image_win.cc @@ -37,8 +37,7 @@ v8::Local NativeImage::CreateThumbnailFromPath( // create an IShellItem Microsoft::WRL::ComPtr pItem; - std::wstring image_path = path.value(); - hr = SHCreateItemFromParsingName(image_path.c_str(), nullptr, + hr = SHCreateItemFromParsingName(path.value().c_str(), nullptr, IID_PPV_ARGS(&pItem)); if (FAILED(hr)) { diff --git a/shell/common/api/electron_api_testing.cc b/shell/common/api/electron_api_testing.cc index 27447b024b..9e4cf7adae 100644 --- a/shell/common/api/electron_api_testing.cc +++ b/shell/common/api/electron_api_testing.cc @@ -159,7 +159,7 @@ v8::Local CompileWasmModuleWithCacheForTesting( std::span(cached_bytes.span().data(), cached_bytes.span().size())); }, [resolve = std::move(resolve)](ModuleResult result) { - resolve.Run(std::move(result)); + resolve.Run(result); }); auto result = gin_helper::Dictionary::CreateEmpty(isolate); result.Set("accepted", accepted); diff --git a/shell/common/asar/archive.cc b/shell/common/asar/archive.cc index 1ce42af7c0..52cc9af729 100644 --- a/shell/common/asar/archive.cc +++ b/shell/common/asar/archive.cc @@ -183,6 +183,11 @@ bool FillFileInfoWithNode(Archive::FileInfo* info, IntegrityPayload::IntegrityPayload() = default; IntegrityPayload::~IntegrityPayload() = default; IntegrityPayload::IntegrityPayload(const IntegrityPayload& other) = default; +IntegrityPayload::IntegrityPayload(IntegrityPayload&& other) = default; +IntegrityPayload& IntegrityPayload::operator=(const IntegrityPayload& other) = + default; +IntegrityPayload& IntegrityPayload::operator=(IntegrityPayload&& other) = + default; Archive::FileInfo::FileInfo() = default; Archive::FileInfo::~FileInfo() = default; diff --git a/shell/common/asar/archive.h b/shell/common/asar/archive.h index ffed6d1ef6..e562861fbf 100644 --- a/shell/common/asar/archive.h +++ b/shell/common/asar/archive.h @@ -34,6 +34,9 @@ struct IntegrityPayload { IntegrityPayload(); ~IntegrityPayload(); IntegrityPayload(const IntegrityPayload& other); + IntegrityPayload(IntegrityPayload&& other); + IntegrityPayload& operator=(const IntegrityPayload& other); + IntegrityPayload& operator=(IntegrityPayload&& other); HashAlgorithm algorithm = HashAlgorithm::kNone; std::string hash; uint32_t block_size = 0U; diff --git a/shell/common/asar/scoped_temporary_file.cc b/shell/common/asar/scoped_temporary_file.cc index 838d55b00b..e84b21a22f 100644 --- a/shell/common/asar/scoped_temporary_file.cc +++ b/shell/common/asar/scoped_temporary_file.cc @@ -4,6 +4,7 @@ #include "shell/common/asar/scoped_temporary_file.h" +#include #include #include "base/files/file_util.h" @@ -42,7 +43,7 @@ bool ScopedTemporaryFile::Init(const base::FilePath::StringType& ext) { base::FilePath new_path = path_.AddExtension(ext); if (!base::Move(path_, new_path)) return false; - path_ = new_path; + path_ = std::move(new_path); } #endif diff --git a/shell/common/electron_paths.cc b/shell/common/electron_paths.cc index 5624c805f9..fb7a808499 100644 --- a/shell/common/electron_paths.cc +++ b/shell/common/electron_paths.cc @@ -4,6 +4,8 @@ #include "shell/common/electron_paths.h" +#include + #include "base/environment.h" #include "base/files/file_util.h" #include "base/path_service.h" @@ -102,7 +104,7 @@ bool ElectronPathProvider(int key, base::FilePath* result) { return false; } - *result = cur; + *result = std::move(cur); return true; } diff --git a/shell/common/electron_xcache_main.cc b/shell/common/electron_xcache_main.cc index 226ba7e5a3..73618f82eb 100644 --- a/shell/common/electron_xcache_main.cc +++ b/shell/common/electron_xcache_main.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include #include "libplatform/libplatform.h" @@ -248,7 +249,7 @@ bool ParseBlobAt(std::string_view data, size_t offset, BlobInfo* info) { static_cast(b.size - kSnapRoChecksumOffset)); b.checksum_ok = static_cast(a) == ReadU32(p + kSnapChecksumOffset); b.ro_checksum = ReadU32(p + kSnapRoChecksumOffset); - *info = b; + *info = std::move(b); return true; } diff --git a/shell/common/gin_converters/net_converter.cc b/shell/common/gin_converters/net_converter.cc index 092af5ec62..d57b9baec2 100644 --- a/shell/common/gin_converters/net_converter.cc +++ b/shell/common/gin_converters/net_converter.cc @@ -58,7 +58,7 @@ bool CertFromData(const std::string& data, if (cert_list.empty()) return false; - auto leaf_cert = cert_list.front(); + const auto& leaf_cert = cert_list.front(); if (!leaf_cert) return false; diff --git a/shell/common/gin_helper/function_template.h b/shell/common/gin_helper/function_template.h index cab1d581f8..da032240ba 100644 --- a/shell/common/gin_helper/function_template.h +++ b/shell/common/gin_helper/function_template.h @@ -69,7 +69,7 @@ class CallbackHolder final : public gin::internal::CallbackHolderBase { : gin::internal::CallbackHolderBase( reinterpret_cast(&kSignatureId)), callback(std::move(callback)), - invoker_options(std::move(invoker_options)) {} + invoker_options(invoker_options) {} CallbackHolder(const CallbackHolder&) = delete; CallbackHolder& operator=(const CallbackHolder&) = delete; diff --git a/shell/common/gin_helper/reply_channel.cc b/shell/common/gin_helper/reply_channel.cc index ea12fd7891..a59b7fbf50 100644 --- a/shell/common/gin_helper/reply_channel.cc +++ b/shell/common/gin_helper/reply_channel.cc @@ -82,7 +82,7 @@ gin::ObjectTemplateBuilder ReplyChannel::GetObjectTemplateBuilder( } bool ReplyChannel::SendReply(v8::Isolate* isolate, v8::Local arg) { - return SendReplyImpl(isolate, callback_, std::move(arg)); + return SendReplyImpl(isolate, callback_, arg); } void ReplyChannel::EnsureReplySent() { diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 27ef5b8287..30667fc79e 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -937,7 +937,7 @@ std::shared_ptr NodeBindings::CreateEnvironment( if (browser_env_ == BrowserEnvironment::kBrowser || browser_env_ == BrowserEnvironment::kRenderer) { if (on_app_code_ready) { - process.SetMethod("appCodeLoaded", std::move(*on_app_code_ready)); + process.SetMethod("appCodeLoaded", *on_app_code_ready); } else { process.SetMethod("appCodeLoaded", base::BindRepeating(&NodeBindings::SetAppCodeLoaded, diff --git a/shell/common/platform_util_linux.cc b/shell/common/platform_util_linux.cc index 99dc6ab2b8..01ed7d5aa2 100644 --- a/shell/common/platform_util_linux.cc +++ b/shell/common/platform_util_linux.cc @@ -262,7 +262,7 @@ class ShowItemHelper { // Unretained is safe, the ShowItemHelper instance is // never destroyed. base::Unretained(this), full_path), - std::move(file_to_highlight), /*startup-id=*/""); + file_to_highlight, /*startup-id=*/""); } void ShowItemUsingFileManagerResponse( @@ -320,7 +320,7 @@ bool XDGUtil(const std::vector& argv, base::nix::CreateLaunchOptionsWithXdgActivation(base::BindOnce( [](base::RepeatingClosure quit_loop, base::LaunchOptions* options_out, base::LaunchOptions options) { - *options_out = std::move(options); + *options_out = options; std::move(quit_loop).Run(); }, std::move(quit_loop), &options)); diff --git a/shell/common/platform_util_mac.mm b/shell/common/platform_util_mac.mm index 633e2e195e..f2127f17bc 100644 --- a/shell/common/platform_util_mac.mm +++ b/shell/common/platform_util_mac.mm @@ -131,6 +131,8 @@ void OpenExternal(const GURL& url, configuration.activates = options.activate; __block OpenCallback copied_callback = std::move(callback); + // A copy is needed: the block below would capture a reference by reference. + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) scoped_refptr runner = base::SequencedTaskRunner::GetCurrentDefault(); diff --git a/shell/renderer/api/electron_api_context_bridge.cc b/shell/renderer/api/electron_api_context_bridge.cc index 7db8646379..af3705408b 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -862,7 +862,7 @@ void OverrideGlobalValueFromIsolatedWorld( v8::Local main_context = frame->MainWorldScriptContext(); gin_helper::Dictionary global(isolate, main_context->Global()); - const std::string final_key = key_path[key_path.size() - 1]; + const std::string& final_key = key_path[key_path.size() - 1]; auto maybe_target_object = TraceKeyPath(global, key_path, allow_silent_failure); if (!maybe_target_object.has_value()) @@ -899,7 +899,7 @@ bool OverrideGlobalPropertyFromIsolatedWorld( v8::Local main_context = frame->MainWorldScriptContext(); gin_helper::Dictionary global(isolate, main_context->Global()); - const std::string final_key = key_path[key_path.size() - 1]; + const std::string& final_key = key_path[key_path.size() - 1]; auto target_dict = TraceKeyPath(global, key_path, false); v8::Local target_object = target_dict.value().GetHandle(); diff --git a/shell/renderer/electron_api_service_impl.cc b/shell/renderer/electron_api_service_impl.cc index 339cc76ef1..f28ea72f37 100644 --- a/shell/renderer/electron_api_service_impl.cc +++ b/shell/renderer/electron_api_service_impl.cc @@ -234,7 +234,7 @@ void ElectronApiServiceImpl::ReceivePostMessage( for (auto& port : message.ports) { ports.emplace_back( blink::WebMessagePortConverter::EntangleAndInjectMessagePortChannel( - isolate, context, std::move(port))); + isolate, context, port)); } std::vector> args = {message_value}; diff --git a/shell/renderer/renderer_client_base.cc b/shell/renderer/renderer_client_base.cc index 89ab019287..087e562a1b 100644 --- a/shell/renderer/renderer_client_base.cc +++ b/shell/renderer/renderer_client_base.cc @@ -461,7 +461,7 @@ bool RendererClientBase::OverrideCreatePlugin( blink::WebPlugin** plugin) { #if BUILDFLAG(ENABLE_PDF_VIEWER) if (params.mime_type.Utf8() == pdf::kInternalPluginMimeType) { - *plugin = pdf::CreateInternalPlugin(std::move(params), render_frame, {}); + *plugin = pdf::CreateInternalPlugin(params, render_frame, {}); return true; } #endif // BUILDFLAG(ENABLE_PDF_VIEWER) diff --git a/shell/utility/ai/utility_ai_language_model.cc b/shell/utility/ai/utility_ai_language_model.cc index d5a5be9c4a..9d1f23b444 100644 --- a/shell/utility/ai/utility_ai_language_model.cc +++ b/shell/utility/ai/utility_ai_language_model.cc @@ -710,7 +710,7 @@ void UtilityAILanguageModel::MeasureInputUsage( if (result->IsNumber() && gin::ConvertFromV8(isolate, result, &input_tokens)) { - std::move(callback).Run(std::move(input_tokens)); + std::move(callback).Run(input_tokens); } else if (result->IsNull()) { std::move(callback).Run(std::nullopt); } else { diff --git a/shell/utility/ai/utility_ai_manager.cc b/shell/utility/ai/utility_ai_manager.cc index 659defb55f..2a47a6796d 100644 --- a/shell/utility/ai/utility_ai_manager.cc +++ b/shell/utility/ai/utility_ai_manager.cc @@ -404,7 +404,7 @@ void UtilityAIManager::CreateLanguageModel( CreateLanguageModelInternal(isolate, std::move(client), language_model_class.Get(isolate), "create", - std::move(options_dict), std::move(options)); + options_dict, std::move(options)); } void UtilityAIManager::CreateLanguageModelInternal(