Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Issue 700383007: Use implicit_cast<> instead of static_cast<> whenever possible (Closed)

Created:
6 years, 1 month ago by Mark Mentovai
Modified:
6 years, 1 month ago
Reviewers:
Robert Sesek
CC:
crashpad-dev_chromium.org
Base URL:
https://chromium.googlesource.com/crashpad/crashpad@master
Project:
crashpad
Visibility:
Public.

Description

Use implicit_cast<> instead of static_cast<> whenever possible. implicit_cast<> only performs a cast in cases where an implicit conversion would be possible. It’s even safer than static_cast<> It’s an “explicit implicit” cast, which is not normally necsesary, but is frequently required when working with the ?: operator, functions like std::min() and std::max(), and logging and testing macros. The public style guide does not mention implicit_cast<> only because it is not part of the standard library, but would otherwise require it in these situations. Since base does provide implicit_cast<>, it should be used whenever possible. The only uses of static_cast<> not converted to implicit_cast<> are those that require static_cast<>, such as those that assign an integer constant to a variable of an enum type. R=rsesek@chromium.org Committed: https://chromium.googlesource.com/crashpad/crashpad/+/48b1964d1b215dae805bdf08089007bb8a7b285f

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+127 lines, -119 lines) Patch
M client/capture_context_mac_test.cc View 2 chunks +3 lines, -2 lines 0 comments Download
M client/simple_string_dictionary.h View 1 chunk +1 line, -1 line 2 comments Download
M client/simulate_crash_mac.cc View 2 chunks +5 lines, -5 lines 0 comments Download
M client/simulate_crash_mac_test.cc View 3 chunks +6 lines, -6 lines 0 comments Download
M minidump/minidump_module_writer.cc View 2 chunks +4 lines, -4 lines 0 comments Download
M minidump/minidump_module_writer_test.cc View 2 chunks +3 lines, -3 lines 0 comments Download
M minidump/minidump_system_info_writer.cc View 2 chunks +8 lines, -8 lines 0 comments Download
M minidump/minidump_system_info_writer_test.cc View 1 chunk +1 line, -1 line 0 comments Download
M minidump/test/minidump_writable_test_util.cc View 3 chunks +5 lines, -3 lines 0 comments Download
M snapshot/cpu_context.cc View 2 chunks +6 lines, -5 lines 0 comments Download
M snapshot/mac/mach_o_image_reader.cc View 1 chunk +1 line, -1 line 0 comments Download
M snapshot/mac/mach_o_image_reader_test.cc View 3 chunks +3 lines, -3 lines 0 comments Download
M snapshot/mac/process_types_test.cc View 7 chunks +9 lines, -8 lines 0 comments Download
M util/file/file_writer.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M util/file/string_file_writer_test.cc View 2 chunks +4 lines, -4 lines 0 comments Download
M util/mac/launchd.mm View 3 chunks +3 lines, -2 lines 0 comments Download
M util/mach/exc_client_variants_test.cc View 2 chunks +3 lines, -3 lines 0 comments Download
M util/mach/exc_server_variants_test.cc View 5 chunks +6 lines, -6 lines 0 comments Download
M util/mach/mach_extensions.h View 1 chunk +2 lines, -2 lines 0 comments Download
M util/mach/mach_message_server.cc View 1 chunk +1 line, -1 line 0 comments Download
M util/mach/mach_message_server_test.cc View 4 chunks +5 lines, -5 lines 0 comments Download
M util/mach/symbolic_constants_mach.cc View 7 chunks +7 lines, -7 lines 0 comments Download
M util/mach/symbolic_constants_mach_test.cc View 2 chunks +16 lines, -16 lines 0 comments Download
M util/misc/clock_test.cc View 1 chunk +7 lines, -7 lines 0 comments Download
M util/net/http_body.cc View 1 chunk +1 line, -1 line 0 comments Download
M util/net/http_body_test.cc View 1 chunk +1 line, -1 line 0 comments Download
M util/net/http_transport_mac.mm View 1 chunk +1 line, -1 line 0 comments Download
M util/numeric/checked_range.h View 1 chunk +1 line, -1 line 0 comments Download
M util/numeric/in_range_cast_test.cc View 2 chunks +3 lines, -3 lines 0 comments Download
M util/posix/process_util_test.cc View 2 chunks +2 lines, -1 line 0 comments Download
M util/posix/symbolic_constants_posix.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M util/test/mac/mach_multiprocess.cc View 1 chunk +3 lines, -3 lines 0 comments Download
M util/test/posix/close_multiple.cc View 2 chunks +2 lines, -1 line 0 comments Download

Messages

Total messages: 5 (1 generated)
Mark Mentovai
6 years, 1 month ago (2014-11-06 14:45:23 UTC) #2
Robert Sesek
LGTM https://codereview.chromium.org/700383007/diff/1/client/simple_string_dictionary.h File client/simple_string_dictionary.h (right): https://codereview.chromium.org/700383007/diff/1/client/simple_string_dictionary.h#newcode234 client/simple_string_dictionary.h:234: DCHECK_EQ(GetEntryForKey(key), implicit_cast<Entry*>(nullptr)); Is this cast necessary with nullptr?
6 years, 1 month ago (2014-11-06 19:52:26 UTC) #3
Mark Mentovai
https://codereview.chromium.org/700383007/diff/1/client/simple_string_dictionary.h File client/simple_string_dictionary.h (right): https://codereview.chromium.org/700383007/diff/1/client/simple_string_dictionary.h#newcode234 client/simple_string_dictionary.h:234: DCHECK_EQ(GetEntryForKey(key), implicit_cast<Entry*>(nullptr)); Robert Sesek wrote: > Is this cast ...
6 years, 1 month ago (2014-11-06 21:44:35 UTC) #4
Mark Mentovai
6 years, 1 month ago (2014-11-06 21:44:49 UTC) #5
Message was sent while issue was closed.
Committed patchset #1 (id:1) manually as
48b1964d1b215dae805bdf08089007bb8a7b285f (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698