mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
Replace implicit_cast usage with static_cast.
chromium's implicit_cast is going to be removed so stop using it. BUG=529769,472900 R=mark@chromium.org Review URL: https://codereview.chromium.org/1335353002 .
This commit is contained in:
parent
6c23e37ee9
commit
5069c2903a
@ -19,9 +19,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "build/build_config.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/logging.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "util/mach/exception_behaviors.h"
|
||||
#include "util/mach/exception_ports.h"
|
||||
#include "util/mach/mach_extensions.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "util/mach/mach_message.h"
|
||||
#include "util/mach/mach_message_server.h"
|
||||
#include "util/mach/symbolic_constants_mach.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "minidump/minidump_writer_util.h"
|
||||
#include "snapshot/module_snapshot.h"
|
||||
#include "util/file/file_writer.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
#include "util/numeric/in_range_cast.h"
|
||||
#include "util/numeric/safe_assignment.h"
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "snapshot/test/test_module_snapshot.h"
|
||||
#include "test/gtest_death_check.h"
|
||||
#include "util/file/string_file.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
#include "util/misc/uuid.h"
|
||||
#include "util/stdlib/pointer_container.h"
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "minidump/minidump_string_writer.h"
|
||||
#include "snapshot/system_snapshot.h"
|
||||
#include "util/file/file_writer.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
|
@ -16,10 +16,10 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "util/file/file_writer.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/logging.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "snapshot/mac/mach_o_image_symbol_table_reader.h"
|
||||
#include "snapshot/mac/process_reader.h"
|
||||
#include "util/mac/checked_mach_address_range.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "snapshot/mac/process_reader.h"
|
||||
#include "snapshot/mac/process_types.h"
|
||||
#include "test/mac/dyld.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
#include "util/misc/uuid.h"
|
||||
|
||||
// This file is responsible for testing MachOImageReader,
|
||||
|
44
util/misc/implicit_cast.h
Normal file
44
util/misc/implicit_cast.h
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright 2015 The Crashpad Authors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_UTIL_MISC_IMPLICIT_CAST_H_
|
||||
#define CRASHPAD_UTIL_MISC_IMPLICIT_CAST_H_
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
// Use implicit_cast as a safe version of static_cast or const_cast
|
||||
// for upcasting in the type hierarchy (i.e. casting a pointer to Foo
|
||||
// to a pointer to SuperclassOfFoo or casting a pointer to Foo to
|
||||
// a const pointer to Foo).
|
||||
// When you use implicit_cast, the compiler checks that the cast is safe.
|
||||
// Such explicit implicit_casts are necessary in surprisingly many
|
||||
// situations where C++ demands an exact type match instead of an
|
||||
// argument type convertible to a target type.
|
||||
//
|
||||
// The From type can be inferred, so the preferred syntax for using
|
||||
// implicit_cast is the same as for static_cast etc.:
|
||||
//
|
||||
// implicit_cast<ToType>(expr)
|
||||
//
|
||||
// implicit_cast would have been part of the C++ standard library,
|
||||
// but the proposal was submitted too late. It will probably make
|
||||
// its way into the language in the future.
|
||||
template<typename To, typename From>
|
||||
inline To implicit_cast(From const &f) {
|
||||
return f;
|
||||
}
|
||||
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_UTIL_MISC_IMPLICIT_CAST_H_
|
@ -88,6 +88,7 @@
|
||||
'misc/clock_mac.cc',
|
||||
'misc/clock_posix.cc',
|
||||
'misc/clock_win.cc',
|
||||
'misc/implicit_cast.h',
|
||||
'misc/initialization_state.h',
|
||||
'misc/initialization_state_dcheck.cc',
|
||||
'misc/initialization_state_dcheck.h',
|
||||
|
Loading…
x
Reference in New Issue
Block a user