From a5f0d96bc4f40971fc82e0b2255e27056d4621d1 Mon Sep 17 00:00:00 2001 From: danakj Date: Tue, 15 Sep 2015 13:27:24 -0700 Subject: [PATCH] Remove base's implicit_cast. There's no momentum on making this a thing in the C++ standard. We should have less magic that is non-standard in base. R=ricea@chromium.org, thakis@chromium.org, vmpstr BUG=529769 Review URL: https://codereview.chromium.org/1340683002 Cr-Commit-Position: refs/heads/master@{#348978} --- android_webview/native/aw_contents.cc | 2 +- base/android/scoped_java_ref.h | 7 +++-- base/files/file_unittest.cc | 2 +- base/macros.h | 23 ---------------- base/memory/scoped_ptr.h | 4 +-- base/numerics/safe_numerics_unittest.cc | 6 ++--- .../app_shim/app_shim_host_mac_unittest.cc | 10 +++---- .../chrome_native_app_window_views_mac.mm | 2 +- .../chrome_native_app_window_views_win.cc | 3 +-- .../history/core/browser/history_backend.cc | 3 ++- .../core/browser/visitsegment_database.cc | 3 ++- .../browser/cache_storage/cache_storage.cc | 3 ++- net/disk_cache/backend_unittest.cc | 14 +++++----- net/disk_cache/entry_unittest.cc | 2 +- net/disk_cache/simple/simple_index_file.cc | 3 ++- .../simple/simple_index_file_unittest.cc | 10 +++---- .../simple/simple_synchronous_entry.cc | 10 +++---- .../simple/simple_version_upgrade_unittest.cc | 27 +++++++++---------- .../flip_server/url_utilities_unittest.cc | 4 +-- net/tools/quic/quic_client_session_test.cc | 4 +-- ui/base/page_transition_types.cc | 7 +++-- .../mac/dialog_button_border_mac_unittest.cc | 4 +-- 22 files changed, 64 insertions(+), 89 deletions(-) diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc index 0f036290e98f61..1aad1f5d21a26c 100644 --- a/android_webview/native/aw_contents.cc +++ b/android_webview/native/aw_contents.cc @@ -180,7 +180,7 @@ AwBrowserPermissionRequestDelegate* AwBrowserPermissionRequestDelegate::FromID( content::WebContents::FromRenderFrameHost( content::RenderFrameHost::FromID(render_process_id, render_frame_id))); - return implicit_cast(aw_contents); + return aw_contents; } AwContents::AwContents(scoped_ptr web_contents) diff --git a/base/android/scoped_java_ref.h b/base/android/scoped_java_ref.h index 6d441954a4e902..cad63b75617a10 100644 --- a/base/android/scoped_java_ref.h +++ b/base/android/scoped_java_ref.h @@ -11,6 +11,7 @@ #include "base/base_export.h" #include "base/basictypes.h" #include "base/logging.h" +#include "base/template_util.h" namespace base { namespace android { @@ -178,7 +179,8 @@ class ScopedJavaLocalRef : public JavaRef { template void Reset(JNIEnv* env, U obj) { - implicit_cast(obj); // Ensure U is assignable to T + static_assert(base::is_convertible::value, + "U must be convertible to T"); env_ = this->SetNewLocalRef(env, obj); } @@ -242,7 +244,8 @@ class ScopedJavaGlobalRef : public JavaRef { template void Reset(JNIEnv* env, U obj) { - implicit_cast(obj); // Ensure U is assignable to T + static_assert(base::is_convertible::value, + "U must be convertible to T"); this->SetNewGlobalRef(env, obj); } diff --git a/base/files/file_unittest.cc b/base/files/file_unittest.cc index 5c594242bc8486..3d60b2c870fc72 100644 --- a/base/files/file_unittest.cc +++ b/base/files/file_unittest.cc @@ -517,7 +517,7 @@ TEST(FileTest, MemoryCorruption) { // Test that changing the checksum value is detected. base::File file; EXPECT_NE(file.file_.file_memory_checksum_, - implicit_cast(file.GetPlatformFile())); + static_cast(file.GetPlatformFile())); file.file_.file_memory_checksum_ = file.GetPlatformFile(); EXPECT_DEATH(file.IsValid(), ""); diff --git a/base/macros.h b/base/macros.h index 53b3926cd2424a..c5f503fbc3ae91 100644 --- a/base/macros.h +++ b/base/macros.h @@ -55,29 +55,6 @@ template char (&ArraySizeHelper(T (&array)[N]))[N]; #define arraysize(array) (sizeof(ArraySizeHelper(array))) - -// 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(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 -inline To implicit_cast(From const &f) { - return f; -} - // The COMPILE_ASSERT macro can be used to verify that a compile time // expression is true. For example, you could use it to verify the // size of a static array: diff --git a/base/memory/scoped_ptr.h b/base/memory/scoped_ptr.h index 987ccfa804eadd..fb781b0b32ddfd 100644 --- a/base/memory/scoped_ptr.h +++ b/base/memory/scoped_ptr.h @@ -465,9 +465,7 @@ class scoped_ptr { // (C++98 [expr.delete]p3). If you're doing this, fix your code. // - it cannot be const-qualified differently from T per unique_ptr spec // (http://cplusplus.github.com/LWG/lwg-active.html#2118). Users wanting - // to work around this may use implicit_cast(). - // However, because of the first bullet in this comment, users MUST - // NOT use implicit_cast() to upcast the static type of the array. + // to work around this may use const_cast(). explicit scoped_ptr(element_type* array) : impl_(array) {} // Constructor. Allows construction from a nullptr. diff --git a/base/numerics/safe_numerics_unittest.cc b/base/numerics/safe_numerics_unittest.cc index bad0f5718516b4..f2bb011eb4758b 100644 --- a/base/numerics/safe_numerics_unittest.cc +++ b/base/numerics/safe_numerics_unittest.cc @@ -673,9 +673,9 @@ TEST(SafeNumerics, IsValueInRangeForNumericType) { EXPECT_TRUE(IsValueInRangeForNumericType( std::numeric_limits::min())); EXPECT_TRUE(IsValueInRangeForNumericType( - implicit_cast(std::numeric_limits::min()))); + static_cast(std::numeric_limits::min()))); EXPECT_FALSE(IsValueInRangeForNumericType( - implicit_cast(std::numeric_limits::min()) - 1)); + static_cast(std::numeric_limits::min()) - 1)); EXPECT_FALSE(IsValueInRangeForNumericType( std::numeric_limits::min())); @@ -715,7 +715,7 @@ TEST(SafeNumerics, IsValueInRangeForNumericType) { EXPECT_TRUE(IsValueInRangeForNumericType( std::numeric_limits::min())); EXPECT_TRUE(IsValueInRangeForNumericType( - implicit_cast(std::numeric_limits::min()))); + static_cast(std::numeric_limits::min()))); EXPECT_TRUE(IsValueInRangeForNumericType( std::numeric_limits::min())); } diff --git a/chrome/browser/apps/app_shim/app_shim_host_mac_unittest.cc b/chrome/browser/apps/app_shim/app_shim_host_mac_unittest.cc index e20a9b5fcb2ed5..9a79097994cd7e 100644 --- a/chrome/browser/apps/app_shim/app_shim_host_mac_unittest.cc +++ b/chrome/browser/apps/app_shim/app_shim_host_mac_unittest.cc @@ -78,7 +78,7 @@ class AppShimHostTest : public testing::Test, } void SimulateDisconnect() { - implicit_cast(host_.release())->OnChannelError(); + static_cast(host_.release())->OnChannelError(); } protected: @@ -128,7 +128,7 @@ TEST_F(AppShimHostTest, TestLaunchAppWithHandler) { apps::AppShimHandler::RegisterHandler(kTestAppId, this); LaunchApp(apps::APP_SHIM_LAUNCH_NORMAL); EXPECT_EQ(kTestAppId, - implicit_cast(host())->GetAppId()); + static_cast(host())->GetAppId()); EXPECT_EQ(apps::APP_SHIM_LAUNCH_SUCCESS, GetLaunchResult()); EXPECT_EQ(1, launch_count_); EXPECT_EQ(1, launch_now_count_); @@ -136,8 +136,8 @@ TEST_F(AppShimHostTest, TestLaunchAppWithHandler) { EXPECT_EQ(0, close_count_); // A second OnAppLaunchComplete is ignored. - implicit_cast(host())-> - OnAppLaunchComplete(apps::APP_SHIM_LAUNCH_APP_NOT_FOUND); + static_cast(host()) + ->OnAppLaunchComplete(apps::APP_SHIM_LAUNCH_APP_NOT_FOUND); EXPECT_EQ(apps::APP_SHIM_LAUNCH_SUCCESS, GetLaunchResult()); EXPECT_TRUE(host()->ReceiveMessage( @@ -157,7 +157,7 @@ TEST_F(AppShimHostTest, TestNoLaunchNow) { apps::AppShimHandler::RegisterHandler(kTestAppId, this); LaunchApp(apps::APP_SHIM_LAUNCH_REGISTER_ONLY); EXPECT_EQ(kTestAppId, - implicit_cast(host())->GetAppId()); + static_cast(host())->GetAppId()); EXPECT_EQ(apps::APP_SHIM_LAUNCH_SUCCESS, GetLaunchResult()); EXPECT_EQ(1, launch_count_); EXPECT_EQ(0, launch_now_count_); diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views_mac.mm b/chrome/browser/ui/views/apps/chrome_native_app_window_views_mac.mm index ab7e05aa336eaa..5572ab1c96bc5b 100644 --- a/chrome/browser/ui/views/apps/chrome_native_app_window_views_mac.mm +++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views_mac.mm @@ -38,7 +38,7 @@ - (id)initForNativeAppWindow:(ChromeNativeAppWindowViewsMac*)nativeAppWindow { addObserver:self selector:@selector(onWindowWillStartLiveResize:) name:NSWindowWillStartLiveResizeNotification - object:implicit_cast(nativeAppWindow) + object:static_cast(nativeAppWindow) ->GetNativeWindow()]; } return self; diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views_win.cc b/chrome/browser/ui/views/apps/chrome_native_app_window_views_win.cc index 8ff89ed9708ce4..eaa1ec6a0cf1a5 100644 --- a/chrome/browser/ui/views/apps/chrome_native_app_window_views_win.cc +++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views_win.cc @@ -57,8 +57,7 @@ bool ChromeNativeAppWindowViewsWin::IsRunningInAsh() { if (!ash::Shell::HasInstance()) return false; - views::Widget* widget = - implicit_cast(this)->GetWidget(); + views::Widget* widget = GetWidget(); chrome::HostDesktopType host_desktop_type = chrome::GetHostDesktopTypeForNativeWindow(widget->GetNativeWindow()); return host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH; diff --git a/components/history/core/browser/history_backend.cc b/components/history/core/browser/history_backend.cc index ad61094c5702e5..19836b7f168bc4 100644 --- a/components/history/core/browser/history_backend.cc +++ b/components/history/core/browser/history_backend.cc @@ -1367,7 +1367,8 @@ void HistoryBackend::QueryFilteredURLs(int result_count, // Limit to the top |result_count| results. std::sort(data.begin(), data.end(), PageUsageData::Predicate); - if (result_count && implicit_cast(data.size()) > result_count) + DCHECK_GE(result_count, 0); + if (result_count && data.size() > static_cast(result_count)) data.resize(result_count); for (size_t i = 0; i < data.size(); ++i) { diff --git a/components/history/core/browser/visitsegment_database.cc b/components/history/core/browser/visitsegment_database.cc index afeecb71441946..232e044258d68e 100644 --- a/components/history/core/browser/visitsegment_database.cc +++ b/components/history/core/browser/visitsegment_database.cc @@ -258,7 +258,8 @@ void VisitSegmentDatabase::QuerySegmentUsage( // Limit to the top kResultCount results. std::sort(results->begin(), results->end(), PageUsageData::Predicate); - if (static_cast(results->size()) > max_result_count) { + DCHECK_GE(max_result_count, 0); + if (results->size() > static_cast(max_result_count)) { STLDeleteContainerPointers(results->begin() + max_result_count, results->end()); results->resize(max_result_count); diff --git a/content/browser/cache_storage/cache_storage.cc b/content/browser/cache_storage/cache_storage.cc index f511164c6905e4..42f0215b8477c7 100644 --- a/content/browser/cache_storage/cache_storage.cc +++ b/content/browser/cache_storage/cache_storage.cc @@ -12,6 +12,7 @@ #include "base/location.h" #include "base/memory/ref_counted.h" #include "base/metrics/histogram_macros.h" +#include "base/numerics/safe_conversions.h" #include "base/sha1.h" #include "base/single_thread_task_runner.h" #include "base/stl_util.h" @@ -276,7 +277,7 @@ class CacheStorage::SimpleCacheLoader : public CacheStorage::CacheLoader { const BoolCallback& callback, const scoped_refptr& original_task_runner) { int bytes_written = base::WriteFile(tmp_path, data.c_str(), data.size()); - if (bytes_written != implicit_cast(data.size())) { + if (bytes_written != base::checked_cast(data.size())) { base::DeleteFile(tmp_path, /* recursive */ false); original_task_runner->PostTask(FROM_HERE, base::Bind(callback, false)); } diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc index 8ea080a040a6f8..d1d72a4084d601 100644 --- a/net/disk_cache/backend_unittest.cc +++ b/net/disk_cache/backend_unittest.cc @@ -252,7 +252,7 @@ bool DiskCacheBackendTest::CreateSetOfRandomEntries( key_pool->insert(key); entry->Close(); } - return key_pool->size() == implicit_cast(cache_->GetEntryCount()); + return key_pool->size() == static_cast(cache_->GetEntryCount()); } // Performs iteration over the backend and checks that the keys of entries @@ -274,7 +274,7 @@ bool DiskCacheBackendTest::EnumerateAndMatchKeys( EXPECT_EQ(1U, keys_to_match->erase(entry->GetKey())); entry->Close(); ++(*count); - if (max_to_open >= 0 && implicit_cast(*count) >= max_to_open) + if (max_to_open >= 0 && static_cast(*count) >= max_to_open) break; }; @@ -3327,10 +3327,9 @@ TEST_F(DiskCacheBackendTest, SimpleCacheOpenBadFile) { disk_cache::SimpleFileHeader header; header.initial_magic_number = UINT64_C(0xbadf00d); - EXPECT_EQ( - implicit_cast(sizeof(header)), - base::WriteFile(entry_file1_path, reinterpret_cast(&header), - sizeof(header))); + EXPECT_EQ(static_cast(sizeof(header)), + base::WriteFile(entry_file1_path, reinterpret_cast(&header), + sizeof(header))); ASSERT_EQ(net::ERR_FAILED, OpenEntry(key, &entry)); } @@ -3489,8 +3488,7 @@ TEST_F(DiskCacheBackendTest, SimpleCacheEnumerationCorruption) { EXPECT_TRUE(disk_cache::simple_util::CreateCorruptFileForTests( key, cache_path_)); - EXPECT_EQ(key_pool.size() + 1, - implicit_cast(cache_->GetEntryCount())); + EXPECT_EQ(key_pool.size() + 1, static_cast(cache_->GetEntryCount())); // Check that enumeration returns all entries but the corrupt one. std::set keys_to_match(key_pool); diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc index bf154f23d90366..639cf87d320c0f 100644 --- a/net/disk_cache/entry_unittest.cc +++ b/net/disk_cache/entry_unittest.cc @@ -2718,7 +2718,7 @@ TEST_F(DiskCacheEntryTest, SimpleCacheNoEOF) { // Truncate the file such that the length isn't sufficient to have an EOF // record. - int kTruncationBytes = -implicit_cast(sizeof(disk_cache::SimpleFileEOF)); + int kTruncationBytes = -static_cast(sizeof(disk_cache::SimpleFileEOF)); const base::FilePath entry_path = cache_path_.AppendASCII( disk_cache::simple_util::GetFilenameFromKeyAndFileIndex(key, 0)); const int64 invalid_size = diff --git a/net/disk_cache/simple/simple_index_file.cc b/net/disk_cache/simple/simple_index_file.cc index c013084041f301..11d37a95048b90 100644 --- a/net/disk_cache/simple/simple_index_file.cc +++ b/net/disk_cache/simple/simple_index_file.cc @@ -11,6 +11,7 @@ #include "base/files/memory_mapped_file.h" #include "base/hash.h" #include "base/logging.h" +#include "base/numerics/safe_conversions.h" #include "base/pickle.h" #include "base/single_thread_task_runner.h" #include "base/task_runner_util.h" @@ -77,7 +78,7 @@ bool WritePickleFile(base::Pickle* pickle, const base::FilePath& file_name) { int bytes_written = file.Write(0, static_cast(pickle->data()), pickle->size()); - if (bytes_written != implicit_cast(pickle->size())) { + if (bytes_written != base::checked_cast(pickle->size())) { simple_util::SimpleCacheDeleteFile(file_name); return false; } diff --git a/net/disk_cache/simple/simple_index_file_unittest.cc b/net/disk_cache/simple/simple_index_file_unittest.cc index cfff0792f9a887..ae4945a045b3c6 100644 --- a/net/disk_cache/simple/simple_index_file_unittest.cc +++ b/net/disk_cache/simple/simple_index_file_unittest.cc @@ -221,9 +221,8 @@ TEST_F(SimpleIndexFileTest, LoadCorruptIndex) { ASSERT_TRUE(simple_index_file.CreateIndexFileDirectory()); const base::FilePath& index_path = simple_index_file.GetIndexFilePath(); const std::string kDummyData = "nothing to be seen here"; - EXPECT_EQ( - implicit_cast(kDummyData.size()), - base::WriteFile(index_path, kDummyData.data(), kDummyData.size())); + EXPECT_EQ(static_cast(kDummyData.size()), + base::WriteFile(index_path, kDummyData.data(), kDummyData.size())); base::Time fake_cache_mtime; ASSERT_TRUE(simple_util::GetMTime(simple_index_file.GetIndexFilePath(), &fake_cache_mtime)); @@ -263,9 +262,8 @@ TEST_F(SimpleIndexFileTest, SimpleCacheUpgrade) { const std::string index_file_contents("incorrectly serialized data"); const base::FilePath old_index_file = cache_path.AppendASCII("the-real-index"); - ASSERT_EQ(implicit_cast(index_file_contents.size()), - base::WriteFile(old_index_file, - index_file_contents.data(), + ASSERT_EQ(static_cast(index_file_contents.size()), + base::WriteFile(old_index_file, index_file_contents.data(), index_file_contents.size())); // Upgrade the cache. diff --git a/net/disk_cache/simple/simple_synchronous_entry.cc b/net/disk_cache/simple/simple_synchronous_entry.cc index 2c0412db17f061..f6f0c71717d457 100644 --- a/net/disk_cache/simple/simple_synchronous_entry.cc +++ b/net/disk_cache/simple/simple_synchronous_entry.cc @@ -939,7 +939,7 @@ int SimpleSynchronousEntry::InitializeForOpen( scoped_ptr key(new char[header.key_length]); int key_read_result = files_[i].Read(sizeof(header), key.get(), header.key_length); - if (key_read_result != implicit_cast(header.key_length)) { + if (key_read_result != base::checked_cast(header.key_length)) { DLOG(WARNING) << "Cannot read key from entry."; RecordSyncOpenResult(cache_type_, OPEN_ENTRY_CANT_READ_KEY, had_index); return net::ERR_FAILED; @@ -1018,7 +1018,7 @@ bool SimpleSynchronousEntry::InitializeCreatedFile( bytes_written = files_[file_index].Write(sizeof(header), key_.data(), key_.size()); - if (bytes_written != implicit_cast(key_.size())) { + if (bytes_written != base::checked_cast(key_.size())) { *out_result = CREATE_ENTRY_CANT_WRITE_KEY; return false; } @@ -1248,7 +1248,7 @@ bool SimpleSynchronousEntry::InitializeSparseFile() { int key_write_result = sparse_file_.Write(sizeof(header), key_.data(), key_.size()); - if (key_write_result != implicit_cast(key_.size())) { + if (key_write_result != base::checked_cast(key_.size())) { DLOG(WARNING) << "Could not write sparse file key"; return false; } @@ -1378,7 +1378,7 @@ bool SimpleSynchronousEntry::WriteSparseRange(SparseRange* range, int bytes_written = sparse_file_.Write(range->file_offset - sizeof(header), reinterpret_cast(&header), sizeof(header)); - if (bytes_written != implicit_cast(sizeof(header))) { + if (bytes_written != base::checked_cast(sizeof(header))) { DLOG(WARNING) << "Could not rewrite sparse range header."; return false; } @@ -1413,7 +1413,7 @@ bool SimpleSynchronousEntry::AppendSparseRange(int64 offset, int bytes_written = sparse_file_.Write(sparse_tail_offset_, reinterpret_cast(&header), sizeof(header)); - if (bytes_written != implicit_cast(sizeof(header))) { + if (bytes_written != base::checked_cast(sizeof(header))) { DLOG(WARNING) << "Could not append sparse range header."; return false; } diff --git a/net/disk_cache/simple/simple_version_upgrade_unittest.cc b/net/disk_cache/simple/simple_version_upgrade_unittest.cc index febf527573470b..0a8d8c9a79d95a 100644 --- a/net/disk_cache/simple/simple_version_upgrade_unittest.cc +++ b/net/disk_cache/simple/simple_version_upgrade_unittest.cc @@ -56,9 +56,9 @@ TEST(SimpleVersionUpgradeTest, FailsToMigrateBackwards) { data.unused_must_be_zero1 = 0; data.unused_must_be_zero2 = 0; const base::FilePath file_name = cache_path.AppendASCII(kFakeIndexFileName); - ASSERT_EQ(implicit_cast(sizeof(data)), - base::WriteFile( - file_name, reinterpret_cast(&data), sizeof(data))); + ASSERT_EQ(static_cast(sizeof(data)), + base::WriteFile(file_name, reinterpret_cast(&data), + sizeof(data))); EXPECT_FALSE(disk_cache::UpgradeSimpleCacheOnDisk(cache_dir.path())); } @@ -70,9 +70,9 @@ TEST(SimpleVersionUpgradeTest, FakeIndexVersionGetsUpdated) { WriteFakeIndexFileV5(cache_path); const std::string file_contents("incorrectly serialized data"); const base::FilePath index_file = cache_path.AppendASCII(kIndexFileName); - ASSERT_EQ(implicit_cast(file_contents.size()), - base::WriteFile( - index_file, file_contents.data(), file_contents.size())); + ASSERT_EQ( + static_cast(file_contents.size()), + base::WriteFile(index_file, file_contents.data(), file_contents.size())); // Upgrade. ASSERT_TRUE(disk_cache::UpgradeSimpleCacheOnDisk(cache_path)); @@ -97,9 +97,9 @@ TEST(SimpleVersionUpgradeTest, UpgradeV5V6IndexMustDisappear) { WriteFakeIndexFileV5(cache_path); const std::string file_contents("incorrectly serialized data"); const base::FilePath index_file = cache_path.AppendASCII(kIndexFileName); - ASSERT_EQ(implicit_cast(file_contents.size()), - base::WriteFile( - index_file, file_contents.data(), file_contents.size())); + ASSERT_EQ( + static_cast(file_contents.size()), + base::WriteFile(index_file, file_contents.data(), file_contents.size())); // Create a few entry-like files. const uint64 kEntries = 5; @@ -109,11 +109,10 @@ TEST(SimpleVersionUpgradeTest, UpgradeV5V6IndexMustDisappear) { base::StringPrintf("%016" PRIx64 "_%1d", entry_hash, index); std::string entry_contents = file_contents + - base::StringPrintf(" %" PRIx64, implicit_cast(entry_hash)); - ASSERT_EQ(implicit_cast(entry_contents.size()), + base::StringPrintf(" %" PRIx64, static_cast(entry_hash)); + ASSERT_EQ(static_cast(entry_contents.size()), base::WriteFile(cache_path.AppendASCII(file_name), - entry_contents.data(), - entry_contents.size())); + entry_contents.data(), entry_contents.size())); } } @@ -128,7 +127,7 @@ TEST(SimpleVersionUpgradeTest, UpgradeV5V6IndexMustDisappear) { base::StringPrintf("%016" PRIx64 "_%1d", entry_hash, index); std::string expected_contents = file_contents + - base::StringPrintf(" %" PRIx64, implicit_cast(entry_hash)); + base::StringPrintf(" %" PRIx64, static_cast(entry_hash)); std::string real_contents; EXPECT_TRUE(base::ReadFileToString(cache_path.AppendASCII(file_name), &real_contents)); diff --git a/net/tools/flip_server/url_utilities_unittest.cc b/net/tools/flip_server/url_utilities_unittest.cc index cd44f9ce02fef0..b766c6cf3abe46 100644 --- a/net/tools/flip_server/url_utilities_unittest.cc +++ b/net/tools/flip_server/url_utilities_unittest.cc @@ -61,7 +61,7 @@ TEST(UrlUtilitiesTest, Unescape) { "%2B%3D%7B%5B%7D%5D%7C%5C%3A%3B%22%27%3C%2C" "%3E%2E%3F%2F")); for (int c = 0; c < 256; ++c) { - std::string unescaped_char(1, implicit_cast(c)); + std::string unescaped_char(1, static_cast(c)); std::string escaped_char = base::StringPrintf("%%%02X", c); EXPECT_EQ(unescaped_char, UrlUtilities::Unescape(escaped_char)) << "escaped_char = " << escaped_char; @@ -75,7 +75,7 @@ TEST(UrlUtilitiesTest, Unescape) { UrlUtilities::Unescape("~`!@#$^&*()_-+={[}]|\\:;\"'<,>.?/")); for (int c = 0; c < 256; ++c) { if (c != '%') { - std::string just_char(1, implicit_cast(c)); + std::string just_char(1, static_cast(c)); EXPECT_EQ(just_char, UrlUtilities::Unescape(just_char)); } } diff --git a/net/tools/quic/quic_client_session_test.cc b/net/tools/quic/quic_client_session_test.cc index c2b0d81859b23f..f9d761ee08e986 100644 --- a/net/tools/quic/quic_client_session_test.cc +++ b/net/tools/quic/quic_client_session_test.cc @@ -130,7 +130,7 @@ TEST_P(ToolsQuicClientSessionTest, InvalidPacketReceived) { IPEndPoint client_address(TestPeerIPAddress(), kTestPort); EXPECT_CALL(*connection_, ProcessUdpPacket(server_address, client_address, _)) - .WillRepeatedly(Invoke(implicit_cast(connection_), + .WillRepeatedly(Invoke(static_cast(connection_), &MockConnection::ReallyProcessUdpPacket)); EXPECT_CALL(*connection_, OnCanWrite()).Times(AnyNumber()); EXPECT_CALL(*connection_, OnError(_)).Times(1); @@ -167,7 +167,7 @@ TEST_P(ToolsQuicClientSessionTest, InvalidFramedPacketReceived) { IPEndPoint client_address(TestPeerIPAddress(), kTestPort); EXPECT_CALL(*connection_, ProcessUdpPacket(server_address, client_address, _)) - .WillRepeatedly(Invoke(implicit_cast(connection_), + .WillRepeatedly(Invoke(static_cast(connection_), &MockConnection::ReallyProcessUdpPacket)); EXPECT_CALL(*connection_, OnError(_)).Times(1); diff --git a/ui/base/page_transition_types.cc b/ui/base/page_transition_types.cc index 0bd86f613e3a26..62c4e5aaba2777 100644 --- a/ui/base/page_transition_types.cc +++ b/ui/base/page_transition_types.cc @@ -11,10 +11,9 @@ namespace ui { bool PageTransitionCoreTypeIs(PageTransition lhs, PageTransition rhs) { // Expect the rhs to be a compile time constant without qualifiers. - DCHECK(PageTransitionGetQualifier(rhs) == 0 && - PageTransitionIsValidType(rhs)); - return implicit_cast(PageTransitionStripQualifier(lhs)) == - implicit_cast(PageTransitionStripQualifier(rhs)); + DCHECK_EQ(PageTransitionGetQualifier(rhs), 0); + DCHECK(PageTransitionIsValidType(rhs)); + return PageTransitionStripQualifier(lhs) == PageTransitionStripQualifier(rhs); } PageTransition PageTransitionStripQualifier(PageTransition type) { diff --git a/ui/views/style/mac/dialog_button_border_mac_unittest.cc b/ui/views/style/mac/dialog_button_border_mac_unittest.cc index 43747887a2c19b..3b8b30e883b7f4 100644 --- a/ui/views/style/mac/dialog_button_border_mac_unittest.cc +++ b/ui/views/style/mac/dialog_button_border_mac_unittest.cc @@ -63,7 +63,7 @@ SkColor TestPaint(View* view) { bitmap.allocN32Pixels(1, 1); EXPECT_TRUE(sk_canvas->readPixels(&bitmap, center.x(), center.y())); initial_pixel = bitmap.getColor(0, 0); - EXPECT_EQ(implicit_cast(SK_ColorTRANSPARENT), initial_pixel); + EXPECT_EQ(static_cast(SK_ColorTRANSPARENT), initial_pixel); view->Paint(ui::CanvasPainter(&canvas, 1.f).context()); @@ -83,7 +83,7 @@ void TestPaintAllStates(CustomButton* button, bool verify) { button->SetState(state); SkColor color = TestPaint(button); if (verify) - EXPECT_NE(implicit_cast(SK_ColorTRANSPARENT), color); + EXPECT_NE(static_cast(SK_ColorTRANSPARENT), color); } }