Commit 9674a45e authored by Will Harris's avatar Will Harris Committed by Commit Bot

Add a new configuration for disabling -Wshorten-64-to-32 warnings.

The old name for this was 'no_size_t_to_int_warning' which was
specific to MSVC. clang does not have a specific warning for just
64-bit size_t -> 32-bit value, but instead it has a warning for
any conversion from 64-bit to 32-bit (-Wshorten-64-to-32).

As part of re-enabling this warning, fixes will be landed to get
Chromium warning-clean with -Wshorten-64-to-32 on 64-bit builds
only (as tackling for 32-bit builds too, which was never covered
by any previous MSVC warning would be too big a first step).

For those projects that are e.g. third party or can be tackled at
a later date, they can include this new config.

The name is different from 'no_size_t_to_int_warning' because that
name is confusing (as the new warning enables more than just this).

New exceptions will be added with 'no_shorten_64_warnings' and
old 'no_size_t_to_int_warning' will be slowly removed or migrated
over time. Then the old config will be removed.

BUG=588506

Change-Id: I3a6ce9b19e52c7bdc724c7fd326f6afe7b509219
Reviewed-on: https://chromium-review.googlesource.com/1197404
Commit-Queue: Will Harris <wfh@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587858}
parent 897f35eb
...@@ -1762,10 +1762,36 @@ config("wexit_time_destructors") { ...@@ -1762,10 +1762,36 @@ config("wexit_time_destructors") {
# Note that this can be applied regardless of platform and architecture to # Note that this can be applied regardless of platform and architecture to
# clean up the call sites. This will only apply the flag when necessary. # clean up the call sites. This will only apply the flag when necessary.
# #
# This config is just an alias to no_shorten_64_warnings and will
# suppress a superset of warning 4267 and any 64-bit -> 32-bit implicit
# conversions. Having both for a time means not having to go through and
# update all references to no_size_t_to_int_warning throughout the codebase
# atomically.
#
# Any new warning suppressions should use the no_shorten_64_warnings
# config below and not this.
#
# TODO(jschuh): crbug.com/167187 fix this and delete this config. # TODO(jschuh): crbug.com/167187 fix this and delete this config.
config("no_size_t_to_int_warning") { config("no_size_t_to_int_warning") {
if (is_win && current_cpu == "x64") { configs = [ ":no_shorten_64_warnings" ]
cflags = [ "/wd4267" ] }
# As part of re-enabling -Wconversion (see issue 588506) some code
# will continue to generate warnings.
# The first warning to be enabled will be -Wshorten-64-to-32.
#
# Code that currently generates warnings for this can include this
# config to disable them.
config("no_shorten_64_warnings") {
if (current_cpu == "x64") {
if (is_clang) {
cflags = [ "-Wno-shorten-64-to-32" ]
} else {
# MSVC does not have an explicit warning equivalent to
# -Wshorten-64-to-32 but 4267 warns for size_t -> int
# on 64-bit builds, so is the closest.
cflags = [ "/wd4267" ]
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment