From 803e0a55478300c34f66360954259d2740a1d86a Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 25 Sep 2018 17:32:45 +0000 Subject: [PATCH] Build cc/ with -Wexit-time-destructors. Bug: 101600 Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel Change-Id: I39cc247a432861bf8e7ac815dc2d1a2834a2cf08 Reviewed-on: https://chromium-review.googlesource.com/1240975 Reviewed-by: danakj Commit-Queue: Nico Weber Cr-Commit-Position: refs/heads/master@{#593986} --- cc/BUILD.gn | 2 +- cc/cc.gni | 24 +++++++++++------------- cc/layers/picture_layer_impl.cc | 5 +++-- cc/paint/discardable_image_map.cc | 5 +++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cc/BUILD.gn b/cc/BUILD.gn index 844dc792ecc685..b5a24d07ecaef4 100644 --- a/cc/BUILD.gn +++ b/cc/BUILD.gn @@ -376,7 +376,7 @@ cc_component("cc") { defines = [ "CC_IMPLEMENTATION=1" ] } -cc_static_library("test_support") { +cc_test_static_library("test_support") { testonly = true sources = [ "test/animation_test_common.cc", diff --git a/cc/cc.gni b/cc/cc.gni index 44a5eebc517dbd..51bbd51a06c882 100644 --- a/cc/cc.gni +++ b/cc/cc.gni @@ -6,24 +6,16 @@ import("//build/config/jumbo.gni") import("//testing/test.gni") cc_remove_configs = [] -cc_add_configs = [ "//build/config:precompiled_headers" ] +cc_add_configs = [ + "//build/config:precompiled_headers", + "//build/config/compiler:wexit_time_destructors", +] if (!is_debug && (is_win || is_android)) { cc_remove_configs += [ "//build/config/compiler:default_optimization" ] cc_add_configs += [ "//build/config/compiler:optimize_max" ] } -template("cc_source_set") { - jumbo_source_set(target_name) { - forward_variables_from(invoker, "*", [ "configs" ]) - if (defined(invoker.configs)) { - configs += invoker.configs - } - configs -= cc_remove_configs - configs += cc_add_configs - } -} - template("cc_component") { jumbo_component(target_name) { forward_variables_from(invoker, "*", [ "configs" ]) @@ -35,7 +27,7 @@ template("cc_component") { } } -template("cc_static_library") { +template("cc_test_static_library") { jumbo_static_library(target_name) { forward_variables_from(invoker, "*", [ "configs" ]) if (defined(invoker.configs)) { @@ -43,6 +35,9 @@ template("cc_static_library") { } configs -= cc_remove_configs configs += cc_add_configs + + # Not needed in test code. + configs -= [ "//build/config/compiler:wexit_time_destructors" ] } } @@ -54,5 +49,8 @@ template("cc_test") { } configs -= cc_remove_configs configs += cc_add_configs + + # Not needed in test code. + configs -= [ "//build/config/compiler:wexit_time_destructors" ] } } diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index d28e60988c8f6f..9b7809e39beed5 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -13,6 +13,7 @@ #include #include "base/metrics/histogram_macros.h" +#include "base/no_destructor.h" #include "base/time/time.h" #include "base/trace_event/trace_event_argument.h" #include "build/build_config.h" @@ -666,11 +667,11 @@ bool PictureLayerImpl::UpdateTiles() { !layer_tree_impl()->SmoothnessTakesPriority(); } - static const Occlusion kEmptyOcclusion; + static const base::NoDestructor kEmptyOcclusion; const Occlusion& occlusion_in_content_space = layer_tree_impl()->settings().use_occlusion_for_tile_prioritization ? draw_properties().occlusion_in_content_space - : kEmptyOcclusion; + : *kEmptyOcclusion; // Pass |occlusion_in_content_space| for |occlusion_in_layer_space| since // they are the same space in picture layer, as contents scale is always 1. diff --git a/cc/paint/discardable_image_map.cc b/cc/paint/discardable_image_map.cc index 232dab6a1d483b..1c53bb9b523a2c 100644 --- a/cc/paint/discardable_image_map.cc +++ b/cc/paint/discardable_image_map.cc @@ -12,6 +12,7 @@ #include "base/auto_reset.h" #include "base/containers/adapters.h" #include "base/metrics/histogram_macros.h" +#include "base/no_destructor.h" #include "base/trace_event/trace_event.h" #include "cc/paint/paint_filter.h" #include "cc/paint/paint_op_buffer.h" @@ -456,9 +457,9 @@ void DiscardableImageMap::GetDiscardableImagesInRect( const DiscardableImageMap::Rects& DiscardableImageMap::GetRectsForImage( PaintImage::Id image_id) const { - static const Rects kEmptyRects; + static const base::NoDestructor kEmptyRects; auto it = image_id_to_rects_.find(image_id); - return it == image_id_to_rects_.end() ? kEmptyRects : it->second; + return it == image_id_to_rects_.end() ? *kEmptyRects : it->second; } void DiscardableImageMap::Reset() {