From 331a98a8a6881842c0f470ecc547dad7d29c892c Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 6 Feb 2018 23:26:01 +0000 Subject: [PATCH] Prepare mac code for building with -Wimplicit-fallthrough. Fixes a bug where memory-infra tracing would count private_dirty memory also as shared_dirty memory in a certain detail view (but not in aggregates). Record a memory-infra trace as described on https://chromium.googlesource.com/chromium/src/+/lkcr/docs/memory-infra/ then click a memory dump, click e.g. "Browser" in the Analysis view, scroll down, and click the triangle toggle next to Total and then Native heap. Before this change, entries with "Private dirty" != 0 would always have the same value in the "Shared dirty" column (but not the other way round). After this change, at most one of the two columns is != 0. Actually turning on the warning is blocked on an issue in protobuf (see crbug.com/809157), so this will happen in a future CL. TBR=sky Bug: 177475 Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Change-Id: I663f225f817accd5ee7319e33e2779aafd9c85c6 Reviewed-on: https://chromium-review.googlesource.com/902065 Commit-Queue: Nico Weber Reviewed-by: Scott Violet Reviewed-by: Erik Chen Cr-Commit-Position: refs/heads/master@{#534831} --- base/process/process_metrics_mac.cc | 2 +- chrome/browser/app_controller_mac.mm | 2 +- chrome/browser/chrome_browser_application_mac.mm | 1 + chrome/browser/mac/keystone_glue.mm | 2 +- .../ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm | 2 +- chrome/browser/ui/cocoa/download/download_item_mac.mm | 2 +- chrome/browser/ui/cocoa/gradient_button_cell.mm | 5 +++-- chrome/browser/ui/webui/help/version_updater_mac.mm | 2 +- device/gamepad/xbox_controller_mac.mm | 1 + media/gpu/vt_video_decode_accelerator_mac.cc | 2 +- net/dns/dns_config_service_posix.cc | 1 + .../public/cpp/memory_instrumentation/os_metrics_mac.cc | 1 + ui/accessibility/platform/ax_platform_node_mac.mm | 2 +- 13 files changed, 15 insertions(+), 10 deletions(-) diff --git a/base/process/process_metrics_mac.cc b/base/process/process_metrics_mac.cc index 276104e30e2bb7..63c59e21453153 100644 --- a/base/process/process_metrics_mac.cc +++ b/base/process/process_metrics_mac.cc @@ -237,7 +237,7 @@ bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, break; case SM_COW: private_pages_count += info.private_pages_resident; - // Fall through + FALLTHROUGH; case SM_SHARED: case SM_PRIVATE_ALIASED: case SM_TRUESHARED: diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index 49fc290e0ae87b..e3c1b5b7b067fc 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -1056,7 +1056,7 @@ - (void)commandDispatch:(id)sender { chrome::ExecuteCommand(browser, IDC_NEW_TAB); break; } - // Else fall through to create new window. + FALLTHROUGH; // To create new window. case IDC_NEW_WINDOW: CreateBrowser(lastProfile); break; diff --git a/chrome/browser/chrome_browser_application_mac.mm b/chrome/browser/chrome_browser_application_mac.mm index 9e053afcdde615..4751110e2880ca 100644 --- a/chrome/browser/chrome_browser_application_mac.mm +++ b/chrome/browser/chrome_browser_application_mac.mm @@ -260,6 +260,7 @@ - (void)sendEvent:(NSEvent*)event { bool ctrlDown = [event modifierFlags] & NSControlKeyMask; if (kioskMode && ([event type] == NSRightMouseDown || ctrlDown)) break; + FALLTHROUGH; // Not menu-generating, so pass on the event. } default: { diff --git a/chrome/browser/mac/keystone_glue.mm b/chrome/browser/mac/keystone_glue.mm index 87fb51c8f721fb..3e93e7003ba307 100644 --- a/chrome/browser/mac/keystone_glue.mm +++ b/chrome/browser/mac/keystone_glue.mm @@ -427,7 +427,7 @@ - (NSString*)brandFilePath { case kBrandFileTypeNotDetermined: NOTIMPLEMENTED(); - // Fall through + FALLTHROUGH; case kBrandFileTypeNone: // Clear the value. result = @""; diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm index 33847ad7e19b8e..e467878b625edd 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm @@ -1747,7 +1747,7 @@ - (BOOL)handleInputText:(NSString*)newText { return NO; // NO because the selection-handling code will close // later. } - // Fall-through if selected index is folder. + FALLTHROUGH; } // Keys that open and close submenus. case NSRightArrowFunctionKey: { diff --git a/chrome/browser/ui/cocoa/download/download_item_mac.mm b/chrome/browser/ui/cocoa/download/download_item_mac.mm index b39137cb104872..d105254ebf8361 100644 --- a/chrome/browser/ui/cocoa/download/download_item_mac.mm +++ b/chrome/browser/ui/cocoa/download/download_item_mac.mm @@ -53,7 +53,7 @@ [item_controller_ remove]; // We're deleted now! return; } - // fall through + FALLTHROUGH; case DownloadItem::IN_PROGRESS: case DownloadItem::CANCELLED: [item_controller_ setStateFromDownload:&download_model_]; diff --git a/chrome/browser/ui/cocoa/gradient_button_cell.mm b/chrome/browser/ui/cocoa/gradient_button_cell.mm index 7a953c76b8f4c5..4755fe0c12b490 100644 --- a/chrome/browser/ui/cocoa/gradient_button_cell.mm +++ b/chrome/browser/ui/cocoa/gradient_button_cell.mm @@ -515,15 +515,16 @@ - (void)getDrawParamsForFrame:(NSRect)cellFrame case kMiddleButtonType: drawFrame.size.width += 20; innerFrame.size.width += 2; - // Fallthrough + FALLTHROUGH; case kRightButtonType: drawFrame.origin.x -= 20; innerFrame.origin.x -= 2; - // Fallthrough + FALLTHROUGH; case kLeftButtonType: case kLeftButtonWithShadowType: drawFrame.size.width += 20; innerFrame.size.width += 2; + break; default: break; } diff --git a/chrome/browser/ui/webui/help/version_updater_mac.mm b/chrome/browser/ui/webui/help/version_updater_mac.mm index c7f0393ab93a1e..243d56245425d8 100644 --- a/chrome/browser/ui/webui/help/version_updater_mac.mm +++ b/chrome/browser/ui/webui/help/version_updater_mac.mm @@ -191,7 +191,7 @@ - (void)handleStatusNotification:(NSNotification*)notification { case kAutoupdateRegisterFailed: enable_promote_button = false; - // Fall through. + FALLTHROUGH; case kAutoupdateCheckFailed: case kAutoupdateInstallFailed: case kAutoupdatePromoteFailed: diff --git a/device/gamepad/xbox_controller_mac.mm b/device/gamepad/xbox_controller_mac.mm index 5bafa1574a18aa..246ec86d162e03 100644 --- a/device/gamepad/xbox_controller_mac.mm +++ b/device/gamepad/xbox_controller_mac.mm @@ -779,6 +779,7 @@ void NormalizeXboxOneButtonData(const XboxOneButtonData& data, return; XboxOneGuideData* data = reinterpret_cast(buffer); delegate_->XboxControllerGotGuideData(this, data->down); + break; } default: // Unknown packet: ignore! diff --git a/media/gpu/vt_video_decode_accelerator_mac.cc b/media/gpu/vt_video_decode_accelerator_mac.cc index ab4ba8166bd671..15317c981ad405 100644 --- a/media/gpu/vt_video_decode_accelerator_mac.cc +++ b/media/gpu/vt_video_decode_accelerator_mac.cc @@ -761,8 +761,8 @@ void VTVideoDecodeAccelerator::DecodeTask(const BitstreamBuffer& bitstream, frame->pic_order_cnt = *pic_order_cnt; frame->reorder_window = ComputeReorderWindow(sps); } + FALLTHROUGH; - // Intentional fallthrough. default: nalus.push_back(nalu); data_size += kNALUHeaderLength + nalu.size; diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc index dac587bbd53fa5..706ba6e8e88278 100644 --- a/net/dns/dns_config_service_posix.cc +++ b/net/dns/dns_config_service_posix.cc @@ -173,6 +173,7 @@ ConfigParsePosixResult ReadDnsConfig(DnsConfig* dns_config) { case CONFIG_PARSE_POSIX_UNHANDLED_OPTIONS: LOG(WARNING) << "dns_config has unhandled options!"; dns_config->unhandled_options = true; + FALLTHROUGH; default: return error; } diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_mac.cc b/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_mac.cc index 5a9b10f00eeb9b..3c2e43796959ee 100644 --- a/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_mac.cc +++ b/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_mac.cc @@ -136,6 +136,7 @@ void PopulateByteStats(VMRegion* region, case SM_PRIVATE: case SM_COW: region->byte_stats_private_dirty_resident = dirty_bytes; + break; case SM_SHARED: case SM_PRIVATE_ALIASED: case SM_TRUESHARED: diff --git a/ui/accessibility/platform/ax_platform_node_mac.mm b/ui/accessibility/platform/ax_platform_node_mac.mm index f3c841366e9cba..3e42c04d0488e1 100644 --- a/ui/accessibility/platform/ax_platform_node_mac.mm +++ b/ui/accessibility/platform/ax_platform_node_mac.mm @@ -445,7 +445,7 @@ - (NSArray*)accessibilityAttributeNames { [axAttributes addObject:kTextAttributes]; if (!node_->GetData().HasState(ax::mojom::State::kProtected)) [axAttributes addObjectsFromArray:kUnprotectedTextAttributes]; - // Fallthrough. + FALLTHROUGH; case ax::mojom::Role::kCheckBox: case ax::mojom::Role::kComboBoxMenuButton: case ax::mojom::Role::kMenuItemCheckBox: