Commit de9574ce authored by Arthur Eubanks's avatar Arthur Eubanks Committed by Commit Bot

Fix up gperf's pointer to int casting

Pointers are only guaranteed to be castable to an integer of at least
the same size.

gperf currently generates something like
{(int)(long)&(foo), bar},

Replace it with
{static_cast<int>(reinterpret_cast<uintptr_t>(&(foo)), bar},

Bug: 1059231
Change-Id: Ic68a92f8239ec0d51485f17ac5ada91b7617636e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2098763Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Arthur Eubanks <aeubanks@google.com>
Cr-Commit-Position: refs/heads/master@{#749354}
parent 825d7256
...@@ -40,6 +40,13 @@ def generate_gperf(gperf_path, gperf_input, gperf_args): ...@@ -40,6 +40,13 @@ def generate_gperf(gperf_path, gperf_input, gperf_args):
# https://savannah.gnu.org/bugs/index.php?53029 # https://savannah.gnu.org/bugs/index.php?53029
gperf_output = gperf_output.replace('/*FALLTHROUGH*/', gperf_output = gperf_output.replace('/*FALLTHROUGH*/',
' FALLTHROUGH;') ' FALLTHROUGH;')
# -Wpointer-to-int-cast warns about casting pointers to smaller ints
# Replace {(int)(long)&(foo), bar} with
# {static_cast<int>(reinterpret_cast<uintptr_t>(&(foo)), bar}
gperf_output = re.sub(
r'\(int\)\(long\)(.*?),',
r'static_cast<int>(reinterpret_cast<uintptr_t>(\1)),',
gperf_output)
script = 'third_party/blink/renderer/build/scripts/gperf.py' script = 'third_party/blink/renderer/build/scripts/gperf.py'
return '// Generated by %s\n' % script + gperf_output return '// Generated by %s\n' % script + gperf_output
except OSError: except OSError:
......
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