From 0affe616899ec552ffb63a663bdc12abb80a815e Mon Sep 17 00:00:00 2001 From: Daniel Cheng Date: Mon, 28 Feb 2022 20:57:19 -0800 Subject: [PATCH] Migrate base::{size,empty,data} to STL equivalents in crashpad. Bug: chromium:1299695 Change-Id: I95187a425b08c96430c659f843c379d506972f0f Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3496462 Reviewed-by: Mark Mentovai Commit-Queue: Mark Mentovai --- client/crash_report_database_mac.mm | 6 +- client/crashpad_client_ios.cc | 8 +- .../in_process_intermediate_dump_handler.cc | 7 +- ..._process_intermediate_dump_handler_test.cc | 5 +- client/simulate_crash_mac.cc | 7 +- client/simulate_crash_mac_test.cc | 9 ++- handler/mac/file_limit_annotation.cc | 4 +- handler/win/crashy_test_program.cc | 6 +- handler/win/hanging_program.cc | 5 +- minidump/minidump_annotation_writer_test.cc | 4 +- minidump/minidump_byte_array_writer_test.cc | 6 +- minidump/minidump_exception_writer_test.cc | 4 +- minidump/minidump_file_writer_test.cc | 4 +- minidump/minidump_memory_writer_test.cc | 8 +- minidump/minidump_misc_info_writer.cc | 10 +-- minidump/minidump_misc_info_writer_test.cc | 52 ++++++------- ...nidump_module_crashpad_info_writer_test.cc | 8 +- minidump/minidump_module_writer_test.cc | 12 +-- minidump/minidump_rva_list_writer_test.cc | 6 +- minidump/minidump_string_writer_test.cc | 15 ++-- minidump/minidump_system_info_writer.cc | 5 +- minidump/minidump_thread_id_map_test.cc | 7 +- minidump/minidump_thread_writer_test.cc | 12 +-- minidump/minidump_writable.cc | 5 +- minidump/test/minidump_context_test_util.cc | 73 +++++++++---------- snapshot/capture_memory.cc | 8 +- snapshot/cpu_context.cc | 7 +- snapshot/cpu_context_test.cc | 23 +++--- .../memory_map_region_snapshot_fuchsia.cc | 5 +- .../fuchsia/process_reader_fuchsia_test.cc | 5 +- .../fuchsia/process_snapshot_fuchsia_test.cc | 13 ++-- .../linux/exception_snapshot_linux_test.cc | 13 ++-- snapshot/linux/process_reader_linux_test.cc | 4 +- snapshot/mac/mach_o_image_reader.cc | 7 +- .../mac/mach_o_image_segment_reader_test.cc | 9 ++- snapshot/mac/process_reader_mac_test.cc | 8 +- snapshot/mac/process_types.cc | 4 +- snapshot/mac/process_types/custom.cc | 9 +-- snapshot/mac/process_types_test.cc | 8 +- .../minidump/minidump_context_converter.cc | 19 ++--- .../process_snapshot_minidump_test.cc | 24 +++--- snapshot/posix/timezone.cc | 6 +- snapshot/posix/timezone_test.cc | 4 +- .../process_snapshot_sanitized_test.cc | 5 +- .../sanitization_information_test.cc | 5 +- snapshot/test/test_cpu_context.cc | 32 ++++---- snapshot/win/cpu_context_win_test.cc | 9 ++- .../crashpad_snapshot_test_image_reader.cc | 9 ++- snapshot/win/pe_image_annotations_reader.cc | 6 +- snapshot/win/pe_image_reader.cc | 4 +- snapshot/win/process_reader_win_test.cc | 7 +- snapshot/win/process_snapshot_win.cc | 8 +- test/hex_string.h | 4 +- test/hex_string_test.cc | 5 +- tools/crashpad_database_util.cc | 10 +-- util/file/delimited_file_reader.cc | 4 +- util/file/delimited_file_reader_test.cc | 8 +- util/file/file_io_test.cc | 4 +- util/linux/proc_stat_reader.cc | 5 +- util/linux/proc_task_reader.cc | 5 +- util/linux/ptrace_client.cc | 4 +- util/mac/checked_mach_address_range_test.cc | 8 +- util/mac/launchd_test.mm | 10 +-- util/mach/child_port_handshake.cc | 6 +- util/mach/child_port_server.cc | 5 +- .../composite_mach_message_server_test.cc | 15 ++-- util/mach/exc_client_variants_test.cc | 11 +-- util/mach/exc_server_variants.cc | 8 +- util/mach/exc_server_variants_test.cc | 41 ++++++----- util/mach/exception_behaviors_test.cc | 5 +- util/mach/exception_types_test.cc | 9 ++- util/mach/mach_message_server_test.cc | 4 +- util/mach/notify_server.cc | 5 +- util/mach/symbolic_constants_mach.cc | 28 +++---- util/mach/symbolic_constants_mach_test.cc | 50 ++++++------- util/misc/arraysize.h | 6 +- util/misc/capture_context_test_util_win.cc | 11 +-- util/misc/clock_test.cc | 4 +- util/misc/paths_win.cc | 11 ++- util/misc/random_string_test.cc | 6 +- util/misc/uuid_test.cc | 8 +- util/net/http_transport_socket.cc | 8 +- util/net/http_transport_win.cc | 5 +- util/numeric/checked_address_range_test.cc | 8 +- util/numeric/checked_range_test.cc | 12 +-- util/posix/close_multiple.cc | 4 +- util/posix/process_info_mac.cc | 11 +-- util/posix/scoped_mmap_test.cc | 17 +++-- util/posix/signals.cc | 13 ++-- util/posix/signals_test.cc | 4 +- util/posix/symbolic_constants_posix.cc | 11 +-- util/posix/symbolic_constants_posix_test.cc | 15 ++-- util/process/process_memory_range_test.cc | 14 ++-- util/stdlib/string_number_conversion_test.cc | 6 +- util/stdlib/strlcpy_test.cc | 14 ++-- util/stdlib/thread_safe_vector_test.cc | 11 +-- util/stream/base94_output_stream_test.cc | 4 +- util/stream/zlib_output_stream.cc | 9 ++- util/stream/zlib_output_stream_test.cc | 4 +- util/synchronization/semaphore_test.cc | 7 +- util/thread/thread_log_messages_test.cc | 9 ++- util/win/command_line_test.cc | 17 +++-- util/win/exception_handler_server.cc | 6 +- util/win/ntstatus_logging.cc | 4 +- util/win/registration_protocol_win.cc | 10 +-- util/win/safe_terminate_process_test.cc | 6 +- 106 files changed, 556 insertions(+), 522 deletions(-) diff --git a/client/crash_report_database_mac.mm b/client/crash_report_database_mac.mm index 52319bef..c24b4a5d 100644 --- a/client/crash_report_database_mac.mm +++ b/client/crash_report_database_mac.mm @@ -14,9 +14,9 @@ #include "client/crash_report_database.h" +#import #include #include -#import #include #include #include @@ -25,9 +25,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/mac/scoped_nsautorelease_pool.h" #include "base/posix/eintr_wrapper.h" @@ -282,7 +282,7 @@ bool CrashReportDatabaseMac::Initialize(bool may_create) { } // Create the three processing directories for the database. - for (size_t i = 0; i < base::size(kReportDirectories); ++i) { + for (size_t i = 0; i < std::size(kReportDirectories); ++i) { if (!CreateOrEnsureDirectoryExists(base_dir_.Append(kReportDirectories[i]))) return false; } diff --git a/client/crashpad_client_ios.cc b/client/crashpad_client_ios.cc index 7474ed8b..ae0ddf1d 100644 --- a/client/crashpad_client_ios.cc +++ b/client/crashpad_client_ios.cc @@ -17,8 +17,8 @@ #include #include +#include -#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/mac/mach_logging.h" #include "base/mac/scoped_mach_port.h" @@ -40,7 +40,7 @@ bool IsBeingDebugged() { kinfo_proc kern_proc_info; int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()}; size_t len = sizeof(kern_proc_info); - if (sysctl(mib, base::size(mib), &kern_proc_info, &len, nullptr, 0) == 0) + if (sysctl(mib, std::size(mib), &kern_proc_info, &len, nullptr, 0) == 0) return kern_proc_info.kp_proc.p_flag & P_TRACED; return false; } @@ -111,7 +111,7 @@ class CrashHandler : public Thread, mach_thread_self(), kSimulatedException, code, - base::size(code), + std::size(code), MACHINE_THREAD_STATE, reinterpret_cast(context), MACHINE_THREAD_STATE_COUNT); @@ -304,7 +304,7 @@ class CrashHandler : public Thread, mach_thread_self(), kMachExceptionFromNSException, code, - base::size(code), + std::size(code), MACHINE_THREAD_STATE, reinterpret_cast(context), MACHINE_THREAD_STATE_COUNT); diff --git a/client/ios_handler/in_process_intermediate_dump_handler.cc b/client/ios_handler/in_process_intermediate_dump_handler.cc index 12dcf2b4..e4d6223b 100644 --- a/client/ios_handler/in_process_intermediate_dump_handler.cc +++ b/client/ios_handler/in_process_intermediate_dump_handler.cc @@ -21,7 +21,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "build/build_config.h" #include "snapshot/snapshot_constants.h" #include "util/ios/ios_intermediate_dump_writer.h" @@ -428,7 +429,7 @@ void CaptureMemoryPointedToByThreadState(IOSIntermediateDumpWriter* writer, MaybeCaptureMemoryAround(writer, thread_state.__rip); #elif defined(ARCH_CPU_ARM_FAMILY) MaybeCaptureMemoryAround(writer, thread_state.__pc); - for (size_t i = 0; i < base::size(thread_state.__x); ++i) { + for (size_t i = 0; i < std::size(thread_state.__x); ++i) { MaybeCaptureMemoryAround(writer, thread_state.__x[i]); } #endif @@ -598,7 +599,7 @@ void InProcessIntermediateDumpHandler::WriteProcessInfo( kinfo_proc kern_proc_info; int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()}; size_t len = sizeof(kern_proc_info); - if (sysctl(mib, base::size(mib), &kern_proc_info, &len, nullptr, 0) == 0) { + if (sysctl(mib, std::size(mib), &kern_proc_info, &len, nullptr, 0) == 0) { WriteProperty( writer, IntermediateDumpKey::kPID, &kern_proc_info.kp_proc.p_pid); WriteProperty(writer, diff --git a/client/ios_handler/in_process_intermediate_dump_handler_test.cc b/client/ios_handler/in_process_intermediate_dump_handler_test.cc index b79f93f6..54af2c7f 100644 --- a/client/ios_handler/in_process_intermediate_dump_handler_test.cc +++ b/client/ios_handler/in_process_intermediate_dump_handler_test.cc @@ -16,7 +16,8 @@ #include -#include "base/cxx17_backports.h" +#include + #include "base/files/file_path.h" #include "build/build_config.h" #include "client/annotation.h" @@ -74,7 +75,7 @@ class InProcessIntermediateDumpHandlerTest : public testing::Test { mach_thread_self(), kSimulatedException, code, - base::size(code), + std::size(code), MACHINE_THREAD_STATE, reinterpret_cast(&cpu_context), MACHINE_THREAD_STATE_COUNT); diff --git a/client/simulate_crash_mac.cc b/client/simulate_crash_mac.cc index 48d81a0d..86f4043d 100644 --- a/client/simulate_crash_mac.cc +++ b/client/simulate_crash_mac.cc @@ -17,8 +17,9 @@ #include #include +#include + #include "base/check_op.h" -#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/mac/mach_logging.h" #include "base/mac/scoped_mach_port.h" @@ -207,7 +208,7 @@ void SimulateCrash(const NativeCPUContext& cpu_context) { base::mac::ScopedMachSendRight thread(mach_thread_self()); exception_type_t exception = kMachExceptionSimulated; mach_exception_data_type_t codes[] = {0, 0}; - mach_msg_type_number_t code_count = base::size(codes); + mach_msg_type_number_t code_count = std::size(codes); // Look up the handler for EXC_CRASH exceptions in the same way that the // kernel would: try a thread handler, then a task handler, and finally a host @@ -229,7 +230,7 @@ void SimulateCrash(const NativeCPUContext& cpu_context) { bool success = false; for (size_t target_type_index = 0; - !success && target_type_index < base::size(kTargetTypes); + !success && target_type_index < std::size(kTargetTypes); ++target_type_index) { ExceptionPorts::ExceptionHandlerVector handlers; ExceptionPorts exception_ports(kTargetTypes[target_type_index], diff --git a/client/simulate_crash_mac_test.cc b/client/simulate_crash_mac_test.cc index f22b2a69..ccd0267c 100644 --- a/client/simulate_crash_mac_test.cc +++ b/client/simulate_crash_mac_test.cc @@ -18,7 +18,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/strings/stringprintf.h" #include "build/build_config.h" #include "gtest/gtest.h" @@ -370,13 +371,13 @@ TEST(SimulateCrash, SimulateCrash) { #endif }; - for (size_t target_index = 0; target_index < base::size(kTargets); + for (size_t target_index = 0; target_index < std::size(kTargets); ++target_index) { TestSimulateCrashMac::ExceptionPortsTarget target = kTargets[target_index]; SCOPED_TRACE(base::StringPrintf( "target_index %zu, target %d", target_index, target)); - for (size_t behavior_index = 0; behavior_index < base::size(kBehaviors); + for (size_t behavior_index = 0; behavior_index < std::size(kBehaviors); ++behavior_index) { exception_behavior_t behavior = kBehaviors[behavior_index]; SCOPED_TRACE(base::StringPrintf( @@ -390,7 +391,7 @@ TEST(SimulateCrash, SimulateCrash) { target, behavior, THREAD_STATE_NONE); test_simulate_crash_mac.Run(); } else { - for (size_t flavor_index = 0; flavor_index < base::size(kFlavors); + for (size_t flavor_index = 0; flavor_index < std::size(kFlavors); ++flavor_index) { thread_state_flavor_t flavor = kFlavors[flavor_index]; SCOPED_TRACE(base::StringPrintf( diff --git a/handler/mac/file_limit_annotation.cc b/handler/mac/file_limit_annotation.cc index 0813b950..06334534 100644 --- a/handler/mac/file_limit_annotation.cc +++ b/handler/mac/file_limit_annotation.cc @@ -21,9 +21,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/strings/stringprintf.h" #include "client/crashpad_info.h" @@ -108,7 +108,7 @@ void RecordFileLimitAnnotation() { int mib[] = {CTL_KERN, KERN_MAXFILES}; size = sizeof(value); std::string max_files = FormatFromSysctl( - sysctl(mib, base::size(mib), &value, &size, nullptr, 0), &value, &size); + sysctl(mib, std::size(mib), &value, &size, nullptr, 0), &value, &size); std::string open_files = CountOpenFileDescriptors(); diff --git a/handler/win/crashy_test_program.cc b/handler/win/crashy_test_program.cc index 4fb25547..f5cf0487 100644 --- a/handler/win/crashy_test_program.cc +++ b/handler/win/crashy_test_program.cc @@ -19,12 +19,12 @@ #include #include +#include #include #include #include #include -#include "base/cxx17_backports.h" #include "base/files/file_path.h" #include "base/logging.h" #include "build/build_config.h" @@ -83,11 +83,11 @@ void AllocateMemoryOfVariousProtections() { // All of these allocations are leaked, we want to view them in windbg via // !vprot. void* reserve = VirtualAlloc( - nullptr, base::size(kPageTypes) * kPageSize, MEM_RESERVE, PAGE_READWRITE); + nullptr, std::size(kPageTypes) * kPageSize, MEM_RESERVE, PAGE_READWRITE); PCHECK(reserve) << "VirtualAlloc MEM_RESERVE"; uintptr_t reserve_as_int = reinterpret_cast(reserve); - for (size_t i = 0; i < base::size(kPageTypes); ++i) { + for (size_t i = 0; i < std::size(kPageTypes); ++i) { void* result = VirtualAlloc(reinterpret_cast(reserve_as_int + (kPageSize * i)), kPageSize, diff --git a/handler/win/hanging_program.cc b/handler/win/hanging_program.cc index b65d46db..aff3ae28 100644 --- a/handler/win/hanging_program.cc +++ b/handler/win/hanging_program.cc @@ -15,7 +15,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/debug/alias.h" #include "base/logging.h" #include "base/notreached.h" @@ -125,7 +126,7 @@ int wmain(int argc, wchar_t* argv[]) { // This is not expected to return. DWORD count = WaitForMultipleObjects( - static_cast(base::size(threads)), threads, true, INFINITE); + static_cast(std::size(threads)), threads, true, INFINITE); if (count == WAIT_FAILED) { PLOG(ERROR) << "WaitForMultipleObjects"; } else { diff --git a/minidump/minidump_annotation_writer_test.cc b/minidump/minidump_annotation_writer_test.cc index c862f023..ff3c2a8e 100644 --- a/minidump/minidump_annotation_writer_test.cc +++ b/minidump/minidump_annotation_writer_test.cc @@ -14,9 +14,9 @@ #include "minidump/minidump_annotation_writer.h" +#include #include -#include "base/cxx17_backports.h" #include "gtest/gtest.h" #include "minidump/minidump_extensions.h" #include "minidump/test/minidump_byte_array_writer_test_util.h" @@ -107,7 +107,7 @@ TEST(MinidumpAnnotationWriter, ThreeItems) { MinidumpAnnotationListWriter list_writer; - for (size_t i = 0; i < base::size(kNames); ++i) { + for (size_t i = 0; i < std::size(kNames); ++i) { auto annotation = std::make_unique(); annotation->InitializeWithData(kNames[i], kTypes[i], kValues[i]); list_writer.AddObject(std::move(annotation)); diff --git a/minidump/minidump_byte_array_writer_test.cc b/minidump/minidump_byte_array_writer_test.cc index 526e38ba..8742ea44 100644 --- a/minidump/minidump_byte_array_writer_test.cc +++ b/minidump/minidump_byte_array_writer_test.cc @@ -14,9 +14,9 @@ #include "minidump/minidump_byte_array_writer.h" +#include #include -#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" @@ -35,7 +35,7 @@ TEST(MinidumpByteArrayWriter, Write) { {}, }; - for (size_t i = 0; i < base::size(kTests); ++i) { + for (size_t i = 0; i < std::size(kTests); ++i) { SCOPED_TRACE(base::StringPrintf("index %" PRIuS, i)); StringFile string_file; @@ -67,7 +67,7 @@ TEST(MinidumpByteArrayWriter, SetData) { {}, }; - for (size_t i = 0; i < base::size(kTests); ++i) { + for (size_t i = 0; i < std::size(kTests); ++i) { SCOPED_TRACE(base::StringPrintf("index %" PRIuS, i)); crashpad::MinidumpByteArrayWriter writer; diff --git a/minidump/minidump_exception_writer_test.cc b/minidump/minidump_exception_writer_test.cc index 0243c175..e09232fe 100644 --- a/minidump/minidump_exception_writer_test.cc +++ b/minidump/minidump_exception_writer_test.cc @@ -14,10 +14,10 @@ #include "minidump/minidump_exception_writer.h" +#include #include #include -#include "base/cxx17_backports.h" #include "gtest/gtest.h" #include "minidump/minidump_context.h" #include "minidump/minidump_context_writer.h" @@ -86,7 +86,7 @@ void ExpectExceptionStream(const MINIDUMP_EXCEPTION_STREAM* expected, expected_exception.NumberParameters); EXPECT_EQ(observed->ExceptionRecord.__unusedAlignment, 0u); for (size_t index = 0; - index < base::size(observed_exception.ExceptionInformation); + index < std::size(observed_exception.ExceptionInformation); ++index) { EXPECT_EQ(observed_exception.ExceptionInformation[index], expected_exception.ExceptionInformation[index]); diff --git a/minidump/minidump_file_writer_test.cc b/minidump/minidump_file_writer_test.cc index e4be0b6d..75c8525c 100644 --- a/minidump/minidump_file_writer_test.cc +++ b/minidump/minidump_file_writer_test.cc @@ -17,10 +17,10 @@ #include #include +#include #include #include -#include "base/cxx17_backports.h" #include "build/build_config.h" #include "gtest/gtest.h" #include "minidump/minidump_stream_writer.h" @@ -156,7 +156,7 @@ TEST(MinidumpFileWriter, AddUserExtensionStream) { minidump_file.SetTimestamp(kTimestamp); static constexpr uint8_t kStreamData[] = "Hello World!"; - constexpr size_t kStreamSize = base::size(kStreamData); + constexpr size_t kStreamSize = std::size(kStreamData); constexpr MinidumpStreamType kStreamType = static_cast(0x4d); diff --git a/minidump/minidump_memory_writer_test.cc b/minidump/minidump_memory_writer_test.cc index 02a352fc..0ca0652d 100644 --- a/minidump/minidump_memory_writer_test.cc +++ b/minidump/minidump_memory_writer_test.cc @@ -14,9 +14,9 @@ #include "minidump/minidump_memory_writer.h" +#include #include -#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" @@ -342,7 +342,7 @@ TEST(MinidumpMemoryWriter, ExtraMemory) { TEST(MinidumpMemoryWriter, AddFromSnapshot) { MINIDUMP_MEMORY_DESCRIPTOR expect_memory_descriptors[3] = {}; - uint8_t values[base::size(expect_memory_descriptors)] = {}; + uint8_t values[std::size(expect_memory_descriptors)] = {}; expect_memory_descriptors[0].StartOfMemoryRange = 0; expect_memory_descriptors[0].Memory.DataSize = 0x1000; @@ -358,7 +358,7 @@ TEST(MinidumpMemoryWriter, AddFromSnapshot) { std::vector> memory_snapshots_owner; std::vector memory_snapshots; - for (size_t index = 0; index < base::size(expect_memory_descriptors); + for (size_t index = 0; index < std::size(expect_memory_descriptors); ++index) { memory_snapshots_owner.push_back(std::make_unique()); TestMemorySnapshot* memory_snapshot = memory_snapshots_owner.back().get(); @@ -397,7 +397,7 @@ TEST(MinidumpMemoryWriter, AddFromSnapshot) { TEST(MinidumpMemoryWriter, CoalesceExplicitMultiple) { MINIDUMP_MEMORY_DESCRIPTOR expect_memory_descriptors[4] = {}; - uint8_t values[base::size(expect_memory_descriptors)] = {}; + uint8_t values[std::size(expect_memory_descriptors)] = {}; expect_memory_descriptors[0].StartOfMemoryRange = 0; expect_memory_descriptors[0].Memory.DataSize = 1000; diff --git a/minidump/minidump_misc_info_writer.cc b/minidump/minidump_misc_info_writer.cc index 12c65b1a..78847c11 100644 --- a/minidump/minidump_misc_info_writer.cc +++ b/minidump/minidump_misc_info_writer.cc @@ -14,10 +14,10 @@ #include "minidump/minidump_misc_info_writer.h" +#include #include #include "base/check_op.h" -#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/numerics/safe_conversions.h" #include "base/strings/stringprintf.h" @@ -311,7 +311,7 @@ void MinidumpMiscInfoWriter::SetTimeZone(uint32_t time_zone_id, internal::MinidumpWriterUtil::AssignUTF8ToUTF16( AsU16CStr(misc_info_.TimeZone.StandardName), - base::size(misc_info_.TimeZone.StandardName), + std::size(misc_info_.TimeZone.StandardName), standard_name); misc_info_.TimeZone.StandardDate = standard_date; @@ -319,7 +319,7 @@ void MinidumpMiscInfoWriter::SetTimeZone(uint32_t time_zone_id, internal::MinidumpWriterUtil::AssignUTF8ToUTF16( AsU16CStr(misc_info_.TimeZone.DaylightName), - base::size(misc_info_.TimeZone.DaylightName), + std::size(misc_info_.TimeZone.DaylightName), daylight_name); misc_info_.TimeZone.DaylightDate = daylight_date; @@ -337,11 +337,11 @@ void MinidumpMiscInfoWriter::SetBuildString( internal::MinidumpWriterUtil::AssignUTF8ToUTF16( AsU16CStr(misc_info_.BuildString), - base::size(misc_info_.BuildString), + std::size(misc_info_.BuildString), build_string); internal::MinidumpWriterUtil::AssignUTF8ToUTF16( AsU16CStr(misc_info_.DbgBldStr), - base::size(misc_info_.DbgBldStr), + std::size(misc_info_.DbgBldStr), debug_build_string); } diff --git a/minidump/minidump_misc_info_writer_test.cc b/minidump/minidump_misc_info_writer_test.cc index f74d0bd5..c9834141 100644 --- a/minidump/minidump_misc_info_writer_test.cc +++ b/minidump/minidump_misc_info_writer_test.cc @@ -16,10 +16,10 @@ #include +#include #include #include -#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" @@ -125,7 +125,7 @@ void ExpectMiscInfoEqual( SCOPED_TRACE("Standard"); ExpectNULPaddedString16Equal(AsU16CStr(expected->TimeZone.StandardName), AsU16CStr(observed->TimeZone.StandardName), - base::size(expected->TimeZone.StandardName)); + std::size(expected->TimeZone.StandardName)); ExpectSystemTimeEqual(&expected->TimeZone.StandardDate, &observed->TimeZone.StandardDate); EXPECT_EQ(observed->TimeZone.StandardBias, expected->TimeZone.StandardBias); @@ -134,7 +134,7 @@ void ExpectMiscInfoEqual( SCOPED_TRACE("Daylight"); ExpectNULPaddedString16Equal(AsU16CStr(expected->TimeZone.DaylightName), AsU16CStr(observed->TimeZone.DaylightName), - base::size(expected->TimeZone.DaylightName)); + std::size(expected->TimeZone.DaylightName)); ExpectSystemTimeEqual(&expected->TimeZone.DaylightDate, &observed->TimeZone.DaylightDate); EXPECT_EQ(observed->TimeZone.DaylightBias, expected->TimeZone.DaylightBias); @@ -152,13 +152,13 @@ void ExpectMiscInfoEqual( SCOPED_TRACE("BuildString"); ExpectNULPaddedString16Equal(AsU16CStr(expected->BuildString), AsU16CStr(observed->BuildString), - base::size(expected->BuildString)); + std::size(expected->BuildString)); } { SCOPED_TRACE("DbgBldStr"); ExpectNULPaddedString16Equal(AsU16CStr(expected->DbgBldStr), AsU16CStr(observed->DbgBldStr), - base::size(expected->DbgBldStr)); + std::size(expected->DbgBldStr)); } } @@ -181,7 +181,7 @@ void ExpectMiscInfoEqual( EXPECT_EQ(observed_misc_info.XStateData.EnabledFeatures, expected_misc_info.XStateData.EnabledFeatures); for (size_t feature_index = 0; - feature_index < base::size(observed_misc_info.XStateData.Features); + feature_index < std::size(observed_misc_info.XStateData.Features); ++feature_index) { SCOPED_TRACE(base::StringPrintf("feature_index %" PRIuS, feature_index)); EXPECT_EQ(observed_misc_info.XStateData.Features[feature_index].Offset, @@ -408,7 +408,7 @@ TEST(MinidumpMiscInfoWriter, TimeZone) { base::UTF8ToUTF16(Crbug1189439Cast(kStandardName)); c16lcpy(AsU16CStr(expected.TimeZone.StandardName), standard_name_utf16.c_str(), - base::size(expected.TimeZone.StandardName)); + std::size(expected.TimeZone.StandardName)); memcpy(&expected.TimeZone.StandardDate, &kStandardDate, sizeof(expected.TimeZone.StandardDate)); @@ -417,7 +417,7 @@ TEST(MinidumpMiscInfoWriter, TimeZone) { base::UTF8ToUTF16(Crbug1189439Cast(kDaylightName)); c16lcpy(AsU16CStr(expected.TimeZone.DaylightName), daylight_name_utf16.c_str(), - base::size(expected.TimeZone.DaylightName)); + std::size(expected.TimeZone.DaylightName)); memcpy(&expected.TimeZone.DaylightDate, &kDaylightDate, sizeof(expected.TimeZone.DaylightDate)); @@ -436,9 +436,9 @@ TEST(MinidumpMiscInfoWriter, TimeZoneStringsOverflow) { constexpr uint32_t kTimeZoneId = 2; constexpr int32_t kBias = 300; [[maybe_unused]] MINIDUMP_MISC_INFO_N tmp; - std::string standard_name(base::size(tmp.TimeZone.StandardName) + 1, 's'); + std::string standard_name(std::size(tmp.TimeZone.StandardName) + 1, 's'); constexpr int32_t kStandardBias = 0; - std::string daylight_name(base::size(tmp.TimeZone.DaylightName), 'd'); + std::string daylight_name(std::size(tmp.TimeZone.DaylightName), 'd'); constexpr int32_t kDaylightBias = -60; // Test using kSystemTimeZero, because not all platforms will be able to @@ -469,7 +469,7 @@ TEST(MinidumpMiscInfoWriter, TimeZoneStringsOverflow) { std::u16string standard_name_utf16 = base::UTF8ToUTF16(standard_name); c16lcpy(AsU16CStr(expected.TimeZone.StandardName), standard_name_utf16.c_str(), - base::size(expected.TimeZone.StandardName)); + std::size(expected.TimeZone.StandardName)); memcpy(&expected.TimeZone.StandardDate, &kSystemTimeZero, sizeof(expected.TimeZone.StandardDate)); @@ -477,7 +477,7 @@ TEST(MinidumpMiscInfoWriter, TimeZoneStringsOverflow) { std::u16string daylight_name_utf16 = base::UTF8ToUTF16(daylight_name); c16lcpy(AsU16CStr(expected.TimeZone.DaylightName), daylight_name_utf16.c_str(), - base::size(expected.TimeZone.DaylightName)); + std::size(expected.TimeZone.DaylightName)); memcpy(&expected.TimeZone.DaylightDate, &kSystemTimeZero, sizeof(expected.TimeZone.DaylightDate)); @@ -509,12 +509,12 @@ TEST(MinidumpMiscInfoWriter, BuildStrings) { base::UTF8ToUTF16(Crbug1189439Cast(kBuildString)); c16lcpy(AsU16CStr(expected.BuildString), build_string_utf16.c_str(), - base::size(expected.BuildString)); + std::size(expected.BuildString)); std::u16string debug_build_string_utf16 = base::UTF8ToUTF16(Crbug1189439Cast(kDebugBuildString)); c16lcpy(AsU16CStr(expected.DbgBldStr), debug_build_string_utf16.c_str(), - base::size(expected.DbgBldStr)); + std::size(expected.DbgBldStr)); ExpectMiscInfoEqual(&expected, observed); } @@ -527,8 +527,8 @@ TEST(MinidumpMiscInfoWriter, BuildStringsOverflow) { auto misc_info_writer = std::make_unique(); [[maybe_unused]] MINIDUMP_MISC_INFO_N tmp; - std::string build_string(base::size(tmp.BuildString) + 1, 'B'); - std::string debug_build_string(base::size(tmp.DbgBldStr), 'D'); + std::string build_string(std::size(tmp.BuildString) + 1, 'B'); + std::string debug_build_string(std::size(tmp.DbgBldStr), 'D'); misc_info_writer->SetBuildString(build_string, debug_build_string); @@ -545,12 +545,12 @@ TEST(MinidumpMiscInfoWriter, BuildStringsOverflow) { std::u16string build_string_utf16 = base::UTF8ToUTF16(build_string); c16lcpy(AsU16CStr(expected.BuildString), build_string_utf16.c_str(), - base::size(expected.BuildString)); + std::size(expected.BuildString)); std::u16string debug_build_string_utf16 = base::UTF8ToUTF16(debug_build_string); c16lcpy(AsU16CStr(expected.DbgBldStr), debug_build_string_utf16.c_str(), - base::size(expected.DbgBldStr)); + std::size(expected.DbgBldStr)); ExpectMiscInfoEqual(&expected, observed); } @@ -691,7 +691,7 @@ TEST(MinidumpMiscInfoWriter, Everything) { base::UTF8ToUTF16(Crbug1189439Cast(kStandardName)); c16lcpy(AsU16CStr(expected.TimeZone.StandardName), standard_name_utf16.c_str(), - base::size(expected.TimeZone.StandardName)); + std::size(expected.TimeZone.StandardName)); memcpy(&expected.TimeZone.StandardDate, &kSystemTimeZero, sizeof(expected.TimeZone.StandardDate)); @@ -700,7 +700,7 @@ TEST(MinidumpMiscInfoWriter, Everything) { base::UTF8ToUTF16(Crbug1189439Cast(kDaylightName)); c16lcpy(AsU16CStr(expected.TimeZone.DaylightName), daylight_name_utf16.c_str(), - base::size(expected.TimeZone.DaylightName)); + std::size(expected.TimeZone.DaylightName)); memcpy(&expected.TimeZone.DaylightDate, &kSystemTimeZero, sizeof(expected.TimeZone.DaylightDate)); @@ -709,12 +709,12 @@ TEST(MinidumpMiscInfoWriter, Everything) { base::UTF8ToUTF16(Crbug1189439Cast(kBuildString)); c16lcpy(AsU16CStr(expected.BuildString), build_string_utf16.c_str(), - base::size(expected.BuildString)); + std::size(expected.BuildString)); std::u16string debug_build_string_utf16 = base::UTF8ToUTF16(Crbug1189439Cast(kDebugBuildString)); c16lcpy(AsU16CStr(expected.DbgBldStr), debug_build_string_utf16.c_str(), - base::size(expected.DbgBldStr)); + std::size(expected.DbgBldStr)); ExpectMiscInfoEqual(&expected, observed); } @@ -758,18 +758,18 @@ TEST(MinidumpMiscInfoWriter, InitializeFromSnapshot) { expect_misc_info.TimeZone.Bias = 300; c16lcpy(AsU16CStr(expect_misc_info.TimeZone.StandardName), standard_time_name_utf16.c_str(), - base::size(expect_misc_info.TimeZone.StandardName)); + std::size(expect_misc_info.TimeZone.StandardName)); expect_misc_info.TimeZone.StandardBias = 0; c16lcpy(AsU16CStr(expect_misc_info.TimeZone.DaylightName), daylight_time_name_utf16.c_str(), - base::size(expect_misc_info.TimeZone.DaylightName)); + std::size(expect_misc_info.TimeZone.DaylightName)); expect_misc_info.TimeZone.DaylightBias = -60; c16lcpy(AsU16CStr(expect_misc_info.BuildString), build_string_utf16.c_str(), - base::size(expect_misc_info.BuildString)); + std::size(expect_misc_info.BuildString)); c16lcpy(AsU16CStr(expect_misc_info.DbgBldStr), debug_build_string_utf16.c_str(), - base::size(expect_misc_info.DbgBldStr)); + std::size(expect_misc_info.DbgBldStr)); const timeval kStartTime = { static_cast(expect_misc_info.ProcessCreateTime), 0}; diff --git a/minidump/minidump_module_crashpad_info_writer_test.cc b/minidump/minidump_module_crashpad_info_writer_test.cc index 613314b3..ba5c5f22 100644 --- a/minidump/minidump_module_crashpad_info_writer_test.cc +++ b/minidump/minidump_module_crashpad_info_writer_test.cc @@ -17,9 +17,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "gtest/gtest.h" #include "minidump/minidump_annotation_writer.h" #include "minidump/minidump_simple_string_dictionary_writer.h" @@ -155,9 +155,9 @@ TEST(MinidumpModuleCrashpadInfoWriter, FullModule) { sizeof(MinidumpSimpleStringDictionaryEntry) + sizeof(MinidumpAnnotationList) + 2 + // padding sizeof(MinidumpAnnotation) + sizeof(MinidumpUTF8String) + - base::size(kEntry) + 2 + // padding - sizeof(MinidumpUTF8String) + base::size(kKey) + - sizeof(MinidumpUTF8String) + base::size(kValue) + + std::size(kEntry) + 2 + // padding + sizeof(MinidumpUTF8String) + std::size(kKey) + + sizeof(MinidumpUTF8String) + std::size(kValue) + sizeof(MinidumpUTF8String) + annotation.name.size() + 1 + sizeof(MinidumpByteArray) + annotation.value.size()); diff --git a/minidump/minidump_module_writer_test.cc b/minidump/minidump_module_writer_test.cc index 131575fa..e189d77e 100644 --- a/minidump/minidump_module_writer_test.cc +++ b/minidump/minidump_module_writer_test.cc @@ -17,9 +17,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" @@ -793,10 +793,10 @@ void InitializeTestModuleSnapshotFromMinidumpModule( TEST(MinidumpModuleWriter, InitializeFromSnapshot) { MINIDUMP_MODULE expect_modules[3] = {}; - const char* module_paths[base::size(expect_modules)] = {}; - const char* module_pdbs[base::size(expect_modules)] = {}; - UUID uuids[base::size(expect_modules)] = {}; - uint32_t ages[base::size(expect_modules)] = {}; + const char* module_paths[std::size(expect_modules)] = {}; + const char* module_pdbs[std::size(expect_modules)] = {}; + UUID uuids[std::size(expect_modules)] = {}; + uint32_t ages[std::size(expect_modules)] = {}; expect_modules[0].BaseOfImage = 0x100101000; expect_modules[0].SizeOfImage = 0xf000; @@ -887,7 +887,7 @@ TEST(MinidumpModuleWriter, InitializeFromSnapshot) { std::vector> module_snapshots_owner; std::vector module_snapshots; - for (size_t index = 0; index < base::size(expect_modules); ++index) { + for (size_t index = 0; index < std::size(expect_modules); ++index) { module_snapshots_owner.push_back(std::make_unique()); TestModuleSnapshot* module_snapshot = module_snapshots_owner.back().get(); InitializeTestModuleSnapshotFromMinidumpModule(module_snapshot, diff --git a/minidump/minidump_rva_list_writer_test.cc b/minidump/minidump_rva_list_writer_test.cc index f99d9435..adfed112 100644 --- a/minidump/minidump_rva_list_writer_test.cc +++ b/minidump/minidump_rva_list_writer_test.cc @@ -14,9 +14,9 @@ #include "minidump/minidump_rva_list_writer.h" +#include #include -#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" @@ -89,10 +89,10 @@ TEST(MinidumpRVAListWriter, ThreeChildren) { ASSERT_TRUE(list_writer.WriteEverything(&string_file)); const MinidumpRVAList* list = - MinidumpRVAListAtStart(string_file.string(), base::size(kValues)); + MinidumpRVAListAtStart(string_file.string(), std::size(kValues)); ASSERT_TRUE(list); - for (size_t index = 0; index < base::size(kValues); ++index) { + for (size_t index = 0; index < std::size(kValues); ++index) { SCOPED_TRACE(base::StringPrintf("index %" PRIuS, index)); const uint32_t* child = MinidumpWritableAtRVA( diff --git a/minidump/minidump_string_writer_test.cc b/minidump/minidump_string_writer_test.cc index 9609ade1..f0cdb827 100644 --- a/minidump/minidump_string_writer_test.cc +++ b/minidump/minidump_string_writer_test.cc @@ -14,9 +14,9 @@ #include "minidump/minidump_string_writer.h" +#include #include -#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" @@ -66,16 +66,15 @@ TEST(MinidumpStringWriter, MinidumpUTF16StringWriter) { {4, "\360\220\204\202", 2, {0xd800, 0xdd02}}, // 𐄂 (non-BMP) }; - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { SCOPED_TRACE(base::StringPrintf( "index %" PRIuS ", input %s", index, kTestData[index].input_string)); // Make sure that the expected output string with its NUL terminator fits in // the space provided. - ASSERT_EQ( - kTestData[index] - .output_string[base::size(kTestData[index].output_string) - 1], - 0); + ASSERT_EQ(kTestData[index] + .output_string[std::size(kTestData[index].output_string) - 1], + 0); string_file.Reset(); crashpad::internal::MinidumpUTF16StringWriter string_writer; @@ -112,7 +111,7 @@ TEST(MinidumpStringWriter, ConvertInvalidUTF8ToUTF16) { "\303\0\251", // NUL in middle of valid sequence }; - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { SCOPED_TRACE(base::StringPrintf( "index %" PRIuS ", input %s", index, kTestData[index])); string_file.Reset(); @@ -173,7 +172,7 @@ TEST(MinidumpStringWriter, MinidumpUTF8StringWriter) { {4, "\360\220\204\202"}, // 𐄂 (non-BMP) }; - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { SCOPED_TRACE(base::StringPrintf( "index %" PRIuS ", input %s", index, kTestData[index].string)); diff --git a/minidump/minidump_system_info_writer.cc b/minidump/minidump_system_info_writer.cc index 13501010..bc9a5d65 100644 --- a/minidump/minidump_system_info_writer.cc +++ b/minidump/minidump_system_info_writer.cc @@ -16,8 +16,9 @@ #include +#include + #include "base/check_op.h" -#include "base/cxx17_backports.h" #include "base/notreached.h" #include "minidump/minidump_string_writer.h" #include "snapshot/system_snapshot.h" @@ -235,7 +236,7 @@ void MinidumpSystemInfoWriter::SetCPUX86VendorString( sizeof(registers) == sizeof(system_info_.Cpu.X86CpuInfo.VendorId), "VendorId sizes must be equal"); - for (size_t index = 0; index < base::size(registers); ++index) { + for (size_t index = 0; index < std::size(registers); ++index) { memcpy(®isters[index], &vendor[index * sizeof(*registers)], sizeof(*registers)); diff --git a/minidump/minidump_thread_id_map_test.cc b/minidump/minidump_thread_id_map_test.cc index e972aebc..0883d9a5 100644 --- a/minidump/minidump_thread_id_map_test.cc +++ b/minidump/minidump_thread_id_map_test.cc @@ -16,9 +16,9 @@ #include +#include #include -#include "base/cxx17_backports.h" #include "gtest/gtest.h" #include "snapshot/test/test_thread_snapshot.h" @@ -41,8 +41,7 @@ class MinidumpThreadIDMapTest : public testing::Test { // testing::Test: void SetUp() override { - for (size_t index = 0; index < base::size(test_thread_snapshots_); - ++index) { + for (size_t index = 0; index < std::size(test_thread_snapshots_); ++index) { thread_snapshots_.push_back(&test_thread_snapshots_[index]); } } @@ -63,7 +62,7 @@ class MinidumpThreadIDMapTest : public testing::Test { } void SetThreadID(size_t index, uint64_t thread_id) { - ASSERT_LT(index, base::size(test_thread_snapshots_)); + ASSERT_LT(index, std::size(test_thread_snapshots_)); test_thread_snapshots_[index].SetThreadID(thread_id); } diff --git a/minidump/minidump_thread_writer_test.cc b/minidump/minidump_thread_writer_test.cc index 924c5c11..9b0e064c 100644 --- a/minidump/minidump_thread_writer_test.cc +++ b/minidump/minidump_thread_writer_test.cc @@ -14,11 +14,11 @@ #include "minidump/minidump_thread_writer.h" +#include #include #include #include "base/compiler_specific.h" -#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" @@ -531,10 +531,10 @@ template void RunInitializeFromSnapshotTest(bool thread_id_collision) { using MinidumpContextType = typename Traits::MinidumpContextType; MINIDUMP_THREAD expect_threads[3] = {}; - uint64_t thread_ids[base::size(expect_threads)] = {}; - uint8_t memory_values[base::size(expect_threads)] = {}; - uint32_t context_seeds[base::size(expect_threads)] = {}; - MINIDUMP_MEMORY_DESCRIPTOR tebs[base::size(expect_threads)] = {}; + uint64_t thread_ids[std::size(expect_threads)] = {}; + uint8_t memory_values[std::size(expect_threads)] = {}; + uint32_t context_seeds[std::size(expect_threads)] = {}; + MINIDUMP_MEMORY_DESCRIPTOR tebs[std::size(expect_threads)] = {}; constexpr size_t kTebSize = 1024; @@ -590,7 +590,7 @@ void RunInitializeFromSnapshotTest(bool thread_id_collision) { std::vector> thread_snapshots_owner; std::vector thread_snapshots; - for (size_t index = 0; index < base::size(expect_threads); ++index) { + for (size_t index = 0; index < std::size(expect_threads); ++index) { thread_snapshots_owner.push_back(std::make_unique()); TestThreadSnapshot* thread_snapshot = thread_snapshots_owner.back().get(); diff --git a/minidump/minidump_writable.cc b/minidump/minidump_writable.cc index 8f69c9c1..9bfba52e 100644 --- a/minidump/minidump_writable.cc +++ b/minidump/minidump_writable.cc @@ -16,7 +16,8 @@ #include -#include "base/cxx17_backports.h" +#include + #include "base/logging.h" #include "util/file/file_writer.h" #include "util/numeric/safe_assignment.h" @@ -245,7 +246,7 @@ bool MinidumpWritable::WritePaddingAndObject(FileWriterInterface* file_writer) { // The number of elements in kZeroes must be at least one less than the // maximum Alignment() ever encountered. static constexpr uint8_t kZeroes[kMaximumAlignment - 1] = {}; - DCHECK_LE(leading_pad_bytes_, base::size(kZeroes)); + DCHECK_LE(leading_pad_bytes_, std::size(kZeroes)); if (leading_pad_bytes_) { if (!file_writer->Write(&kZeroes, leading_pad_bytes_)) { diff --git a/minidump/test/minidump_context_test_util.cc b/minidump/test/minidump_context_test_util.cc index 446e5a15..3836640c 100644 --- a/minidump/test/minidump_context_test_util.cc +++ b/minidump/test/minidump_context_test_util.cc @@ -17,7 +17,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/format_macros.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" @@ -128,8 +129,7 @@ void InitializeMinidumpContextAMD64(MinidumpContextAMD64* context, context->ds = static_cast(value++); context->es = static_cast(value++); context->ss = static_cast(value++); - for (size_t index = 0; index < base::size(context->vector_register); - ++index) { + for (size_t index = 0; index < std::size(context->vector_register); ++index) { context->vector_register[index].lo = value++; context->vector_register[index].hi = value++; } @@ -152,7 +152,7 @@ void InitializeMinidumpContextARM(MinidumpContextARM* context, uint32_t seed) { uint32_t value = seed; - for (size_t index = 0; index < base::size(context->regs); ++index) { + for (size_t index = 0; index < std::size(context->regs); ++index) { context->regs[index] = value++; } context->fp = value++; @@ -163,7 +163,7 @@ void InitializeMinidumpContextARM(MinidumpContextARM* context, uint32_t seed) { context->pc = value++; context->cpsr = value++; - for (size_t index = 0; index < base::size(context->vfp); ++index) { + for (size_t index = 0; index < std::size(context->vfp); ++index) { context->vfp[index] = value++; } context->fpscr = value++; @@ -181,7 +181,7 @@ void InitializeMinidumpContextARM64(MinidumpContextARM64* context, uint32_t value = seed; - for (size_t index = 0; index < base::size(context->regs); ++index) { + for (size_t index = 0; index < std::size(context->regs); ++index) { context->regs[index] = value++; } context->fp = value++; @@ -190,7 +190,7 @@ void InitializeMinidumpContextARM64(MinidumpContextARM64* context, context->pc = value++; context->cpsr = value++; - for (size_t index = 0; index < base::size(context->fpsimd); ++index) { + for (size_t index = 0; index < std::size(context->fpsimd); ++index) { context->fpsimd[index].lo = value++; context->fpsimd[index].hi = value++; } @@ -210,7 +210,7 @@ void InitializeMinidumpContextMIPS(MinidumpContextMIPS* context, uint32_t value = seed; - for (size_t index = 0; index < base::size(context->regs); ++index) { + for (size_t index = 0; index < std::size(context->regs); ++index) { context->regs[index] = value++; } @@ -221,7 +221,7 @@ void InitializeMinidumpContextMIPS(MinidumpContextMIPS* context, context->status = value++; context->cause = value++; - for (size_t index = 0; index < base::size(context->fpregs.fregs); ++index) { + for (size_t index = 0; index < std::size(context->fpregs.fregs); ++index) { context->fpregs.fregs[index]._fp_fregs = static_cast(value++); } @@ -248,7 +248,7 @@ void InitializeMinidumpContextMIPS64(MinidumpContextMIPS64* context, uint64_t value = seed; - for (size_t index = 0; index < base::size(context->regs); ++index) { + for (size_t index = 0; index < std::size(context->regs); ++index) { context->regs[index] = value++; } @@ -259,7 +259,7 @@ void InitializeMinidumpContextMIPS64(MinidumpContextMIPS64* context, context->status = value++; context->cause = value++; - for (size_t index = 0; index < base::size(context->fpregs.dregs); ++index) { + for (size_t index = 0; index < std::size(context->fpregs.dregs); ++index) { context->fpregs.dregs[index] = static_cast(value++); } context->fpcsr = value++; @@ -294,33 +294,33 @@ void ExpectMinidumpContextFxsave(const FxsaveType* expected, EXPECT_EQ(observed->reserved_3, expected->reserved_3); EXPECT_EQ(observed->mxcsr, expected->mxcsr); EXPECT_EQ(observed->mxcsr_mask, expected->mxcsr_mask); - for (size_t st_mm_index = 0; st_mm_index < base::size(expected->st_mm); + for (size_t st_mm_index = 0; st_mm_index < std::size(expected->st_mm); ++st_mm_index) { SCOPED_TRACE(base::StringPrintf("st_mm_index %" PRIuS, st_mm_index)); EXPECT_EQ(BytesToHexString(observed->st_mm[st_mm_index].st, - base::size(observed->st_mm[st_mm_index].st)), + std::size(observed->st_mm[st_mm_index].st)), BytesToHexString(expected->st_mm[st_mm_index].st, - base::size(expected->st_mm[st_mm_index].st))); + std::size(expected->st_mm[st_mm_index].st))); EXPECT_EQ( BytesToHexString(observed->st_mm[st_mm_index].st_reserved, - base::size(observed->st_mm[st_mm_index].st_reserved)), + std::size(observed->st_mm[st_mm_index].st_reserved)), BytesToHexString(expected->st_mm[st_mm_index].st_reserved, - base::size(expected->st_mm[st_mm_index].st_reserved))); + std::size(expected->st_mm[st_mm_index].st_reserved))); } - for (size_t xmm_index = 0; xmm_index < base::size(expected->xmm); + for (size_t xmm_index = 0; xmm_index < std::size(expected->xmm); ++xmm_index) { EXPECT_EQ(BytesToHexString(observed->xmm[xmm_index], - base::size(observed->xmm[xmm_index])), + std::size(observed->xmm[xmm_index])), BytesToHexString(expected->xmm[xmm_index], - base::size(expected->xmm[xmm_index]))) + std::size(expected->xmm[xmm_index]))) << "xmm_index " << xmm_index; } EXPECT_EQ( - BytesToHexString(observed->reserved_4, base::size(observed->reserved_4)), - BytesToHexString(expected->reserved_4, base::size(expected->reserved_4))); + BytesToHexString(observed->reserved_4, std::size(observed->reserved_4)), + BytesToHexString(expected->reserved_4, std::size(expected->reserved_4))); EXPECT_EQ( - BytesToHexString(observed->available, base::size(observed->available)), - BytesToHexString(expected->available, base::size(expected->available))); + BytesToHexString(observed->available, std::size(observed->available)), + BytesToHexString(expected->available, std::size(expected->available))); } } // namespace @@ -345,11 +345,11 @@ void ExpectMinidumpContextX86( EXPECT_EQ(observed->fsave.fpu_cs, expected.fsave.fpu_cs); EXPECT_EQ(observed->fsave.fpu_dp, expected.fsave.fpu_dp); EXPECT_EQ(observed->fsave.fpu_ds, expected.fsave.fpu_ds); - for (size_t index = 0; index < base::size(expected.fsave.st); ++index) { + for (size_t index = 0; index < std::size(expected.fsave.st); ++index) { EXPECT_EQ(BytesToHexString(observed->fsave.st[index], - base::size(observed->fsave.st[index])), + std::size(observed->fsave.st[index])), BytesToHexString(expected.fsave.st[index], - base::size(expected.fsave.st[index]))) + std::size(expected.fsave.st[index]))) << "index " << index; } if (snapshot) { @@ -448,8 +448,7 @@ void ExpectMinidumpContextAMD64( ExpectMinidumpContextFxsave(&expected.fxsave, &observed->fxsave); - for (size_t index = 0; index < base::size(expected.vector_register); - ++index) { + for (size_t index = 0; index < std::size(expected.vector_register); ++index) { if (snapshot) { EXPECT_EQ(observed->vector_register[index].lo, 0u) << "index " << index; EXPECT_EQ(observed->vector_register[index].hi, 0u) << "index " << index; @@ -489,7 +488,7 @@ void ExpectMinidumpContextARM(uint32_t expect_seed, EXPECT_EQ(observed->context_flags, expected.context_flags); - for (size_t index = 0; index < base::size(expected.regs); ++index) { + for (size_t index = 0; index < std::size(expected.regs); ++index) { EXPECT_EQ(observed->regs[index], expected.regs[index]); } EXPECT_EQ(observed->fp, expected.fp); @@ -500,10 +499,10 @@ void ExpectMinidumpContextARM(uint32_t expect_seed, EXPECT_EQ(observed->cpsr, expected.cpsr); EXPECT_EQ(observed->fpscr, expected.fpscr); - for (size_t index = 0; index < base::size(expected.vfp); ++index) { + for (size_t index = 0; index < std::size(expected.vfp); ++index) { EXPECT_EQ(observed->vfp[index], expected.vfp[index]); } - for (size_t index = 0; index < base::size(expected.extra); ++index) { + for (size_t index = 0; index < std::size(expected.extra); ++index) { EXPECT_EQ(observed->extra[index], snapshot ? 0 : expected.extra[index]); } } @@ -516,14 +515,14 @@ void ExpectMinidumpContextARM64(uint32_t expect_seed, EXPECT_EQ(observed->context_flags, expected.context_flags); - for (size_t index = 0; index < base::size(expected.regs); ++index) { + for (size_t index = 0; index < std::size(expected.regs); ++index) { EXPECT_EQ(observed->regs[index], expected.regs[index]); } EXPECT_EQ(observed->cpsr, expected.cpsr); EXPECT_EQ(observed->fpsr, expected.fpsr); EXPECT_EQ(observed->fpcr, expected.fpcr); - for (size_t index = 0; index < base::size(expected.fpsimd); ++index) { + for (size_t index = 0; index < std::size(expected.fpsimd); ++index) { EXPECT_EQ(observed->fpsimd[index].lo, expected.fpsimd[index].lo); EXPECT_EQ(observed->fpsimd[index].hi, expected.fpsimd[index].hi); } @@ -537,7 +536,7 @@ void ExpectMinidumpContextMIPS(uint32_t expect_seed, EXPECT_EQ(observed->context_flags, expected.context_flags); - for (size_t index = 0; index < base::size(expected.regs); ++index) { + for (size_t index = 0; index < std::size(expected.regs); ++index) { EXPECT_EQ(observed->regs[index], expected.regs[index]); } @@ -548,7 +547,7 @@ void ExpectMinidumpContextMIPS(uint32_t expect_seed, EXPECT_EQ(observed->status, expected.status); EXPECT_EQ(observed->cause, expected.cause); - for (size_t index = 0; index < base::size(expected.fpregs.fregs); ++index) { + for (size_t index = 0; index < std::size(expected.fpregs.fregs); ++index) { EXPECT_EQ(observed->fpregs.fregs[index]._fp_fregs, expected.fpregs.fregs[index]._fp_fregs); } @@ -570,7 +569,7 @@ void ExpectMinidumpContextMIPS64(uint32_t expect_seed, EXPECT_EQ(observed->context_flags, expected.context_flags); - for (size_t index = 0; index < base::size(expected.regs); ++index) { + for (size_t index = 0; index < std::size(expected.regs); ++index) { EXPECT_EQ(observed->regs[index], expected.regs[index]); } @@ -581,7 +580,7 @@ void ExpectMinidumpContextMIPS64(uint32_t expect_seed, EXPECT_EQ(observed->status, expected.status); EXPECT_EQ(observed->cause, expected.cause); - for (size_t index = 0; index < base::size(expected.fpregs.dregs); ++index) { + for (size_t index = 0; index < std::size(expected.fpregs.dregs); ++index) { EXPECT_EQ(observed->fpregs.dregs[index], expected.fpregs.dregs[index]); } EXPECT_EQ(observed->fpcsr, expected.fpcsr); diff --git a/snapshot/capture_memory.cc b/snapshot/capture_memory.cc index 5c7ded46..06d92581 100644 --- a/snapshot/capture_memory.cc +++ b/snapshot/capture_memory.cc @@ -16,10 +16,10 @@ #include +#include #include #include -#include "base/cxx17_backports.h" #include "base/logging.h" #include "snapshot/memory_snapshot.h" @@ -99,17 +99,17 @@ void CaptureMemory::PointedToByContext(const CPUContext& context, #elif defined(ARCH_CPU_ARM_FAMILY) if (context.architecture == kCPUArchitectureARM64) { MaybeCaptureMemoryAround(delegate, context.arm64->pc); - for (size_t i = 0; i < base::size(context.arm64->regs); ++i) { + for (size_t i = 0; i < std::size(context.arm64->regs); ++i) { MaybeCaptureMemoryAround(delegate, context.arm64->regs[i]); } } else { MaybeCaptureMemoryAround(delegate, context.arm->pc); - for (size_t i = 0; i < base::size(context.arm->regs); ++i) { + for (size_t i = 0; i < std::size(context.arm->regs); ++i) { MaybeCaptureMemoryAround(delegate, context.arm->regs[i]); } } #elif defined(ARCH_CPU_MIPS_FAMILY) - for (size_t i = 0; i < base::size(context.mipsel->regs); ++i) { + for (size_t i = 0; i < std::size(context.mipsel->regs); ++i) { MaybeCaptureMemoryAround(delegate, context.mipsel->regs[i]); } #else diff --git a/snapshot/cpu_context.cc b/snapshot/cpu_context.cc index 643ad80f..2e29f703 100644 --- a/snapshot/cpu_context.cc +++ b/snapshot/cpu_context.cc @@ -17,7 +17,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/notreached.h" #include "util/misc/arraysize.h" #include "util/misc/implicit_cast.h" @@ -58,7 +59,7 @@ void CPUContextX86::FxsaveToFsave(const Fxsave& fxsave, Fsave* fsave) { fsave->reserved_4 = 0; static_assert(ArraySize(fsave->st) == ArraySize(fxsave.st_mm), "FPU stack registers must be equivalent"); - for (size_t index = 0; index < base::size(fsave->st); ++index) { + for (size_t index = 0; index < std::size(fsave->st); ++index) { memcpy(fsave->st[index], fxsave.st_mm[index].st, sizeof(fsave->st[index])); } } @@ -80,7 +81,7 @@ void CPUContextX86::FsaveToFxsave(const Fsave& fsave, Fxsave* fxsave) { fxsave->mxcsr_mask = 0; static_assert(ArraySize(fxsave->st_mm) == ArraySize(fsave.st), "FPU stack registers must be equivalent"); - for (size_t index = 0; index < base::size(fsave.st); ++index) { + for (size_t index = 0; index < std::size(fsave.st); ++index) { memcpy(fxsave->st_mm[index].st, fsave.st[index], sizeof(fsave.st[index])); memset(fxsave->st_mm[index].st_reserved, 0, diff --git a/snapshot/cpu_context_test.cc b/snapshot/cpu_context_test.cc index b1340d6e..019c7694 100644 --- a/snapshot/cpu_context_test.cc +++ b/snapshot/cpu_context_test.cc @@ -18,7 +18,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "gtest/gtest.h" #include "test/hex_string.h" @@ -124,7 +125,7 @@ TEST(CPUContextX86, FxsaveToFsave) { &fxsave.st_mm[6].st, kExponentAllZero, false, kFractionAllZero); SetX87Register( &fxsave.st_mm[7].st, kExponentNormal, true, kFractionNormal); // valid - for (size_t index = 0; index < base::size(fxsave.st_mm); ++index) { + for (size_t index = 0; index < std::size(fxsave.st_mm); ++index) { memset(&fxsave.st_mm[index].st_reserved, 0x5a, sizeof(fxsave.st_mm[index].st_reserved)); @@ -148,10 +149,10 @@ TEST(CPUContextX86, FxsaveToFsave) { EXPECT_EQ(fsave.fpu_dp, fxsave.fpu_dp); EXPECT_EQ(fsave.fpu_ds, fxsave.fpu_ds); EXPECT_EQ(fsave.reserved_4, 0); - for (size_t index = 0; index < base::size(fsave.st); ++index) { - EXPECT_EQ(BytesToHexString(fsave.st[index], base::size(fsave.st[index])), + for (size_t index = 0; index < std::size(fsave.st); ++index) { + EXPECT_EQ(BytesToHexString(fsave.st[index], std::size(fsave.st[index])), BytesToHexString(fxsave.st_mm[index].st, - base::size(fxsave.st_mm[index].st))) + std::size(fxsave.st_mm[index].st))) << "index " << index; } } @@ -204,14 +205,14 @@ TEST(CPUContextX86, FsaveToFxsave) { EXPECT_EQ(fxsave.reserved_3, 0); EXPECT_EQ(fxsave.mxcsr, 0u); EXPECT_EQ(fxsave.mxcsr_mask, 0u); - for (size_t index = 0; index < base::size(fxsave.st_mm); ++index) { + for (size_t index = 0; index < std::size(fxsave.st_mm); ++index) { EXPECT_EQ(BytesToHexString(fxsave.st_mm[index].st, - base::size(fxsave.st_mm[index].st)), - BytesToHexString(fsave.st[index], base::size(fsave.st[index]))) + std::size(fxsave.st_mm[index].st)), + BytesToHexString(fsave.st[index], std::size(fsave.st[index]))) << "index " << index; EXPECT_EQ(BytesToHexString(fxsave.st_mm[index].st_reserved, - base::size(fxsave.st_mm[index].st_reserved)), - std::string(base::size(fxsave.st_mm[index].st_reserved) * 2, '0')) + std::size(fxsave.st_mm[index].st_reserved)), + std::string(std::size(fxsave.st_mm[index].st_reserved) * 2, '0')) << "index " << index; } size_t unused_len = sizeof(fxsave) - offsetof(decltype(fxsave), xmm); @@ -318,7 +319,7 @@ TEST(CPUContextX86, FxsaveToFsaveTagWord) { // In this set, everything is valid. fsw = 0 << 11; // top = 0: logical 0-7 maps to physical 0-7 fxsave_tag = 0xff; // nothing empty - for (size_t index = 0; index < base::size(st_mm); ++index) { + for (size_t index = 0; index < std::size(st_mm); ++index) { SetX87OrMMXRegister(&st_mm[index], kExponentNormal, true, kFractionAllZero); } EXPECT_EQ(CPUContextX86::FxsaveToFsaveTagWord(fsw, fxsave_tag, st_mm), 0); diff --git a/snapshot/fuchsia/memory_map_region_snapshot_fuchsia.cc b/snapshot/fuchsia/memory_map_region_snapshot_fuchsia.cc index a5885b06..8d7f9b86 100644 --- a/snapshot/fuchsia/memory_map_region_snapshot_fuchsia.cc +++ b/snapshot/fuchsia/memory_map_region_snapshot_fuchsia.cc @@ -14,8 +14,9 @@ #include "snapshot/fuchsia/memory_map_region_snapshot_fuchsia.h" +#include + #include "base/check_op.h" -#include "base/cxx17_backports.h" namespace crashpad { namespace internal { @@ -50,7 +51,7 @@ uint32_t MmuFlagsToProtectFlags(zx_vm_option_t flags) { const uint32_t index = flags & (ZX_VM_PERM_READ | ZX_VM_PERM_WRITE | ZX_VM_PERM_EXECUTE); - DCHECK_LT(index, base::size(mapping)); + DCHECK_LT(index, std::size(mapping)); const uint32_t protect_flags = mapping[index]; DCHECK_NE(protect_flags, 0u); diff --git a/snapshot/fuchsia/process_reader_fuchsia_test.cc b/snapshot/fuchsia/process_reader_fuchsia_test.cc index f5a8aea7..362be5bd 100644 --- a/snapshot/fuchsia/process_reader_fuchsia_test.cc +++ b/snapshot/fuchsia/process_reader_fuchsia_test.cc @@ -20,7 +20,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "gtest/gtest.h" #include "test/multiprocess_exec.h" #include "test/test_paths.h" @@ -35,7 +36,7 @@ TEST(ProcessReaderFuchsia, SelfBasic) { ASSERT_TRUE(process_reader.Initialize(*zx::process::self())); static constexpr char kTestMemory[] = "Some test memory"; - char buffer[base::size(kTestMemory)]; + char buffer[std::size(kTestMemory)]; ASSERT_TRUE(process_reader.Memory()->Read( reinterpret_cast(kTestMemory), sizeof(kTestMemory), &buffer)); EXPECT_STREQ(kTestMemory, buffer); diff --git a/snapshot/fuchsia/process_snapshot_fuchsia_test.cc b/snapshot/fuchsia/process_snapshot_fuchsia_test.cc index 9389868b..874f1590 100644 --- a/snapshot/fuchsia/process_snapshot_fuchsia_test.cc +++ b/snapshot/fuchsia/process_snapshot_fuchsia_test.cc @@ -12,17 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "snapshot/fuchsia/memory_map_region_snapshot_fuchsia.h" +#include "snapshot/fuchsia/process_snapshot_fuchsia.h" #include #include -#include "base/cxx17_backports.h" +#include + #include "base/fuchsia/fuchsia_logging.h" #include "base/logging.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" -#include "snapshot/fuchsia/process_snapshot_fuchsia.h" +#include "snapshot/fuchsia/memory_map_region_snapshot_fuchsia.h" #include "test/multiprocess_exec.h" #include "util/fuchsia/koid_utilities.h" #include "util/fuchsia/scoped_task_suspend.h" @@ -111,8 +112,8 @@ class AddressSpaceTest : public MultiprocessExec { private: void MultiprocessParent() override { - uintptr_t test_addresses[base::size(kTestMappingPermAndSizes)]; - for (size_t i = 0; i < base::size(test_addresses); ++i) { + uintptr_t test_addresses[std::size(kTestMappingPermAndSizes)]; + for (size_t i = 0; i < std::size(test_addresses); ++i) { ASSERT_TRUE(ReadFileExactly( ReadPipeHandle(), &test_addresses[i], sizeof(test_addresses[i]))); } @@ -122,7 +123,7 @@ class AddressSpaceTest : public MultiprocessExec { ProcessSnapshotFuchsia process_snapshot; ASSERT_TRUE(process_snapshot.Initialize(*ChildProcess())); - for (size_t i = 0; i < base::size(test_addresses); ++i) { + for (size_t i = 0; i < std::size(test_addresses); ++i) { const auto& t = kTestMappingPermAndSizes[i]; EXPECT_TRUE(HasSingleMatchingMapping(process_snapshot.MemoryMap(), test_addresses[i], diff --git a/snapshot/linux/exception_snapshot_linux_test.cc b/snapshot/linux/exception_snapshot_linux_test.cc index 91be497a..a045f365 100644 --- a/snapshot/linux/exception_snapshot_linux_test.cc +++ b/snapshot/linux/exception_snapshot_linux_test.cc @@ -21,8 +21,9 @@ #include #include +#include + #include "base/bit_cast.h" -#include "base/cxx17_backports.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" #include "snapshot/cpu_architecture.h" @@ -170,7 +171,7 @@ void InitializeContext(NativeCPUContext* context) { test_context->vfp.head.magic = VFP_MAGIC; test_context->vfp.head.size = sizeof(test_context->vfp); memset(&test_context->vfp.context, 'v', sizeof(test_context->vfp.context)); - for (size_t reg = 0; reg < base::size(test_context->vfp.context.vfp.fpregs); + for (size_t reg = 0; reg < std::size(test_context->vfp.context.vfp.fpregs); ++reg) { test_context->vfp.context.vfp.fpregs[reg] = reg; } @@ -218,7 +219,7 @@ struct TestCoprocessorContext { void InitializeContext(NativeCPUContext* context) { memset(context, 'x', sizeof(*context)); - for (size_t index = 0; index < base::size(context->uc_mcontext.regs); + for (size_t index = 0; index < std::size(context->uc_mcontext.regs); ++index) { context->uc_mcontext.regs[index] = index; } @@ -237,7 +238,7 @@ void InitializeContext(NativeCPUContext* context) { test_context->fpsimd.head.size = sizeof(test_context->fpsimd); test_context->fpsimd.fpsr = 1; test_context->fpsimd.fpcr = 2; - for (size_t reg = 0; reg < base::size(test_context->fpsimd.vregs); ++reg) { + for (size_t reg = 0; reg < std::size(test_context->fpsimd.vregs); ++reg) { test_context->fpsimd.vregs[reg] = reg; } @@ -270,7 +271,7 @@ void ExpectContext(const CPUContext& actual, const NativeCPUContext& expected) { using NativeCPUContext = ucontext_t; void InitializeContext(NativeCPUContext* context) { - for (size_t reg = 0; reg < base::size(context->uc_mcontext.gregs); ++reg) { + for (size_t reg = 0; reg < std::size(context->uc_mcontext.gregs); ++reg) { context->uc_mcontext.gregs[reg] = reg; } memset(&context->uc_mcontext.fpregs, 44, sizeof(context->uc_mcontext.fpregs)); @@ -285,7 +286,7 @@ void ExpectContext(const CPUContext& actual, const NativeCPUContext& expected) { #define CPU_ARCH_NAME mips64 #endif - for (size_t reg = 0; reg < base::size(expected.uc_mcontext.gregs); ++reg) { + for (size_t reg = 0; reg < std::size(expected.uc_mcontext.gregs); ++reg) { EXPECT_EQ(actual.CPU_ARCH_NAME->regs[reg], expected.uc_mcontext.gregs[reg]); } diff --git a/snapshot/linux/process_reader_linux_test.cc b/snapshot/linux/process_reader_linux_test.cc index 8cc90a0e..81b3d6ec 100644 --- a/snapshot/linux/process_reader_linux_test.cc +++ b/snapshot/linux/process_reader_linux_test.cc @@ -26,12 +26,12 @@ #include #include +#include #include #include #include #include -#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/memory/free_deleter.h" #include "base/strings/stringprintf.h" @@ -88,7 +88,7 @@ TEST(ProcessReaderLinux, SelfBasic) { EXPECT_EQ(process_reader.ParentProcessID(), getppid()); static constexpr char kTestMemory[] = "Some test memory"; - char buffer[base::size(kTestMemory)]; + char buffer[std::size(kTestMemory)]; ASSERT_TRUE(process_reader.Memory()->Read( reinterpret_cast(kTestMemory), sizeof(kTestMemory), diff --git a/snapshot/mac/mach_o_image_reader.cc b/snapshot/mac/mach_o_image_reader.cc index 4e66f3db..5c5bcb00 100644 --- a/snapshot/mac/mach_o_image_reader.cc +++ b/snapshot/mac/mach_o_image_reader.cc @@ -18,10 +18,10 @@ #include #include +#include #include #include -#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/strings/stringprintf.h" #include "client/crashpad_info.h" @@ -183,7 +183,7 @@ bool MachOImageReader::Initialize(ProcessReaderMac* process_reader, // This vector is parallel to the kLoadCommandReaders array, and tracks // whether a singleton load command matching the |command| field has been // found yet. - std::vector singleton_indices(base::size(kLoadCommandReaders), + std::vector singleton_indices(std::size(kLoadCommandReaders), kInvalidSegmentIndex); size_t offset = mach_header.Size(); @@ -236,8 +236,7 @@ bool MachOImageReader::Initialize(ProcessReaderMac* process_reader, return false; } - for (size_t reader_index = 0; - reader_index < base::size(kLoadCommandReaders); + for (size_t reader_index = 0; reader_index < std::size(kLoadCommandReaders); ++reader_index) { if (load_command.cmd != kLoadCommandReaders[reader_index].command) { continue; diff --git a/snapshot/mac/mach_o_image_segment_reader_test.cc b/snapshot/mac/mach_o_image_segment_reader_test.cc index f89b475f..38e55dfa 100644 --- a/snapshot/mac/mach_o_image_segment_reader_test.cc +++ b/snapshot/mac/mach_o_image_segment_reader_test.cc @@ -16,7 +16,8 @@ #include -#include "base/cxx17_backports.h" +#include + #include "base/strings/stringprintf.h" #include "gtest/gtest.h" @@ -63,7 +64,7 @@ TEST(MachOImageSegmentReader, SegmentNameString) { SEG_IMPORT, }; - for (size_t index = 0; index < base::size(kSegmentTestData); ++index) { + for (size_t index = 0; index < std::size(kSegmentTestData); ++index) { EXPECT_EQ( MachOImageSegmentReader::SegmentNameString(kSegmentTestData[index]), kSegmentTestData[index]) @@ -106,7 +107,7 @@ TEST(MachOImageSegmentReader, SectionNameString) { SECT_ICON_TIFF, }; - for (size_t index = 0; index < base::size(kSectionTestData); ++index) { + for (size_t index = 0; index < std::size(kSectionTestData); ++index) { EXPECT_EQ( MachOImageSegmentReader::SectionNameString(kSectionTestData[index]), kSectionTestData[index]) @@ -169,7 +170,7 @@ TEST(MachOImageSegmentReader, SegmentAndSectionNameString) { {SEG_IMPORT, "", "__IMPORT,"}, }; - for (size_t index = 0; index < base::size(kSegmentAndSectionTestData); + for (size_t index = 0; index < std::size(kSegmentAndSectionTestData); ++index) { const auto& test = kSegmentAndSectionTestData[index]; EXPECT_EQ(MachOImageSegmentReader::SegmentAndSectionNameString( diff --git a/snapshot/mac/process_reader_mac_test.cc b/snapshot/mac/process_reader_mac_test.cc index 6b4e108b..88689508 100644 --- a/snapshot/mac/process_reader_mac_test.cc +++ b/snapshot/mac/process_reader_mac_test.cc @@ -25,11 +25,11 @@ #include #include +#include #include #include #include "base/check_op.h" -#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/mac/mach_logging.h" #include "base/posix/eintr_wrapper.h" @@ -68,7 +68,7 @@ TEST(ProcessReaderMac, SelfBasic) { EXPECT_EQ(process_reader.ParentProcessID(), getppid()); static constexpr char kTestMemory[] = "Some test memory"; - char buffer[base::size(kTestMemory)]; + char buffer[std::size(kTestMemory)]; ASSERT_TRUE(process_reader.Memory()->Read( FromPointerCast(kTestMemory), sizeof(kTestMemory), @@ -702,11 +702,11 @@ class ScopedOpenCLNoOpKernel { const size_t source_lengths[] = { strlen(sources[0]), }; - static_assert(base::size(sources) == base::size(source_lengths), + static_assert(std::size(sources) == std::size(source_lengths), "arrays must be parallel"); program_ = clCreateProgramWithSource( - context_, base::size(sources), sources, source_lengths, &rv); + context_, std::size(sources), sources, source_lengths, &rv); ASSERT_EQ(rv, CL_SUCCESS) << "clCreateProgramWithSource"; rv = clBuildProgram( diff --git a/snapshot/mac/process_types.cc b/snapshot/mac/process_types.cc index 3d4e0590..c91b697d 100644 --- a/snapshot/mac/process_types.cc +++ b/snapshot/mac/process_types.cc @@ -18,9 +18,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "snapshot/mac/process_types/internal.h" #include "util/process/process_memory_mac.h" @@ -74,7 +74,7 @@ using UInt64Array4 = uint64_t[4]; template <> inline void Assign(UInt64Array4* destination, const UInt32Array4& source) { - for (size_t index = 0; index < base::size(source); ++index) { + for (size_t index = 0; index < std::size(source); ++index) { (*destination)[index] = source[index]; } } diff --git a/snapshot/mac/process_types/custom.cc b/snapshot/mac/process_types/custom.cc index 06c13001..5c6dec98 100644 --- a/snapshot/mac/process_types/custom.cc +++ b/snapshot/mac/process_types/custom.cc @@ -12,21 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "snapshot/mac/process_types.h" - #include #include #include #include +#include #include #include #include "base/check_op.h" -#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/numerics/safe_math.h" #include "base/strings/stringprintf.h" +#include "snapshot/mac/process_types.h" #include "snapshot/mac/process_types/internal.h" #include "util/mac/mac_util.h" #include "util/process/process_memory_mac.h" @@ -150,8 +149,8 @@ size_t dyld_all_image_infos::ExpectedSizeForVersion( sizeof(dyld_all_image_infos), // 18 }; - if (version >= base::size(kSizeForVersion)) { - return kSizeForVersion[base::size(kSizeForVersion) - 1]; + if (version >= std::size(kSizeForVersion)) { + return kSizeForVersion[std::size(kSizeForVersion) - 1]; } static_assert(std::is_unsigned::value, diff --git a/snapshot/mac/process_types_test.cc b/snapshot/mac/process_types_test.cc index 90f5c1f6..2946dc25 100644 --- a/snapshot/mac/process_types_test.cc +++ b/snapshot/mac/process_types_test.cc @@ -18,10 +18,10 @@ #include #include +#include #include #include -#include "base/cxx17_backports.h" #include "base/strings/stringprintf.h" #include "build/build_config.h" #include "gtest/gtest.h" @@ -172,7 +172,7 @@ TEST(ProcessTypes, DyldImagesSelf) { {16, kUnsupported, 328}, {17, kUnsupported, 368}, }; - for (size_t index = 0; index < base::size(kVersionsAndSizes); ++index) { + for (size_t index = 0; index < std::size(kVersionsAndSizes); ++index) { uint32_t version = kVersionsAndSizes[index].version; SCOPED_TRACE(base::StringPrintf("index %zu, version %u", index, version)); @@ -325,7 +325,7 @@ TEST(ProcessTypes, DyldImagesSelf) { self_image_infos->sharedCacheBaseAddress); EXPECT_EQ(proctype_image_infos.dyldPath, reinterpret_cast(self_image_infos->dyldPath)); - for (size_t index = 0; index < base::size(self_image_infos->notifyPorts); + for (size_t index = 0; index < std::size(self_image_infos->notifyPorts); ++index) { EXPECT_EQ(proctype_image_infos.notifyPorts[index], self_image_infos->notifyPorts[index]) @@ -345,7 +345,7 @@ TEST(ProcessTypes, DyldImagesSelf) { // process_types version. It’s difficult to compare the reserved fields in // these older SDKs, so only do it where the declarations match. if (proctype_image_infos.version >= 14) { - for (size_t index = 0; index < base::size(proctype_image_infos.reserved); + for (size_t index = 0; index < std::size(proctype_image_infos.reserved); ++index) { EXPECT_EQ(proctype_image_infos.reserved[index], implicit_cast(self_image_infos->reserved[index])) diff --git a/snapshot/minidump/minidump_context_converter.cc b/snapshot/minidump/minidump_context_converter.cc index 981f34c9..5e94ca2c 100644 --- a/snapshot/minidump/minidump_context_converter.cc +++ b/snapshot/minidump/minidump_context_converter.cc @@ -16,7 +16,8 @@ #include -#include "base/cxx17_backports.h" +#include + #include "base/logging.h" #include "minidump/minidump_context.h" @@ -147,7 +148,7 @@ bool MinidumpContextConverter::Initialize( return false; } - for (size_t i = 0; i < base::size(src->regs); i++) { + for (size_t i = 0; i < std::size(src->regs); i++) { context_.arm->regs[i] = src->regs[i]; } @@ -159,7 +160,7 @@ bool MinidumpContextConverter::Initialize( context_.arm->cpsr = src->cpsr; context_.arm->vfp_regs.fpscr = src->fpscr; - for (size_t i = 0; i < base::size(src->vfp); i++) { + for (size_t i = 0; i < std::size(src->vfp); i++) { context_.arm->vfp_regs.vfp[i] = src->vfp[i]; } @@ -179,14 +180,14 @@ bool MinidumpContextConverter::Initialize( return false; } - for (size_t i = 0; i < base::size(src->regs); i++) { + for (size_t i = 0; i < std::size(src->regs); i++) { context_.arm64->regs[i] = src->regs[i]; } context_.arm64->regs[29] = src->fp; context_.arm64->regs[30] = src->lr; - for (size_t i = 0; i < base::size(src->fpsimd); i++) { + for (size_t i = 0; i < std::size(src->fpsimd); i++) { context_.arm64->fpsimd[i] = src->fpsimd[i]; } @@ -208,7 +209,7 @@ bool MinidumpContextConverter::Initialize( return false; } - for (size_t i = 0; i < base::size(src->regs); i++) { + for (size_t i = 0; i < std::size(src->regs); i++) { context_.mipsel->regs[i] = src->regs[i]; } @@ -216,7 +217,7 @@ bool MinidumpContextConverter::Initialize( context_.mipsel->mdlo = static_cast(src->mdlo); context_.mipsel->dsp_control = src->dsp_control; - for (size_t i = 0; i < base::size(src->hi); i++) { + for (size_t i = 0; i < std::size(src->hi); i++) { context_.mipsel->hi[i] = src->hi[i]; context_.mipsel->lo[i] = src->lo[i]; } @@ -244,7 +245,7 @@ bool MinidumpContextConverter::Initialize( return false; } - for (size_t i = 0; i < base::size(src->regs); i++) { + for (size_t i = 0; i < std::size(src->regs); i++) { context_.mips64->regs[i] = src->regs[i]; } @@ -252,7 +253,7 @@ bool MinidumpContextConverter::Initialize( context_.mips64->mdlo = src->mdlo; context_.mips64->dsp_control = src->dsp_control; - for (size_t i = 0; i < base::size(src->hi); i++) { + for (size_t i = 0; i < std::size(src->hi); i++) { context_.mips64->hi[i] = src->hi[i]; context_.mips64->lo[i] = src->lo[i]; } diff --git a/snapshot/minidump/process_snapshot_minidump_test.cc b/snapshot/minidump/process_snapshot_minidump_test.cc index 3c5dcf6c..ded561bf 100644 --- a/snapshot/minidump/process_snapshot_minidump_test.cc +++ b/snapshot/minidump/process_snapshot_minidump_test.cc @@ -19,9 +19,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/numerics/safe_math.h" #include "base/strings/utf_string_conversions.h" #include "gtest/gtest.h" @@ -980,27 +980,27 @@ TEST(ProcessSnapshotMinidump, ThreadContextX86_64) { minidump_context.fxsave.fpu_ip_64 = 42; minidump_context.fxsave.fpu_dp_64 = 43; - for (size_t i = 0; i < base::size(minidump_context.vector_register); i++) { + for (size_t i = 0; i < std::size(minidump_context.vector_register); i++) { minidump_context.vector_register[i].lo = i * 2 + 44; minidump_context.vector_register[i].hi = i * 2 + 45; } - for (uint8_t i = 0; i < base::size(minidump_context.fxsave.reserved_4); i++) { + for (uint8_t i = 0; i < std::size(minidump_context.fxsave.reserved_4); i++) { minidump_context.fxsave.reserved_4[i] = i * 2 + 115; minidump_context.fxsave.available[i] = i * 2 + 116; } - for (size_t i = 0; i < base::size(minidump_context.fxsave.st_mm); i++) { + for (size_t i = 0; i < std::size(minidump_context.fxsave.st_mm); i++) { for (uint8_t j = 0; - j < base::size(minidump_context.fxsave.st_mm[0].mm_value); + j < std::size(minidump_context.fxsave.st_mm[0].mm_value); j++) { minidump_context.fxsave.st_mm[i].mm_value[j] = j + 1; minidump_context.fxsave.st_mm[i].mm_reserved[j] = j + 1; } } - for (size_t i = 0; i < base::size(minidump_context.fxsave.xmm); i++) { - for (uint8_t j = 0; j < base::size(minidump_context.fxsave.xmm[0]); j++) { + for (size_t i = 0; i < std::size(minidump_context.fxsave.xmm); i++) { + for (uint8_t j = 0; j < std::size(minidump_context.fxsave.xmm[0]); j++) { minidump_context.fxsave.xmm[i][j] = j + 1; } } @@ -1083,20 +1083,20 @@ TEST(ProcessSnapshotMinidump, ThreadContextX86_64) { EXPECT_EQ(ctx->fxsave.fpu_ip_64, 42U); EXPECT_EQ(ctx->fxsave.fpu_dp_64, 43U); - for (uint8_t i = 0; i < base::size(ctx->fxsave.reserved_4); i++) { + for (uint8_t i = 0; i < std::size(ctx->fxsave.reserved_4); i++) { EXPECT_EQ(ctx->fxsave.reserved_4[i], i * 2 + 115); EXPECT_EQ(ctx->fxsave.available[i], i * 2 + 116); } - for (size_t i = 0; i < base::size(ctx->fxsave.st_mm); i++) { - for (uint8_t j = 0; j < base::size(ctx->fxsave.st_mm[0].mm_value); j++) { + for (size_t i = 0; i < std::size(ctx->fxsave.st_mm); i++) { + for (uint8_t j = 0; j < std::size(ctx->fxsave.st_mm[0].mm_value); j++) { EXPECT_EQ(ctx->fxsave.st_mm[i].mm_value[j], j + 1); EXPECT_EQ(ctx->fxsave.st_mm[i].mm_reserved[j], j + 1); } } - for (size_t i = 0; i < base::size(ctx->fxsave.xmm); i++) { - for (uint8_t j = 0; j < base::size(ctx->fxsave.xmm[0]); j++) { + for (size_t i = 0; i < std::size(ctx->fxsave.xmm); i++) { + for (uint8_t j = 0; j < std::size(ctx->fxsave.xmm[0]); j++) { EXPECT_EQ(ctx->fxsave.xmm[i][j], j + 1); } } diff --git a/snapshot/posix/timezone.cc b/snapshot/posix/timezone.cc index e4b52081..3591157e 100644 --- a/snapshot/posix/timezone.cc +++ b/snapshot/posix/timezone.cc @@ -17,8 +17,9 @@ #include #include +#include + #include "base/check.h" -#include "base/cxx17_backports.h" #include "base/logging.h" #include "build/build_config.h" @@ -61,8 +62,7 @@ void TimeZone(const timeval& snapshot_time, static constexpr int kMonthDeltas[] = {0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12}; - for (size_t index = 0; - index < base::size(kMonthDeltas) && !found_transition; + for (size_t index = 0; index < std::size(kMonthDeltas) && !found_transition; ++index) { // Look at a day of each month at local noon. Set tm_isdst to -1 to avoid // giving mktime() any hints about whether to consider daylight saving diff --git a/snapshot/posix/timezone_test.cc b/snapshot/posix/timezone_test.cc index 6a343767..990a063e 100644 --- a/snapshot/posix/timezone_test.cc +++ b/snapshot/posix/timezone_test.cc @@ -18,9 +18,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" #include "test/errors.h" @@ -154,7 +154,7 @@ TEST(TimeZone, Basic) { {"UTC", false, 0, 0, "UTC", "UTC"}, }; - for (size_t index = 0; index < base::size(kTestTimeZones); ++index) { + for (size_t index = 0; index < std::size(kTestTimeZones); ++index) { const auto& test_time_zone = kTestTimeZones[index]; const char* tz = test_time_zone.tz; SCOPED_TRACE(base::StringPrintf("index %zu, tz %s", index, tz)); diff --git a/snapshot/sanitized/process_snapshot_sanitized_test.cc b/snapshot/sanitized/process_snapshot_sanitized_test.cc index f6ef1efa..306f2df2 100644 --- a/snapshot/sanitized/process_snapshot_sanitized_test.cc +++ b/snapshot/sanitized/process_snapshot_sanitized_test.cc @@ -16,7 +16,8 @@ #include -#include "base/cxx17_backports.h" +#include + #include "base/notreached.h" #include "build/build_config.h" #include "gtest/gtest.h" @@ -101,7 +102,7 @@ void ChildTestFunction() { static StringAnnotation<32> non_allowed_annotation(kNonAllowedAnnotationName); non_allowed_annotation.Set(kNonAllowedAnnotationValue); - char string_data[base::size(kSensitiveStackData)]; + char string_data[std::size(kSensitiveStackData)]; strcpy(string_data, kSensitiveStackData); void (*code_pointer)(void) = ChildTestFunction; diff --git a/snapshot/sanitized/sanitization_information_test.cc b/snapshot/sanitized/sanitization_information_test.cc index 933bc923..65b01f08 100644 --- a/snapshot/sanitized/sanitization_information_test.cc +++ b/snapshot/sanitized/sanitization_information_test.cc @@ -14,7 +14,8 @@ #include "snapshot/sanitized/sanitization_information.h" -#include "base/cxx17_backports.h" +#include + #include "build/build_config.h" #include "gtest/gtest.h" #include "util/misc/from_pointer_cast.h" @@ -66,7 +67,7 @@ const char* const kNonEmptyAllowedAnnotations[] = {"string1", TEST_F(AllowedAnnotationsTest, NonEmptyAllowedAnnotations) { ASSERT_TRUE(DoReadAllowedAnnotations(kNonEmptyAllowedAnnotations)); ASSERT_EQ(allowed_annotations_.size(), - base::size(kNonEmptyAllowedAnnotations) - 1); + std::size(kNonEmptyAllowedAnnotations) - 1); for (size_t index = 0; index < allowed_annotations_.size(); ++index) { EXPECT_EQ(allowed_annotations_[index], kNonEmptyAllowedAnnotations[index]); } diff --git a/snapshot/test/test_cpu_context.cc b/snapshot/test/test_cpu_context.cc index 4923d4c4..75d9c5a1 100644 --- a/snapshot/test/test_cpu_context.cc +++ b/snapshot/test/test_cpu_context.cc @@ -17,7 +17,7 @@ #include #include -#include "base/cxx17_backports.h" +#include namespace crashpad { namespace test { @@ -44,28 +44,28 @@ void InitializeCPUContextFxsave(FxsaveType* fxsave, uint32_t* seed) { fxsave->reserved_3 = static_cast(value++); fxsave->mxcsr = value++; fxsave->mxcsr_mask = value++; - for (size_t st_mm_index = 0; st_mm_index < base::size(fxsave->st_mm); + for (size_t st_mm_index = 0; st_mm_index < std::size(fxsave->st_mm); ++st_mm_index) { - for (size_t byte = 0; byte < base::size(fxsave->st_mm[st_mm_index].st); + for (size_t byte = 0; byte < std::size(fxsave->st_mm[st_mm_index].st); ++byte) { fxsave->st_mm[st_mm_index].st[byte] = static_cast(value++); } for (size_t byte = 0; - byte < base::size(fxsave->st_mm[st_mm_index].st_reserved); + byte < std::size(fxsave->st_mm[st_mm_index].st_reserved); ++byte) { fxsave->st_mm[st_mm_index].st_reserved[byte] = static_cast(value); } } - for (size_t xmm_index = 0; xmm_index < base::size(fxsave->xmm); ++xmm_index) { - for (size_t byte = 0; byte < base::size(fxsave->xmm[xmm_index]); ++byte) { + for (size_t xmm_index = 0; xmm_index < std::size(fxsave->xmm); ++xmm_index) { + for (size_t byte = 0; byte < std::size(fxsave->xmm[xmm_index]); ++byte) { fxsave->xmm[xmm_index][byte] = static_cast(value++); } } - for (size_t byte = 0; byte < base::size(fxsave->reserved_4); ++byte) { + for (size_t byte = 0; byte < std::size(fxsave->reserved_4); ++byte) { fxsave->reserved_4[byte] = static_cast(value++); } - for (size_t byte = 0; byte < base::size(fxsave->available); ++byte) { + for (size_t byte = 0; byte < std::size(fxsave->available); ++byte) { fxsave->available[byte] = static_cast(value++); } @@ -174,7 +174,7 @@ void InitializeCPUContextARM(CPUContext* context, uint32_t seed) { uint32_t value = seed; - for (size_t index = 0; index < base::size(arm->regs); ++index) { + for (size_t index = 0; index < std::size(arm->regs); ++index) { arm->regs[index] = value++; } arm->fp = value++; @@ -185,7 +185,7 @@ void InitializeCPUContextARM(CPUContext* context, uint32_t seed) { arm->pc = value++; arm->cpsr = value++; - for (size_t index = 0; index < base::size(arm->vfp_regs.vfp); ++index) { + for (size_t index = 0; index < std::size(arm->vfp_regs.vfp); ++index) { arm->vfp_regs.vfp[index] = value++; } arm->vfp_regs.fpscr = value++; @@ -205,14 +205,14 @@ void InitializeCPUContextARM64(CPUContext* context, uint32_t seed) { uint32_t value = seed; - for (size_t index = 0; index < base::size(arm64->regs); ++index) { + for (size_t index = 0; index < std::size(arm64->regs); ++index) { arm64->regs[index] = value++; } arm64->sp = value++; arm64->pc = value++; arm64->spsr = value++; - for (size_t index = 0; index < base::size(arm64->fpsimd); ++index) { + for (size_t index = 0; index < std::size(arm64->fpsimd); ++index) { arm64->fpsimd[index].lo = value++; arm64->fpsimd[index].hi = value++; } @@ -231,7 +231,7 @@ void InitializeCPUContextMIPS(CPUContext* context, uint32_t seed) { uint32_t value = seed; - for (size_t index = 0; index < base::size(mipsel->regs); ++index) { + for (size_t index = 0; index < std::size(mipsel->regs); ++index) { mipsel->regs[index] = value++; } @@ -242,7 +242,7 @@ void InitializeCPUContextMIPS(CPUContext* context, uint32_t seed) { mipsel->cp0_status = value++; mipsel->cp0_cause = value++; - for (size_t index = 0; index < base::size(mipsel->fpregs.fregs); ++index) { + for (size_t index = 0; index < std::size(mipsel->fpregs.fregs); ++index) { mipsel->fpregs.fregs[index]._fp_fregs = static_cast(value++); } @@ -267,7 +267,7 @@ void InitializeCPUContextMIPS64(CPUContext* context, uint32_t seed) { uint64_t value = seed; - for (size_t index = 0; index < base::size(mips64->regs); ++index) { + for (size_t index = 0; index < std::size(mips64->regs); ++index) { mips64->regs[index] = value++; } @@ -278,7 +278,7 @@ void InitializeCPUContextMIPS64(CPUContext* context, uint32_t seed) { mips64->cp0_status = value++; mips64->cp0_cause = value++; - for (size_t index = 0; index < base::size(mips64->fpregs.dregs); ++index) { + for (size_t index = 0; index < std::size(mips64->fpregs.dregs); ++index) { mips64->fpregs.dregs[index] = static_cast(value++); } diff --git a/snapshot/win/cpu_context_win_test.cc b/snapshot/win/cpu_context_win_test.cc index 15f76677..ab8b8b31 100644 --- a/snapshot/win/cpu_context_win_test.cc +++ b/snapshot/win/cpu_context_win_test.cc @@ -16,7 +16,8 @@ #include -#include "base/cxx17_backports.h" +#include + #include "build/build_config.h" #include "gtest/gtest.h" #include "snapshot/cpu_context.h" @@ -87,13 +88,13 @@ void TestInitializeX86Context_FsaveWithoutFxsave() { for (size_t st_mm = 0; st_mm < 7; ++st_mm) { EXPECT_EQ( BytesToHexString(cpu_context_x86.fxsave.st_mm[st_mm].st, - base::size(cpu_context_x86.fxsave.st_mm[st_mm].st)), - std::string(base::size(cpu_context_x86.fxsave.st_mm[st_mm].st) * 2, + std::size(cpu_context_x86.fxsave.st_mm[st_mm].st)), + std::string(std::size(cpu_context_x86.fxsave.st_mm[st_mm].st) * 2, '0')) << "st_mm " << st_mm; } EXPECT_EQ(BytesToHexString(cpu_context_x86.fxsave.st_mm[7].st, - base::size(cpu_context_x86.fxsave.st_mm[7].st)), + std::size(cpu_context_x86.fxsave.st_mm[7].st)), "0000000000000080ff7f"); EXPECT_EQ(cpu_context_x86.dr0, 3u); diff --git a/snapshot/win/crashpad_snapshot_test_image_reader.cc b/snapshot/win/crashpad_snapshot_test_image_reader.cc index 94d0e47d..65c77831 100644 --- a/snapshot/win/crashpad_snapshot_test_image_reader.cc +++ b/snapshot/win/crashpad_snapshot_test_image_reader.cc @@ -14,7 +14,8 @@ #include -#include "base/cxx17_backports.h" +#include + #include "base/logging.h" #include "client/crashpad_info.h" #include "util/file/file_io.h" @@ -29,7 +30,7 @@ DWORD WINAPI LotsOfReferencesThreadProc(void* param) { // Allocate a bunch of pointers to things on the stack. int* pointers[1000]; - for (size_t i = 0; i < base::size(pointers); ++i) { + for (size_t i = 0; i < std::size(pointers); ++i) { pointers[i] = new int[2048]; } @@ -53,7 +54,7 @@ int wmain(int argc, wchar_t* argv[]) { // verify the cap on pointed-to memory. crashpad::Semaphore semaphore(0); crashpad::ScopedKernelHANDLE threads[100]; - for (size_t i = 0; i < base::size(threads); ++i) { + for (size_t i = 0; i < std::size(threads); ++i) { threads[i].reset(CreateThread(nullptr, 0, &LotsOfReferencesThreadProc, @@ -66,7 +67,7 @@ int wmain(int argc, wchar_t* argv[]) { } } - for (size_t i = 0; i < base::size(threads); ++i) { + for (size_t i = 0; i < std::size(threads); ++i) { semaphore.Wait(); } diff --git a/snapshot/win/pe_image_annotations_reader.cc b/snapshot/win/pe_image_annotations_reader.cc index 494b3398..9130e6d4 100644 --- a/snapshot/win/pe_image_annotations_reader.cc +++ b/snapshot/win/pe_image_annotations_reader.cc @@ -17,7 +17,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/logging.h" #include "base/strings/utf_string_conversions.h" #include "client/annotation.h" @@ -157,8 +158,7 @@ void PEImageAnnotationsReader::ReadCrashpadAnnotationsList( snapshot.type = current.type; char name[Annotation::kNameMaxLength]; - if (!process_reader_->Memory()->Read( - current.name, base::size(name), name)) { + if (!process_reader_->Memory()->Read(current.name, std::size(name), name)) { LOG(WARNING) << "could not read annotation name at index " << index << " in " << base::WideToUTF8(name_); continue; diff --git a/snapshot/win/pe_image_reader.cc b/snapshot/win/pe_image_reader.cc index bc4511b3..2a7b1510 100644 --- a/snapshot/win/pe_image_reader.cc +++ b/snapshot/win/pe_image_reader.cc @@ -18,9 +18,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/strings/stringprintf.h" #include "client/crashpad_info.h" @@ -288,7 +288,7 @@ bool PEImageReader::VSFixedFileInfo( version_info.wType != 0 || wcsncmp(version_info.szKey, L"VS_VERSION_INFO", - base::size(version_info.szKey)) != 0) { + std::size(version_info.szKey)) != 0) { LOG(WARNING) << "unexpected VS_VERSIONINFO in " << module_subrange_reader_.name(); return false; diff --git a/snapshot/win/process_reader_win_test.cc b/snapshot/win/process_reader_win_test.cc index 68933bbe..709e56b2 100644 --- a/snapshot/win/process_reader_win_test.cc +++ b/snapshot/win/process_reader_win_test.cc @@ -17,7 +17,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "gtest/gtest.h" #include "test/win/win_multiprocess.h" #include "util/misc/from_pointer_cast.h" @@ -44,7 +45,7 @@ TEST(ProcessReaderWin, SelfBasic) { EXPECT_EQ(process_reader.GetProcessInfo().ProcessID(), GetCurrentProcessId()); static constexpr char kTestMemory[] = "Some test memory"; - char buffer[base::size(kTestMemory)]; + char buffer[std::size(kTestMemory)]; ASSERT_TRUE(process_reader.Memory()->Read( reinterpret_cast(kTestMemory), sizeof(kTestMemory), &buffer)); EXPECT_STREQ(kTestMemory, buffer); @@ -193,7 +194,7 @@ class ProcessReaderChildThreadSuspendCount final : public WinMultiprocess { // the pipe. CheckedReadFileAtEOF(ReadPipeHandle()); - for (size_t i = 0; i < base::size(threads); ++i) + for (size_t i = 0; i < std::size(threads); ++i) done.Signal(); for (auto& thread : threads) thread.Join(); diff --git a/snapshot/win/process_snapshot_win.cc b/snapshot/win/process_snapshot_win.cc index fee843c7..f1a20b5d 100644 --- a/snapshot/win/process_snapshot_win.cc +++ b/snapshot/win/process_snapshot_win.cc @@ -18,9 +18,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/numerics/safe_conversions.h" #include "base/strings/utf_string_conversions.h" @@ -332,7 +332,7 @@ void ProcessSnapshotWin::InitializeUnloadedModules() { uet.TimeDateStamp, base::WideToUTF8(base::WStringPiece( uet.ImageName, - wcsnlen(uet.ImageName, base::size(uet.ImageName)))))); + wcsnlen(uet.ImageName, std::size(uet.ImageName)))))); } } } @@ -532,9 +532,9 @@ WinVMSize ProcessSnapshotWin::DetermineSizeOfEnvironmentBlock( env_block.resize( static_cast(bytes_read / sizeof(env_block[0]))); static constexpr wchar_t terminator[] = {0, 0}; - size_t at = env_block.find(std::wstring(terminator, base::size(terminator))); + size_t at = env_block.find(std::wstring(terminator, std::size(terminator))); if (at != std::wstring::npos) - env_block.resize(at + base::size(terminator)); + env_block.resize(at + std::size(terminator)); return env_block.size() * sizeof(env_block[0]); } diff --git a/test/hex_string.h b/test/hex_string.h index b0d44531..be0143b7 100644 --- a/test/hex_string.h +++ b/test/hex_string.h @@ -29,8 +29,8 @@ namespace test { //! uint8_t expected[10]; //! uint8_t observed[10]; //! // … -//! EXPECT_EQ(BytesToHexString(observed, base::size(observed)), -//! BytesToHexString(expected, base::size(expected))); +//! EXPECT_EQ(BytesToHexString(observed, std::size(observed)), +//! BytesToHexString(expected, std::size(expected))); //! \endcode std::string BytesToHexString(const void* bytes, size_t length); diff --git a/test/hex_string_test.cc b/test/hex_string_test.cc index ac6343bf..13aa311a 100644 --- a/test/hex_string_test.cc +++ b/test/hex_string_test.cc @@ -14,7 +14,8 @@ #include "test/hex_string.h" -#include "base/cxx17_backports.h" +#include + #include "gtest/gtest.h" namespace crashpad { @@ -25,7 +26,7 @@ TEST(HexString, HexString) { EXPECT_EQ(BytesToHexString(nullptr, 0), ""); static constexpr char kBytes[] = "Abc123xyz \x0a\x7f\xf0\x9f\x92\xa9_"; - EXPECT_EQ(BytesToHexString(kBytes, base::size(kBytes)), + EXPECT_EQ(BytesToHexString(kBytes, std::size(kBytes)), "41626331323378797a200a7ff09f92a95f00"); } diff --git a/tools/crashpad_database_util.cc b/tools/crashpad_database_util.cc index bbe6f7dd..d5593777 100644 --- a/tools/crashpad_database_util.cc +++ b/tools/crashpad_database_util.cc @@ -21,13 +21,13 @@ #include #include +#include #include #include #include #include #include "base/check_op.h" -#include "base/cxx17_backports.h" #include "base/files/file_path.h" #include "base/numerics/safe_conversions.h" #include "base/strings/utf_string_conversions.h" @@ -111,14 +111,14 @@ bool StringToBool(const char* string, bool* boolean) { "set", }; - for (size_t index = 0; index < base::size(kFalseWords); ++index) { + for (size_t index = 0; index < std::size(kFalseWords); ++index) { if (strcasecmp(string, kFalseWords[index]) == 0) { *boolean = false; return true; } } - for (size_t index = 0; index < base::size(kTrueWords); ++index) { + for (size_t index = 0; index < std::size(kTrueWords); ++index) { if (strcasecmp(string, kTrueWords[index]) == 0) { *boolean = true; return true; @@ -161,7 +161,7 @@ bool StringToTime(const char* string, time_t* out_time, bool utc) { "%+", }; - for (size_t index = 0; index < base::size(kFormats); ++index) { + for (size_t index = 0; index < std::size(kFormats); ++index) { tm time_tm; const char* strptime_result = strptime(string, kFormats[index], &time_tm); if (strptime_result == end) { @@ -216,7 +216,7 @@ std::string TimeToString(time_t out_time, bool utc) { char string[64]; CHECK_NE( - strftime(string, base::size(string), "%Y-%m-%d %H:%M:%S %Z", &time_tm), + strftime(string, std::size(string), "%Y-%m-%d %H:%M:%S %Z", &time_tm), 0u); return std::string(string); diff --git a/util/file/delimited_file_reader.cc b/util/file/delimited_file_reader.cc index f899dbf3..015a09dc 100644 --- a/util/file/delimited_file_reader.cc +++ b/util/file/delimited_file_reader.cc @@ -17,10 +17,10 @@ #include #include +#include #include #include "base/check_op.h" -#include "base/cxx17_backports.h" #include "base/numerics/safe_conversions.h" namespace crashpad { @@ -76,7 +76,7 @@ DelimitedFileReader::Result DelimitedFileReader::GetDelim(char delimiter, return Result::kEndOfFile; } - DCHECK_LE(static_cast(read_result), base::size(buf_)); + DCHECK_LE(static_cast(read_result), std::size(buf_)); DCHECK( base::IsValueInRangeForNumericType(read_result)); buf_len_ = static_cast(read_result); diff --git a/util/file/delimited_file_reader_test.cc b/util/file/delimited_file_reader_test.cc index 05e61011..5cc1f0fc 100644 --- a/util/file/delimited_file_reader_test.cc +++ b/util/file/delimited_file_reader_test.cc @@ -14,9 +14,9 @@ #include "util/file/delimited_file_reader.h" +#include #include -#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" @@ -260,7 +260,7 @@ TEST(DelimitedFileReader, ReallyLongMultiLineFile) { TEST(DelimitedFileReader, EmbeddedNUL) { static constexpr char kString[] = "embedded\0NUL\n"; StringFile string_file; - string_file.SetString(std::string(kString, base::size(kString) - 1)); + string_file.SetString(std::string(kString, std::size(kString) - 1)); DelimitedFileReader delimited_file_reader(&string_file); std::string line; @@ -278,7 +278,7 @@ TEST(DelimitedFileReader, EmbeddedNUL) { TEST(DelimitedFileReader, NULDelimiter) { static constexpr char kString[] = "aa\0b\0ccc\0"; StringFile string_file; - string_file.SetString(std::string(kString, base::size(kString) - 1)); + string_file.SetString(std::string(kString, std::size(kString) - 1)); DelimitedFileReader delimited_file_reader(&string_file); std::string field; @@ -302,7 +302,7 @@ TEST(DelimitedFileReader, NULDelimiter) { TEST(DelimitedFileReader, EdgeCases) { static constexpr size_t kSizes[] = {4094, 4095, 4096, 4097, 8190, 8191, 8192, 8193}; - for (size_t index = 0; index < base::size(kSizes); ++index) { + for (size_t index = 0; index < std::size(kSizes); ++index) { size_t size = kSizes[index]; SCOPED_TRACE( base::StringPrintf("index %" PRIuS ", size %" PRIuS, index, size)); diff --git a/util/file/file_io_test.cc b/util/file/file_io_test.cc index f970e356..2d45cfb6 100644 --- a/util/file/file_io_test.cc +++ b/util/file/file_io_test.cc @@ -16,11 +16,11 @@ #include +#include #include #include #include "base/atomicops.h" -#include "base/cxx17_backports.h" #include "base/files/file_path.h" #include "build/build_config.h" #include "gmock/gmock.h" @@ -643,7 +643,7 @@ void LockingTest(FileLocking main_lock, FileLocking other_locks) { LockingTestThread threads[20]; int expected_iterations = 0; - for (size_t index = 0; index < base::size(threads); ++index) { + for (size_t index = 0; index < std::size(threads); ++index) { int iterations_for_this_thread = static_cast(index * 10); threads[index].Init( (other_locks == FileLocking::kShared) diff --git a/util/linux/proc_stat_reader.cc b/util/linux/proc_stat_reader.cc index 878103d9..04d47f5e 100644 --- a/util/linux/proc_stat_reader.cc +++ b/util/linux/proc_stat_reader.cc @@ -18,7 +18,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/files/file_path.h" #include "base/logging.h" #include "util/file/file_io.h" @@ -48,7 +49,7 @@ bool ProcStatReader::Initialize(PtraceConnection* connection, pid_t tid) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); char path[32]; - snprintf(path, base::size(path), "/proc/%d/stat", tid); + snprintf(path, std::size(path), "/proc/%d/stat", tid); if (!connection->ReadFileContents(base::FilePath(path), &contents_)) { return false; } diff --git a/util/linux/proc_task_reader.cc b/util/linux/proc_task_reader.cc index ca62db27..0d2fb90b 100644 --- a/util/linux/proc_task_reader.cc +++ b/util/linux/proc_task_reader.cc @@ -16,7 +16,8 @@ #include -#include "base/cxx17_backports.h" +#include + #include "base/files/file_path.h" #include "base/logging.h" #include "base/strings/string_number_conversions.h" @@ -29,7 +30,7 @@ bool ReadThreadIDs(pid_t pid, std::vector* tids) { DCHECK(tids->empty()); char path[32]; - snprintf(path, base::size(path), "/proc/%d/task", pid); + snprintf(path, std::size(path), "/proc/%d/task", pid); DirectoryReader reader; if (!reader.Open(base::FilePath(path))) { return false; diff --git a/util/linux/ptrace_client.cc b/util/linux/ptrace_client.cc index 9a34722a..1863841f 100644 --- a/util/linux/ptrace_client.cc +++ b/util/linux/ptrace_client.cc @@ -18,9 +18,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/strings/string_number_conversions.h" #include "util/file/file_io.h" @@ -265,7 +265,7 @@ bool PtraceClient::Threads(std::vector* threads) { threads->push_back(pid_); char path[32]; - snprintf(path, base::size(path), "/proc/%d/task", pid_); + snprintf(path, std::size(path), "/proc/%d/task", pid_); PtraceBroker::Request request = {}; request.type = PtraceBroker::Request::kTypeListDirectory; diff --git a/util/mac/checked_mach_address_range_test.cc b/util/mac/checked_mach_address_range_test.cc index 4ef26fd9..7f26d255 100644 --- a/util/mac/checked_mach_address_range_test.cc +++ b/util/mac/checked_mach_address_range_test.cc @@ -17,9 +17,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/strings/stringprintf.h" #include "build/build_config.h" #include "gtest/gtest.h" @@ -116,7 +116,7 @@ TEST(CheckedMachAddressRange, IsValid) { {0xffffffffffffffff, 1, kInvalid}, }; - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { const auto& testcase = kTestData[index]; SCOPED_TRACE(base::StringPrintf("index %zu, base 0x%llx, size 0x%llx", index, @@ -166,7 +166,7 @@ TEST(CheckedMachAddressRange, ContainsValue) { CheckedMachAddressRange parent_range_32(false, 0x2000, 0x1000); ASSERT_TRUE(parent_range_32.IsValid()); - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { const auto& testcase = kTestData[index]; SCOPED_TRACE( base::StringPrintf("index %zu, value 0x%llx", index, testcase.value)); @@ -223,7 +223,7 @@ TEST(CheckedMachAddressRange, ContainsRange) { CheckedMachAddressRange parent_range_32(false, 0x2000, 0x1000); ASSERT_TRUE(parent_range_32.IsValid()); - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { const auto& testcase = kTestData[index]; SCOPED_TRACE(base::StringPrintf("index %zu, base 0x%llx, size 0x%llx", index, diff --git a/util/mac/launchd_test.mm b/util/mac/launchd_test.mm index 2e49ee66..21920598 100644 --- a/util/mac/launchd_test.mm +++ b/util/mac/launchd_test.mm @@ -20,9 +20,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/mac/scoped_launch_data.h" #include "gtest/gtest.h" #include "util/stdlib/objc.h" @@ -58,7 +58,7 @@ TEST(Launchd, CFPropertyToLaunchData_Integer) { @0xfedcba9876543210, }; - for (size_t index = 0; index < base::size(integer_nses); ++index) { + for (size_t index = 0; index < std::size(integer_nses); ++index) { NSNumber* integer_ns = integer_nses[index]; launch_data.reset(CFPropertyToLaunchData(integer_ns)); ASSERT_TRUE(launch_data.get()); @@ -88,7 +88,7 @@ TEST(Launchd, CFPropertyToLaunchData_FloatingPoint) { @(std::numeric_limits::signaling_NaN()), }; - for (size_t index = 0; index < base::size(double_nses); ++index) { + for (size_t index = 0; index < std::size(double_nses); ++index) { NSNumber* double_ns = double_nses[index]; launch_data.reset(CFPropertyToLaunchData(double_ns)); ASSERT_TRUE(launch_data.get()); @@ -114,7 +114,7 @@ TEST(Launchd, CFPropertyToLaunchData_Boolean) { @YES, }; - for (size_t index = 0; index < base::size(bool_nses); ++index) { + for (size_t index = 0; index < std::size(bool_nses); ++index) { NSNumber* bool_ns = bool_nses[index]; launch_data.reset(CFPropertyToLaunchData(bool_ns)); ASSERT_TRUE(launch_data.get()); @@ -138,7 +138,7 @@ TEST(Launchd, CFPropertyToLaunchData_String) { @"Üñîçø∂é", }; - for (size_t index = 0; index < base::size(string_nses); ++index) { + for (size_t index = 0; index < std::size(string_nses); ++index) { NSString* string_ns = string_nses[index]; launch_data.reset(CFPropertyToLaunchData(string_ns)); ASSERT_TRUE(launch_data.get()); diff --git a/util/mach/child_port_handshake.cc b/util/mach/child_port_handshake.cc index 28fdbae6..d0e58030 100644 --- a/util/mach/child_port_handshake.cc +++ b/util/mach/child_port_handshake.cc @@ -24,10 +24,10 @@ #include #include +#include #include #include "base/check_op.h" -#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/mac/mach_logging.h" #include "base/mac/scoped_mach_port.h" @@ -167,8 +167,8 @@ mach_port_t ChildPortHandshakeServer::RunServer( 0, 0, nullptr); - int rv = HANDLE_EINTR(kevent( - kq.get(), changelist, base::size(changelist), nullptr, 0, nullptr)); + int rv = HANDLE_EINTR( + kevent(kq.get(), changelist, std::size(changelist), nullptr, 0, nullptr)); PCHECK(rv != -1) << "kevent"; ChildPortServer child_port_server(this); diff --git a/util/mach/child_port_server.cc b/util/mach/child_port_server.cc index 92734294..9323723c 100644 --- a/util/mach/child_port_server.cc +++ b/util/mach/child_port_server.cc @@ -14,7 +14,8 @@ #include "util/mach/child_port_server.h" -#include "base/cxx17_backports.h" +#include + #include "util/mach/child_portServer.h" #include "util/mach/mach_message.h" @@ -90,7 +91,7 @@ std::set ChildPortServer::MachMessageServerRequestIDs() { static constexpr mach_msg_id_t request_ids[] = {kMachMessageIDChildPortCheckIn}; return std::set(&request_ids[0], - &request_ids[base::size(request_ids)]); + &request_ids[std::size(request_ids)]); } mach_msg_size_t ChildPortServer::MachMessageServerRequestSize() { diff --git a/util/mach/composite_mach_message_server_test.cc b/util/mach/composite_mach_message_server_test.cc index 91a3851f..36fd6ac0 100644 --- a/util/mach/composite_mach_message_server_test.cc +++ b/util/mach/composite_mach_message_server_test.cc @@ -16,7 +16,8 @@ #include -#include "base/cxx17_backports.h" +#include + #include "base/strings/stringprintf.h" #include "gtest/gtest.h" #include "test/gtest_death.h" @@ -198,7 +199,7 @@ TEST(CompositeMachMessageServer, ThreeHandlers) { TestMachMessageHandler handlers[3]; std::set expect_request_ids; - for (size_t index = 0; index < base::size(kRequestIDs0); ++index) { + for (size_t index = 0; index < std::size(kRequestIDs0); ++index) { const mach_msg_id_t request_id = kRequestIDs0[index]; handlers[0].AddRequestID(request_id); expect_request_ids.insert(request_id); @@ -207,7 +208,7 @@ TEST(CompositeMachMessageServer, ThreeHandlers) { handlers[0].SetReplySize(sizeof(mig_reply_error_t)); handlers[0].SetReturnCodes(true, kReturnCode0, false); - for (size_t index = 0; index < base::size(kRequestIDs1); ++index) { + for (size_t index = 0; index < std::size(kRequestIDs1); ++index) { const mach_msg_id_t request_id = kRequestIDs1[index]; handlers[1].AddRequestID(request_id); expect_request_ids.insert(request_id); @@ -216,7 +217,7 @@ TEST(CompositeMachMessageServer, ThreeHandlers) { handlers[1].SetReplySize(200); handlers[1].SetReturnCodes(false, kReturnCode1, true); - for (size_t index = 0; index < base::size(kRequestIDs2); ++index) { + for (size_t index = 0; index < std::size(kRequestIDs2); ++index) { const mach_msg_id_t request_id = kRequestIDs2[index]; handlers[2].AddRequestID(request_id); expect_request_ids.insert(request_id); @@ -254,7 +255,7 @@ TEST(CompositeMachMessageServer, ThreeHandlers) { // Send messages with known request IDs. - for (size_t index = 0; index < base::size(kRequestIDs0); ++index) { + for (size_t index = 0; index < std::size(kRequestIDs0); ++index) { request.header.msgh_id = kRequestIDs0[index]; SCOPED_TRACE(base::StringPrintf( "handler 0, index %zu, id %d", index, request.header.msgh_id)); @@ -265,7 +266,7 @@ TEST(CompositeMachMessageServer, ThreeHandlers) { EXPECT_FALSE(destroy_complex_request); } - for (size_t index = 0; index < base::size(kRequestIDs1); ++index) { + for (size_t index = 0; index < std::size(kRequestIDs1); ++index) { request.header.msgh_id = kRequestIDs1[index]; SCOPED_TRACE(base::StringPrintf( "handler 1, index %zu, id %d", index, request.header.msgh_id)); @@ -276,7 +277,7 @@ TEST(CompositeMachMessageServer, ThreeHandlers) { EXPECT_TRUE(destroy_complex_request); } - for (size_t index = 0; index < base::size(kRequestIDs2); ++index) { + for (size_t index = 0; index < std::size(kRequestIDs2); ++index) { request.header.msgh_id = kRequestIDs2[index]; SCOPED_TRACE(base::StringPrintf( "handler 2, index %zu, id %d", index, request.header.msgh_id)); diff --git a/util/mach/exc_client_variants_test.cc b/util/mach/exc_client_variants_test.cc index aba72052..700eb5f8 100644 --- a/util/mach/exc_client_variants_test.cc +++ b/util/mach/exc_client_variants_test.cc @@ -19,7 +19,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/strings/stringprintf.h" #include "gtest/gtest.h" #include "test/mac/mach_errors.h" @@ -184,11 +185,11 @@ class TestExcClientVariants : public MachMultiprocess, // These aren’t real flavors, it’s just for testing. flavor = exception_ + 10; flavor_p = &flavor; - for (size_t index = 0; index < base::size(old_state); ++index) { + for (size_t index = 0; index < std::size(old_state); ++index) { old_state[index] = index; } old_state_p = reinterpret_cast(&old_state); - old_state_count = base::size(old_state); + old_state_count = std::size(old_state); // new_state and new_state_count are out parameters that the server should // never see or use, so set them to bogus values. The call to the server @@ -205,7 +206,7 @@ class TestExcClientVariants : public MachMultiprocess, task, exception, code, - base::size(code), + std::size(code), flavor_p, old_state_p, old_state_count, @@ -274,7 +275,7 @@ TEST(ExcClientVariants, UniversalExceptionRaise) { kMachExceptionCodes | EXCEPTION_STATE_IDENTITY, }; - for (size_t index = 0; index < base::size(kBehaviors); ++index) { + for (size_t index = 0; index < std::size(kBehaviors); ++index) { exception_behavior_t behavior = kBehaviors[index]; SCOPED_TRACE(base::StringPrintf("index %zu, behavior %d", index, behavior)); diff --git a/util/mach/exc_server_variants.cc b/util/mach/exc_server_variants.cc index 9d36f3b0..2941cb29 100644 --- a/util/mach/exc_server_variants.cc +++ b/util/mach/exc_server_variants.cc @@ -18,9 +18,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "build/build_config.h" #include "util/mac/mac_util.h" #include "util/mach/composite_mach_message_server.h" @@ -246,7 +246,7 @@ class ExcServer : public MachMessageServer::Interface { Traits::kMachMessageIDExceptionRaiseStateIdentity, }; return std::set(&request_ids[0], - &request_ids[base::size(request_ids)]); + &request_ids[std::size(request_ids)]); } mach_msg_size_t MachMessageServerRequestSize() override { @@ -321,7 +321,7 @@ bool ExcServer::MachMessageServerFunction( using Reply = typename Traits::ExceptionRaiseStateReply; Reply* out_reply = reinterpret_cast(out_header); out_reply->flavor = in_request_1->flavor; - out_reply->new_stateCnt = base::size(out_reply->new_state); + out_reply->new_stateCnt = std::size(out_reply->new_state); out_reply->RetCode = interface_->CatchExceptionRaiseState(in_header->msgh_local_port, in_request->exception, @@ -364,7 +364,7 @@ bool ExcServer::MachMessageServerFunction( using Reply = typename Traits::ExceptionRaiseStateIdentityReply; Reply* out_reply = reinterpret_cast(out_header); out_reply->flavor = in_request_1->flavor; - out_reply->new_stateCnt = base::size(out_reply->new_state); + out_reply->new_stateCnt = std::size(out_reply->new_state); out_reply->RetCode = interface_->CatchExceptionRaiseStateIdentity( in_header->msgh_local_port, in_request->thread.name, diff --git a/util/mach/exc_server_variants_test.cc b/util/mach/exc_server_variants_test.cc index f5be0ea0..b0fcef09 100644 --- a/util/mach/exc_server_variants_test.cc +++ b/util/mach/exc_server_variants_test.cc @@ -19,7 +19,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/strings/stringprintf.h" #include "build/build_config.h" #include "gmock/gmock.h" @@ -232,7 +233,7 @@ struct __attribute__((packed, aligned(4))) ExceptionRaiseStateReply { EXPECT_EQ(memcmp(&NDR, &NDR_record, sizeof(NDR)), 0); EXPECT_EQ(RetCode, KERN_SUCCESS); EXPECT_EQ(flavor, kThreadStateFlavor); - EXPECT_EQ(new_stateCnt, base::size(new_state)); + EXPECT_EQ(new_stateCnt, std::size(new_state)); } mach_msg_header_t Head; @@ -664,7 +665,7 @@ TEST(ExcServerVariants, MockExceptionRaiseState) { AreExceptionCodes(kTestExceptonCodes[0], kTestExceptonCodes[1]), Pointee(Eq(kThreadStateFlavor)), IsThreadStateAndCount(kThreadStateFlavorCount), - IsThreadStateAndCount(base::size(reply.new_state)), + IsThreadStateAndCount(std::size(reply.new_state)), Eq(request.Trailer()))) .WillOnce(Return(KERN_SUCCESS)) .RetiresOnSaturation(); @@ -713,7 +714,7 @@ TEST(ExcServerVariants, MockExceptionRaiseStateIdentity) { AreExceptionCodes(kTestExceptonCodes[0], kTestExceptonCodes[1]), Pointee(Eq(kThreadStateFlavor)), IsThreadStateAndCount(kThreadStateFlavorCount), - IsThreadStateAndCount(base::size(reply.new_state)), + IsThreadStateAndCount(std::size(reply.new_state)), Eq(request.Trailer()))) .WillOnce(Return(KERN_SUCCESS)) .RetiresOnSaturation(); @@ -807,7 +808,7 @@ TEST(ExcServerVariants, MockMachExceptionRaiseState) { kTestMachExceptionCodes[1]), Pointee(Eq(kThreadStateFlavor)), IsThreadStateAndCount(kThreadStateFlavorCount), - IsThreadStateAndCount(base::size(reply.new_state)), + IsThreadStateAndCount(std::size(reply.new_state)), Eq(request.Trailer()))) .WillOnce(Return(KERN_SUCCESS)) .RetiresOnSaturation(); @@ -857,7 +858,7 @@ TEST(ExcServerVariants, MockMachExceptionRaiseStateIdentity) { kTestMachExceptionCodes[1]), Pointee(Eq(kThreadStateFlavor)), IsThreadStateAndCount(kThreadStateFlavorCount), - IsThreadStateAndCount(base::size(reply.new_state)), + IsThreadStateAndCount(std::size(reply.new_state)), Eq(request.Trailer()))) .WillOnce(Return(KERN_SUCCESS)) .RetiresOnSaturation(); @@ -911,7 +912,7 @@ TEST(ExcServerVariants, MockUnknownID) { 2508, }; - for (size_t index = 0; index < base::size(unknown_ids); ++index) { + for (size_t index = 0; index < std::size(unknown_ids); ++index) { mach_msg_id_t id = unknown_ids[index]; SCOPED_TRACE(base::StringPrintf("unknown id %d", id)); @@ -1190,7 +1191,7 @@ TEST(ExcServerVariants, ThreadStates) { #endif }; - for (size_t index = 0; index < base::size(test_data); ++index) { + for (size_t index = 0; index < std::size(test_data); ++index) { const auto& test = test_data[index]; SCOPED_TRACE( base::StringPrintf("index %zu, flavor %d", index, test.flavor)); @@ -1270,7 +1271,7 @@ TEST(ExcServerVariants, ExcServerSuccessfulReturnValue) { KERN_SUCCESS}, }; - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { const auto& test_data = kTestData[index]; SCOPED_TRACE( base::StringPrintf("index %zu, behavior %d, set_thread_state %s", @@ -1289,8 +1290,8 @@ TEST(ExcServerVariants, ExcServerCopyState) { static constexpr natural_t old_state[] = {1, 2, 3, 4, 5}; natural_t new_state[10] = {}; - constexpr mach_msg_type_number_t old_state_count = base::size(old_state); - mach_msg_type_number_t new_state_count = base::size(new_state); + constexpr mach_msg_type_number_t old_state_count = std::size(old_state); + mach_msg_type_number_t new_state_count = std::size(new_state); // EXCEPTION_DEFAULT (with or without MACH_EXCEPTION_CODES) is not // state-carrying. new_state and new_state_count should be untouched. @@ -1299,8 +1300,8 @@ TEST(ExcServerVariants, ExcServerCopyState) { old_state_count, new_state, &new_state_count); - EXPECT_EQ(new_state_count, base::size(new_state)); - for (size_t i = 0; i < base::size(new_state); ++i) { + EXPECT_EQ(new_state_count, std::size(new_state)); + for (size_t i = 0; i < std::size(new_state); ++i) { EXPECT_EQ(new_state[i], 0u) << "i " << i; } @@ -1309,8 +1310,8 @@ TEST(ExcServerVariants, ExcServerCopyState) { old_state_count, new_state, &new_state_count); - EXPECT_EQ(new_state_count, base::size(new_state)); - for (size_t i = 0; i < base::size(new_state); ++i) { + EXPECT_EQ(new_state_count, std::size(new_state)); + for (size_t i = 0; i < std::size(new_state); ++i) { EXPECT_EQ(new_state[i], 0u) << "i " << i; } @@ -1322,7 +1323,7 @@ TEST(ExcServerVariants, ExcServerCopyState) { for (size_t i = 0; i < copy_limit; ++i) { EXPECT_EQ(new_state[i], old_state[i]) << "i " << i; } - for (size_t i = copy_limit; i < base::size(new_state); ++i) { + for (size_t i = copy_limit; i < std::size(new_state); ++i) { EXPECT_EQ(new_state[i], 0u) << "i " << i; } @@ -1338,23 +1339,23 @@ TEST(ExcServerVariants, ExcServerCopyState) { for (size_t i = 0; i < copy_limit; ++i) { EXPECT_EQ(new_state[i], old_state[i]) << "i " << i; } - for (size_t i = copy_limit; i < base::size(new_state); ++i) { + for (size_t i = copy_limit; i < std::size(new_state); ++i) { EXPECT_EQ(new_state[i], 0u) << "i " << i; } // This is a state-carrying exception where all of old_state is copied to // new_state, which is large enough to receive it and then some. - new_state_count = base::size(new_state); + new_state_count = std::size(new_state); ExcServerCopyState(MACH_EXCEPTION_CODES | EXCEPTION_STATE_IDENTITY, old_state, old_state_count, new_state, &new_state_count); EXPECT_EQ(new_state_count, old_state_count); - for (size_t i = 0; i < base::size(old_state); ++i) { + for (size_t i = 0; i < std::size(old_state); ++i) { EXPECT_EQ(new_state[i], old_state[i]) << "i " << i; } - for (size_t i = base::size(old_state); i < base::size(new_state); ++i) { + for (size_t i = std::size(old_state); i < std::size(new_state); ++i) { EXPECT_EQ(new_state[i], 0u) << "i " << i; } } diff --git a/util/mach/exception_behaviors_test.cc b/util/mach/exception_behaviors_test.cc index e6abd25f..8e3d0f4b 100644 --- a/util/mach/exception_behaviors_test.cc +++ b/util/mach/exception_behaviors_test.cc @@ -16,7 +16,8 @@ #include -#include "base/cxx17_backports.h" +#include + #include "base/strings/stringprintf.h" #include "gtest/gtest.h" #include "util/mach/mach_extensions.h" @@ -53,7 +54,7 @@ TEST(ExceptionBehaviors, ExceptionBehaviors) { EXCEPTION_STATE_IDENTITY}, }; - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { const auto& test_data = kTestData[index]; SCOPED_TRACE(base::StringPrintf( "index %zu, behavior %d", index, test_data.behavior)); diff --git a/util/mach/exception_types_test.cc b/util/mach/exception_types_test.cc index 3e777ef2..fb095fab 100644 --- a/util/mach/exception_types_test.cc +++ b/util/mach/exception_types_test.cc @@ -20,7 +20,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/strings/stringprintf.h" #include "build/build_config.h" #include "gtest/gtest.h" @@ -71,7 +72,7 @@ TEST(ExceptionTypes, ExcCrashRecoverOriginalException) { // TODO(macos_arm64): Add arm64 test data. }; - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { const auto& test_data = kTestData[index]; SCOPED_TRACE(base::StringPrintf( "index %zu, code_0 0x%llx", index, test_data.code_0)); @@ -88,7 +89,7 @@ TEST(ExceptionTypes, ExcCrashRecoverOriginalException) { // Now make sure that ExcCrashRecoverOriginalException() properly ignores // optional arguments. - static_assert(base::size(kTestData) >= 1, "must have something to test"); + static_assert(std::size(kTestData) >= 1, "must have something to test"); const auto& test_data = kTestData[0]; EXPECT_EQ( ExcCrashRecoverOriginalException(test_data.code_0, nullptr, nullptr), @@ -248,7 +249,7 @@ TEST(ExceptionTypes, ExceptionCodeForMetrics) { {0x00010000, 0x00010000, static_cast(0xffffffff)}, }; - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { const auto& test_data = kTestData[index]; SCOPED_TRACE(base::StringPrintf("index %zu, exception 0x%x, code_0 0x%llx", index, diff --git a/util/mach/mach_message_server_test.cc b/util/mach/mach_message_server_test.cc index 6785827b..51a0b4ca 100644 --- a/util/mach/mach_message_server_test.cc +++ b/util/mach/mach_message_server_test.cc @@ -19,9 +19,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/mac/scoped_mach_port.h" #include "gtest/gtest.h" #include "test/mac/mach_errors.h" @@ -284,7 +284,7 @@ class TestMachMessageServer : public MachMessageServer::Interface, std::set MachMessageServerRequestIDs() override { static constexpr mach_msg_id_t request_ids[] = {kRequestMessageID}; return std::set(&request_ids[0], - &request_ids[base::size(request_ids)]); + &request_ids[std::size(request_ids)]); } mach_msg_size_t MachMessageServerRequestSize() override { diff --git a/util/mach/notify_server.cc b/util/mach/notify_server.cc index e625419e..b16c6fb3 100644 --- a/util/mach/notify_server.cc +++ b/util/mach/notify_server.cc @@ -14,7 +14,8 @@ #include "util/mach/notify_server.h" -#include "base/cxx17_backports.h" +#include + #include "util/mach/mach_message.h" #include "util/mach/notifyServer.h" @@ -227,7 +228,7 @@ std::set NotifyServer::MachMessageServerRequestIDs() { MACH_NOTIFY_DEAD_NAME, }; return std::set(&request_ids[0], - &request_ids[base::size(request_ids)]); + &request_ids[std::size(request_ids)]); } mach_msg_size_t NotifyServer::MachMessageServerRequestSize() { diff --git a/util/mach/symbolic_constants_mach.cc b/util/mach/symbolic_constants_mach.cc index 47090086..457a0ca2 100644 --- a/util/mach/symbolic_constants_mach.cc +++ b/util/mach/symbolic_constants_mach.cc @@ -17,7 +17,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/strings/stringprintf.h" #include "util/mach/exception_behaviors.h" #include "util/mach/mach_extensions.h" @@ -45,7 +46,7 @@ constexpr const char* kExceptionNames[] = { "GUARD", "CORPSE_NOTIFY", }; -static_assert(base::size(kExceptionNames) == EXC_TYPES_COUNT, +static_assert(std::size(kExceptionNames) == EXC_TYPES_COUNT, "kExceptionNames length"); constexpr char kExcPrefix[] = "EXC_"; @@ -170,7 +171,7 @@ std::string ThreadStateFlavorFullToShort(const base::StringPiece& flavor) { {"_STATE32", "32"}, {"_STATE64", "64"}, }; - for (size_t suffix_index = 0; suffix_index < base::size(kStateSuffixes); + for (size_t suffix_index = 0; suffix_index < std::size(kStateSuffixes); ++suffix_index) { const char* suffix = kStateSuffixes[suffix_index].orig; size_t suffix_len = strlen(suffix); @@ -194,7 +195,7 @@ namespace crashpad { std::string ExceptionToString(exception_type_t exception, SymbolicConstantToStringOptions options) { const char* exception_name = - implicit_cast(exception) < base::size(kExceptionNames) + implicit_cast(exception) < std::size(kExceptionNames) ? kExceptionNames[exception] : nullptr; if (!exception_name) { @@ -220,7 +221,7 @@ bool StringToException(const base::StringPiece& string, base::StringPiece short_string = can_match_full ? string.substr(strlen(kExcPrefix)) : string; for (exception_type_t index = 0; - index < implicit_cast(base::size(kExceptionNames)); + index < implicit_cast(std::size(kExceptionNames)); ++index) { const char* exception_name = kExceptionNames[index]; if (!exception_name) { @@ -250,7 +251,7 @@ std::string ExceptionMaskToString(exception_mask_t exception_mask, exception_mask_t local_exception_mask = exception_mask; std::string mask_string; bool has_forbidden_or = false; - for (size_t exception = 0; exception < base::size(kExceptionNames); + for (size_t exception = 0; exception < std::size(kExceptionNames); ++exception) { const char* exception_name = kExceptionNames[exception]; exception_mask_t exception_mask_value = 1 << exception; @@ -324,7 +325,7 @@ bool StringToExceptionMask(const base::StringPiece& string, base::StringPiece short_string = can_match_full ? string.substr(strlen(kExcMaskPrefix)) : string; for (exception_type_t index = 0; - index < implicit_cast(base::size(kExceptionNames)); + index < implicit_cast(std::size(kExceptionNames)); ++index) { const char* exception_name = kExceptionNames[index]; if (!exception_name) { @@ -363,7 +364,7 @@ std::string ExceptionBehaviorToString(exception_behavior_t behavior, const exception_behavior_t basic_behavior = ExceptionBehaviorBasic(behavior); const char* behavior_name = - implicit_cast(basic_behavior) < base::size(kBehaviorNames) + implicit_cast(basic_behavior) < std::size(kBehaviorNames) ? kBehaviorNames[basic_behavior] : nullptr; if (!behavior_name) { @@ -430,8 +431,7 @@ bool StringToExceptionBehavior(const base::StringPiece& string, base::StringPiece short_string = can_match_full ? sp.substr(strlen(kBehaviorPrefix)) : sp; for (exception_behavior_t index = 0; - index < - implicit_cast(base::size(kBehaviorNames)); + index < implicit_cast(std::size(kBehaviorNames)); ++index) { const char* behavior_name = kBehaviorNames[index]; if (!behavior_name) { @@ -467,13 +467,13 @@ bool StringToExceptionBehavior(const base::StringPiece& string, std::string ThreadStateFlavorToString(thread_state_flavor_t flavor, SymbolicConstantToStringOptions options) { const char* flavor_name = - implicit_cast(flavor) < base::size(kFlavorNames) + implicit_cast(flavor) < std::size(kFlavorNames) ? kFlavorNames[flavor] : nullptr; if (!flavor_name) { for (size_t generic_flavor_index = 0; - generic_flavor_index < base::size(kGenericFlavorNames); + generic_flavor_index < std::size(kGenericFlavorNames); ++generic_flavor_index) { if (flavor == kGenericFlavorNames[generic_flavor_index].flavor) { flavor_name = kGenericFlavorNames[generic_flavor_index].name; @@ -500,7 +500,7 @@ bool StringToThreadStateFlavor(const base::StringPiece& string, thread_state_flavor_t* flavor) { if ((options & kAllowFullName) || (options & kAllowShortName)) { for (thread_state_flavor_t index = 0; - index < implicit_cast(base::size(kFlavorNames)); + index < implicit_cast(std::size(kFlavorNames)); ++index) { const char* flavor_name = kFlavorNames[index]; if (!flavor_name) { @@ -520,7 +520,7 @@ bool StringToThreadStateFlavor(const base::StringPiece& string, } for (size_t generic_flavor_index = 0; - generic_flavor_index < base::size(kGenericFlavorNames); + generic_flavor_index < std::size(kGenericFlavorNames); ++generic_flavor_index) { const char* flavor_name = kGenericFlavorNames[generic_flavor_index].name; thread_state_flavor_t flavor_number = diff --git a/util/mach/symbolic_constants_mach_test.cc b/util/mach/symbolic_constants_mach_test.cc index 20c60a0e..614a45b5 100644 --- a/util/mach/symbolic_constants_mach_test.cc +++ b/util/mach/symbolic_constants_mach_test.cc @@ -18,7 +18,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/strings/string_piece.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" @@ -26,7 +27,7 @@ #include "util/misc/implicit_cast.h" #define NUL_TEST_DATA(string) \ - { string, base::size(string) - 1 } + { string, std::size(string) - 1 } namespace crashpad { namespace test { @@ -160,7 +161,7 @@ void TestExceptionToString(exception_type_t value, } TEST(SymbolicConstantsMach, ExceptionToString) { - for (size_t index = 0; index < base::size(kExceptionTestData); ++index) { + for (size_t index = 0; index < std::size(kExceptionTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); TestExceptionToString(kExceptionTestData[index].exception, kExceptionTestData[index].full_name, @@ -188,11 +189,11 @@ void TestStringToException(const base::StringPiece& string, } TEST(SymbolicConstantsMach, StringToException) { - for (size_t option_index = 0; option_index < base::size(kNormalOptions); + for (size_t option_index = 0; option_index < std::size(kNormalOptions); ++option_index) { SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index)); StringToSymbolicConstantOptions options = kNormalOptions[option_index]; - for (size_t index = 0; index < base::size(kExceptionTestData); ++index) { + for (size_t index = 0; index < std::size(kExceptionTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); exception_type_t exception = kExceptionTestData[index].exception; { @@ -230,7 +231,7 @@ TEST(SymbolicConstantsMach, StringToException) { "", }; - for (size_t index = 0; index < base::size(kNegativeTestData); ++index) { + for (size_t index = 0; index < std::size(kNegativeTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); TestStringToException(kNegativeTestData[index], options, false, 0); } @@ -251,7 +252,7 @@ TEST(SymbolicConstantsMach, StringToException) { NUL_TEST_DATA("1\0002"), }; - for (size_t index = 0; index < base::size(kNULTestData); ++index) { + for (size_t index = 0; index < std::size(kNULTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); base::StringPiece string(kNULTestData[index].string, kNULTestData[index].length); @@ -334,7 +335,7 @@ void TestExceptionMaskToString(exception_mask_t value, } TEST(SymbolicConstantsMach, ExceptionMaskToString) { - for (size_t index = 0; index < base::size(kExceptionMaskTestData); ++index) { + for (size_t index = 0; index < std::size(kExceptionMaskTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); TestExceptionMaskToString(kExceptionMaskTestData[index].exception_mask, kExceptionMaskTestData[index].full_name, @@ -389,12 +390,11 @@ TEST(SymbolicConstantsMach, StringToExceptionMask) { kAllowFullName | kAllowShortName | kAllowNumber | kAllowOr, }; - for (size_t option_index = 0; option_index < base::size(kOptions); + for (size_t option_index = 0; option_index < std::size(kOptions); ++option_index) { SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index)); StringToSymbolicConstantOptions options = kOptions[option_index]; - for (size_t index = 0; index < base::size(kExceptionMaskTestData); - ++index) { + for (size_t index = 0; index < std::size(kExceptionMaskTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); exception_mask_t exception_mask = kExceptionMaskTestData[index].exception_mask; @@ -445,7 +445,7 @@ TEST(SymbolicConstantsMach, StringToExceptionMask) { "", }; - for (size_t index = 0; index < base::size(kNegativeTestData); ++index) { + for (size_t index = 0; index < std::size(kNegativeTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); TestStringToExceptionMask(kNegativeTestData[index], options, false, 0); } @@ -471,7 +471,7 @@ TEST(SymbolicConstantsMach, StringToExceptionMask) { NUL_TEST_DATA("ARITHMETIC|\0EMULATION"), }; - for (size_t index = 0; index < base::size(kNULTestData); ++index) { + for (size_t index = 0; index < std::size(kNULTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); base::StringPiece string(kNULTestData[index].string, kNULTestData[index].length); @@ -506,7 +506,7 @@ TEST(SymbolicConstantsMach, StringToExceptionMask) { EXC_MASK_SYSCALL | 0x100}, }; - for (size_t index = 0; index < base::size(kNonCanonicalTestData); ++index) { + for (size_t index = 0; index < std::size(kNonCanonicalTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); TestStringToExceptionMask(kNonCanonicalTestData[index].string, kNonCanonicalTestData[index].options, @@ -577,7 +577,7 @@ void TestExceptionBehaviorToString(exception_behavior_t value, } TEST(SymbolicConstantsMach, ExceptionBehaviorToString) { - for (size_t index = 0; index < base::size(kExceptionBehaviorTestData); + for (size_t index = 0; index < std::size(kExceptionBehaviorTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); TestExceptionBehaviorToString(kExceptionBehaviorTestData[index].behavior, @@ -607,11 +607,11 @@ void TestStringToExceptionBehavior(const base::StringPiece& string, } TEST(SymbolicConstantsMach, StringToExceptionBehavior) { - for (size_t option_index = 0; option_index < base::size(kNormalOptions); + for (size_t option_index = 0; option_index < std::size(kNormalOptions); ++option_index) { SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index)); StringToSymbolicConstantOptions options = kNormalOptions[option_index]; - for (size_t index = 0; index < base::size(kExceptionBehaviorTestData); + for (size_t index = 0; index < std::size(kExceptionBehaviorTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); exception_behavior_t behavior = @@ -657,7 +657,7 @@ TEST(SymbolicConstantsMach, StringToExceptionBehavior) { "", }; - for (size_t index = 0; index < base::size(kNegativeTestData); ++index) { + for (size_t index = 0; index < std::size(kNegativeTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); TestStringToExceptionBehavior( kNegativeTestData[index], options, false, 0); @@ -683,7 +683,7 @@ TEST(SymbolicConstantsMach, StringToExceptionBehavior) { NUL_TEST_DATA("STATE_IDENTITY|\0MACH"), }; - for (size_t index = 0; index < base::size(kNULTestData); ++index) { + for (size_t index = 0; index < std::size(kNULTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); base::StringPiece string(kNULTestData[index].string, kNULTestData[index].length); @@ -720,7 +720,7 @@ TEST(SymbolicConstantsMach, StringToExceptionBehavior) { implicit_cast(MACH_EXCEPTION_CODES | 0x2)}, }; - for (size_t index = 0; index < base::size(kNonCanonicalTestData); ++index) { + for (size_t index = 0; index < std::size(kNonCanonicalTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); TestStringToExceptionBehavior(kNonCanonicalTestData[index].string, kNonCanonicalTestData[index].options, @@ -837,7 +837,7 @@ void TestThreadStateFlavorToString(exception_type_t value, } TEST(SymbolicConstantsMach, ThreadStateFlavorToString) { - for (size_t index = 0; index < base::size(kThreadStateFlavorTestData); + for (size_t index = 0; index < std::size(kThreadStateFlavorTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); TestThreadStateFlavorToString(kThreadStateFlavorTestData[index].flavor, @@ -879,11 +879,11 @@ void TestStringToThreadStateFlavor(const base::StringPiece& string, } TEST(SymbolicConstantsMach, StringToThreadStateFlavor) { - for (size_t option_index = 0; option_index < base::size(kNormalOptions); + for (size_t option_index = 0; option_index < std::size(kNormalOptions); ++option_index) { SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index)); StringToSymbolicConstantOptions options = kNormalOptions[option_index]; - for (size_t index = 0; index < base::size(kThreadStateFlavorTestData); + for (size_t index = 0; index < std::size(kThreadStateFlavorTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); thread_state_flavor_t flavor = kThreadStateFlavorTestData[index].flavor; @@ -953,7 +953,7 @@ TEST(SymbolicConstantsMach, StringToThreadStateFlavor) { #endif }; - for (size_t index = 0; index < base::size(kNegativeTestData); ++index) { + for (size_t index = 0; index < std::size(kNegativeTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); TestStringToThreadStateFlavor( kNegativeTestData[index], options, false, 0); @@ -1019,7 +1019,7 @@ TEST(SymbolicConstantsMach, StringToThreadStateFlavor) { #endif }; - for (size_t index = 0; index < base::size(kNULTestData); ++index) { + for (size_t index = 0; index < std::size(kNULTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); base::StringPiece string(kNULTestData[index].string, kNULTestData[index].length); diff --git a/util/misc/arraysize.h b/util/misc/arraysize.h index 93a63882..63f49768 100644 --- a/util/misc/arraysize.h +++ b/util/misc/arraysize.h @@ -35,9 +35,9 @@ constexpr size_t ArraySizeHelper() noexcept { //! \brief A way of computing an array’s size. //! -//! Use this only where `base::size()` or `std::size()` won’t work, such as in -//! constant expressions (including `static_assert` expressions) that consider -//! the sizes of non-static data members. +//! Use this only where `std::size()` won’t work, such as in constant +//! expressions (including `static_assert` expressions) that consider the +//! sizes of non-static data members. #define ArraySize(array) crashpad::internal::ArraySizeHelper() #endif // CRASHPAD_UTIL_MISC_ARRAYSIZE_H_ diff --git a/util/misc/capture_context_test_util_win.cc b/util/misc/capture_context_test_util_win.cc index d1221956..dd9d9a68 100644 --- a/util/misc/capture_context_test_util_win.cc +++ b/util/misc/capture_context_test_util_win.cc @@ -13,10 +13,11 @@ // limitations under the License. #include "util/misc/capture_context_test_util.h" -#include "util/win/context_wrappers.h" -#include "base/cxx17_backports.h" +#include + #include "gtest/gtest.h" +#include "util/win/context_wrappers.h" namespace crashpad { namespace test { @@ -59,7 +60,7 @@ void SanityCheckContext(const NativeCPUContext& context) { #if defined(ARCH_CPU_X86) // fxsave doesn’t write these bytes. - for (size_t i = 464; i < base::size(context.ExtendedRegisters); ++i) { + for (size_t i = 464; i < std::size(context.ExtendedRegisters); ++i) { SCOPED_TRACE(i); EXPECT_EQ(context.ExtendedRegisters[i], 0); } @@ -69,7 +70,7 @@ void SanityCheckContext(const NativeCPUContext& context) { EXPECT_EQ(context.FltSave.MxCsr, context.MxCsr); // fxsave doesn’t write these bytes. - for (size_t i = 0; i < base::size(context.FltSave.Reserved4); ++i) { + for (size_t i = 0; i < std::size(context.FltSave.Reserved4); ++i) { SCOPED_TRACE(i); EXPECT_EQ(context.FltSave.Reserved4[i], 0); } @@ -81,7 +82,7 @@ void SanityCheckContext(const NativeCPUContext& context) { EXPECT_EQ(context.P4Home, 0u); EXPECT_EQ(context.P5Home, 0u); EXPECT_EQ(context.P6Home, 0u); - for (size_t i = 0; i < base::size(context.VectorRegister); ++i) { + for (size_t i = 0; i < std::size(context.VectorRegister); ++i) { SCOPED_TRACE(i); EXPECT_EQ(context.VectorRegister[i].Low, 0u); EXPECT_EQ(context.VectorRegister[i].High, 0u); diff --git a/util/misc/clock_test.cc b/util/misc/clock_test.cc index a1b1a4fa..8c43d02b 100644 --- a/util/misc/clock_test.cc +++ b/util/misc/clock_test.cc @@ -17,8 +17,8 @@ #include #include +#include -#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/strings/stringprintf.h" #include "build/build_config.h" @@ -83,7 +83,7 @@ TEST(Clock, SleepNanoseconds) { static_cast(5E7), // 50 milliseconds }; - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { const uint64_t nanoseconds = kTestData[index]; SCOPED_TRACE(base::StringPrintf( "index %zu, nanoseconds %" PRIu64, index, nanoseconds)); diff --git a/util/misc/paths_win.cc b/util/misc/paths_win.cc index 8510ccf9..9261718c 100644 --- a/util/misc/paths_win.cc +++ b/util/misc/paths_win.cc @@ -16,7 +16,8 @@ #include -#include "base/cxx17_backports.h" +#include + #include "base/logging.h" namespace crashpad { @@ -24,14 +25,12 @@ namespace crashpad { // static bool Paths::Executable(base::FilePath* path) { wchar_t executable_path[_MAX_PATH]; - unsigned int len = - GetModuleFileName(nullptr, - executable_path, - static_cast(base::size(executable_path))); + unsigned int len = GetModuleFileName( + nullptr, executable_path, static_cast(std::size(executable_path))); if (len == 0) { PLOG(ERROR) << "GetModuleFileName"; return false; - } else if (len >= base::size(executable_path)) { + } else if (len >= std::size(executable_path)) { LOG(ERROR) << "GetModuleFileName"; return false; } diff --git a/util/misc/random_string_test.cc b/util/misc/random_string_test.cc index fac830f3..15b3a414 100644 --- a/util/misc/random_string_test.cc +++ b/util/misc/random_string_test.cc @@ -16,9 +16,9 @@ #include +#include #include -#include "base/cxx17_backports.h" #include "gtest/gtest.h" namespace crashpad { @@ -33,7 +33,7 @@ TEST(RandomString, RandomString) { const std::string allowed_characters("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); size_t character_counts[26] = {}; - ASSERT_EQ(allowed_characters.size(), base::size(character_counts)); + ASSERT_EQ(allowed_characters.size(), std::size(character_counts)); std::set strings; @@ -61,7 +61,7 @@ TEST(RandomString, RandomString) { // Make sure every character appears at least once. It is possible, but // extremely unlikely, for a character to not appear at all. for (size_t character_index = 0; - character_index < base::size(character_counts); + character_index < std::size(character_counts); ++character_index) { EXPECT_GT(character_counts[character_index], 0u) << allowed_characters[character_index]; diff --git a/util/misc/uuid_test.cc b/util/misc/uuid_test.cc index aea126ab..6c036633 100644 --- a/util/misc/uuid_test.cc +++ b/util/misc/uuid_test.cc @@ -17,9 +17,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/scoped_generic.h" #include "base/strings/stringprintf.h" @@ -110,13 +110,13 @@ TEST(UUID, UUID) { EXPECT_NE(uuid, uuid_2); EXPECT_LT(uuid_2, uuid); --uuid.data_3; - for (size_t index = 0; index < base::size(uuid.data_4); ++index) { + for (size_t index = 0; index < std::size(uuid.data_4); ++index) { ++uuid.data_4[index]; EXPECT_NE(uuid, uuid_2); EXPECT_LT(uuid_2, uuid); --uuid.data_4[index]; } - for (size_t index = 0; index < base::size(uuid.data_5); ++index) { + for (size_t index = 0; index < std::size(uuid.data_5); ++index) { ++uuid.data_5[index]; EXPECT_NE(uuid, uuid_2); EXPECT_LT(uuid_2, uuid); @@ -207,7 +207,7 @@ TEST(UUID, FromString) { uuid_zero.InitializeToZero(); const std::string empty_uuid = uuid_zero.ToString(); - for (size_t index = 0; index < base::size(kCases); ++index) { + for (size_t index = 0; index < std::size(kCases); ++index) { const TestCase& test_case = kCases[index]; SCOPED_TRACE(base::StringPrintf( "index %" PRIuS ": %s", index, test_case.uuid_string)); diff --git a/util/net/http_transport_socket.cc b/util/net/http_transport_socket.cc index 286c2ab0..e27afa22 100644 --- a/util/net/http_transport_socket.cc +++ b/util/net/http_transport_socket.cc @@ -12,15 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "util/net/http_transport.h" - #include #include #include #include #include -#include "base/cxx17_backports.h" +#include + #include "base/logging.h" #include "base/numerics/safe_conversions.h" #include "base/posix/eintr_wrapper.h" @@ -30,6 +29,7 @@ #include "build/build_config.h" #include "util/file/file_io.h" #include "util/net/http_body.h" +#include "util/net/http_transport.h" #include "util/net/url.h" #include "util/stdlib/string_number_conversion.h" #include "util/string/split_string.h" @@ -371,7 +371,7 @@ bool WriteRequest(Stream* stream, FileOperationResult data_bytes; do { - constexpr size_t kCRLFSize = base::size(kCRLFTerminator) - 1; + constexpr size_t kCRLFSize = std::size(kCRLFTerminator) - 1; struct __attribute__((packed)) { char size[8]; char crlf[2]; diff --git a/util/net/http_transport_win.cc b/util/net/http_transport_win.cc index cb04c2e9..117b8269 100644 --- a/util/net/http_transport_win.cc +++ b/util/net/http_transport_win.cc @@ -22,7 +22,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/logging.h" #include "base/numerics/safe_conversions.h" #include "base/scoped_generic.h" @@ -96,7 +97,7 @@ std::string WinHttpMessage(const char* extra) { error_code, 0, msgbuf, - static_cast(base::size(msgbuf)), + static_cast(std::size(msgbuf)), nullptr); if (!len) { return base::StringPrintf("%s: error 0x%lx while retrieving error 0x%lx", diff --git a/util/numeric/checked_address_range_test.cc b/util/numeric/checked_address_range_test.cc index aa700e0a..1a4d93f7 100644 --- a/util/numeric/checked_address_range_test.cc +++ b/util/numeric/checked_address_range_test.cc @@ -16,9 +16,9 @@ #include +#include #include -#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/strings/stringprintf.h" #include "build/build_config.h" @@ -119,7 +119,7 @@ TEST(CheckedAddressRange, IsValid) { {0xffffffffffffffff, 1, kInvalid}, }; - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { const auto& testcase = kTestData[index]; SCOPED_TRACE(base::StringPrintf("index %" PRIuS ", base 0x%" PRIx64 ", size 0x%" PRIx64, @@ -170,7 +170,7 @@ TEST(CheckedAddressRange, ContainsValue) { CheckedAddressRange parent_range_32(false, 0x2000, 0x1000); ASSERT_TRUE(parent_range_32.IsValid()); - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { const auto& testcase = kTestData[index]; SCOPED_TRACE(base::StringPrintf( "index %" PRIuS ", value 0x%" PRIx64, index, testcase.value)); @@ -227,7 +227,7 @@ TEST(CheckedAddressRange, ContainsRange) { CheckedAddressRange parent_range_32(false, 0x2000, 0x1000); ASSERT_TRUE(parent_range_32.IsValid()); - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { const auto& testcase = kTestData[index]; SCOPED_TRACE(base::StringPrintf("index %" PRIuS ", base 0x%" PRIx64 ", size 0x%" PRIx64, diff --git a/util/numeric/checked_range_test.cc b/util/numeric/checked_range_test.cc index ad734ba3..b4e04261 100644 --- a/util/numeric/checked_range_test.cc +++ b/util/numeric/checked_range_test.cc @@ -17,9 +17,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" @@ -78,7 +78,7 @@ TEST(CheckedRange, IsValid) { {0xffffffff, 0xffffffff, false}, }; - for (size_t index = 0; index < base::size(kUnsignedTestData); ++index) { + for (size_t index = 0; index < std::size(kUnsignedTestData); ++index) { const auto& testcase = kUnsignedTestData[index]; SCOPED_TRACE(base::StringPrintf("unsigned index %" PRIuS ", base 0x%x, size 0x%x", @@ -140,7 +140,7 @@ TEST(CheckedRange, IsValid) { {-1, 0xffffffff, false}, }; - for (size_t index = 0; index < base::size(kSignedTestData); ++index) { + for (size_t index = 0; index < std::size(kSignedTestData); ++index) { const auto& testcase = kSignedTestData[index]; SCOPED_TRACE(base::StringPrintf("signed index %" PRIuS ", base 0x%x, size 0x%x", @@ -186,7 +186,7 @@ TEST(CheckedRange, ContainsValue) { CheckedRange parent_range(0x2000, 0x1000); ASSERT_TRUE(parent_range.IsValid()); - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { const auto& testcase = kTestData[index]; SCOPED_TRACE(base::StringPrintf( "index %" PRIuS ", value 0x%x", index, testcase.value)); @@ -234,7 +234,7 @@ TEST(CheckedRange, ContainsRange) { CheckedRange parent_range(0x2000, 0x1000); ASSERT_TRUE(parent_range.IsValid()); - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { const auto& testcase = kTestData[index]; SCOPED_TRACE(base::StringPrintf("index %" PRIuS ", base 0x%x, size 0x%x", index, @@ -287,7 +287,7 @@ TEST(CheckedRange, OverlapsRange) { CheckedRange first_range(0x2000, 0x1000); ASSERT_TRUE(first_range.IsValid()); - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { const auto& testcase = kTestData[index]; SCOPED_TRACE(base::StringPrintf("index %" PRIuS ", base 0x%x, size 0x%x", index, diff --git a/util/posix/close_multiple.cc b/util/posix/close_multiple.cc index ec15e06f..4bafd474 100644 --- a/util/posix/close_multiple.cc +++ b/util/posix/close_multiple.cc @@ -21,8 +21,8 @@ #include #include +#include -#include "base/cxx17_backports.h" #include "base/files/scoped_file.h" #include "base/logging.h" #include "base/posix/eintr_wrapper.h" @@ -155,7 +155,7 @@ void CloseMultipleNowOrOnExec(int fd, int preserve_fd) { int maxfilesperproc; size_t maxfilesperproc_size = sizeof(maxfilesperproc); if (sysctl(oid, - base::size(oid), + std::size(oid), &maxfilesperproc, &maxfilesperproc_size, nullptr, diff --git a/util/posix/process_info_mac.cc b/util/posix/process_info_mac.cc index 47d0ff4a..de056dd5 100644 --- a/util/posix/process_info_mac.cc +++ b/util/posix/process_info_mac.cc @@ -16,7 +16,8 @@ #include -#include "base/cxx17_backports.h" +#include + #include "base/logging.h" #include "base/mac/mach_logging.h" @@ -33,7 +34,7 @@ bool ProcessInfo::InitializeWithPid(pid_t pid) { int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid}; size_t len = sizeof(kern_proc_info_); - if (sysctl(mib, base::size(mib), &kern_proc_info_, &len, nullptr, 0) != 0) { + if (sysctl(mib, std::size(mib), &kern_proc_info_, &len, nullptr, 0) != 0) { PLOG(ERROR) << "sysctl for pid " << pid; return false; } @@ -112,7 +113,7 @@ std::set ProcessInfo::SupplementaryGroups() const { const short ngroups = kern_proc_info_.kp_eproc.e_ucred.cr_ngroups; DCHECK_GE(ngroups, 0); DCHECK_LE(static_cast(ngroups), - base::size(kern_proc_info_.kp_eproc.e_ucred.cr_groups)); + std::size(kern_proc_info_.kp_eproc.e_ucred.cr_groups)); const gid_t* groups = kern_proc_info_.kp_eproc.e_ucred.cr_groups; return std::set(&groups[0], &groups[ngroups]); @@ -169,7 +170,7 @@ bool ProcessInfo::Arguments(std::vector* argv) const { do { int mib[] = {CTL_KERN, KERN_PROCARGS2, pid}; int rv = - sysctl(mib, base::size(mib), nullptr, &args_size_estimate, nullptr, 0); + sysctl(mib, std::size(mib), nullptr, &args_size_estimate, nullptr, 0); if (rv != 0) { PLOG(ERROR) << "sysctl (size) for pid " << pid; return false; @@ -184,7 +185,7 @@ bool ProcessInfo::Arguments(std::vector* argv) const { // for the reasons described above.) args_size = args_size_estimate + 32; args.resize(args_size); - rv = sysctl(mib, base::size(mib), &args[0], &args_size, nullptr, 0); + rv = sysctl(mib, std::size(mib), &args[0], &args_size, nullptr, 0); if (rv != 0) { PLOG(ERROR) << "sysctl (data) for pid " << pid; return false; diff --git a/util/posix/scoped_mmap_test.cc b/util/posix/scoped_mmap_test.cc index f8307cc6..c171b81d 100644 --- a/util/posix/scoped_mmap_test.cc +++ b/util/posix/scoped_mmap_test.cc @@ -18,7 +18,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/numerics/safe_conversions.h" #include "base/rand_util.h" #include "base/strings/stringprintf.h" @@ -152,7 +153,7 @@ TEST(ScopedMmapDeathTest, ResetAddrLen_Shrink) { EXPECT_EQ(mapping.len(), 3 * kPageSize); TestCookie cookies[3]; - for (size_t index = 0; index < base::size(cookies); ++index) { + for (size_t index = 0; index < std::size(cookies); ++index) { cookies[index].SetUp(reinterpret_cast( mapping.addr_as() + index * kPageSize)); } @@ -187,7 +188,7 @@ TEST(ScopedMmap, ResetAddrLen_Grow) { EXPECT_EQ(mapping.len(), kPageSize); TestCookie cookies[3]; - for (size_t index = 0; index < base::size(cookies); ++index) { + for (size_t index = 0; index < std::size(cookies); ++index) { cookies[index].SetUp(reinterpret_cast( reinterpret_cast(pages) + index * kPageSize)); } @@ -198,7 +199,7 @@ TEST(ScopedMmap, ResetAddrLen_Grow) { EXPECT_EQ(mapping.addr(), pages); EXPECT_EQ(mapping.len(), 3 * kPageSize); - for (size_t index = 0; index < base::size(cookies); ++index) { + for (size_t index = 0; index < std::size(cookies); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); EXPECT_EQ(cookies[index].Observed(), cookies[index].Expected()); } @@ -219,7 +220,7 @@ TEST(ScopedMmapDeathTest, ResetAddrLen_MoveDownAndGrow) { EXPECT_EQ(mapping.len(), kPageSize); TestCookie cookies[3]; - for (size_t index = 0; index < base::size(cookies); ++index) { + for (size_t index = 0; index < std::size(cookies); ++index) { cookies[index].SetUp(reinterpret_cast( reinterpret_cast(pages) + index * kPageSize)); } @@ -250,7 +251,7 @@ TEST(ScopedMmapDeathTest, ResetAddrLen_MoveUpAndShrink) { EXPECT_EQ(mapping.len(), 2 * kPageSize); TestCookie cookies[3]; - for (size_t index = 0; index < base::size(cookies); ++index) { + for (size_t index = 0; index < std::size(cookies); ++index) { cookies[index].SetUp(reinterpret_cast( reinterpret_cast(pages) + index * kPageSize)); } @@ -348,7 +349,7 @@ TEST(ScopedMmapDeathTest, NotIntegralNumberOfPages) { EXPECT_EQ(mapping.len(), 2 * kPageSize); TestCookie two_cookies[2]; - for (size_t index = 0; index < base::size(two_cookies); ++index) { + for (size_t index = 0; index < std::size(two_cookies); ++index) { two_cookies[index].SetUp(reinterpret_cast( mapping.addr_as() + index * kPageSize)); } @@ -368,7 +369,7 @@ TEST(ScopedMmapDeathTest, NotIntegralNumberOfPages) { EXPECT_NE(mapping.addr(), MAP_FAILED); EXPECT_EQ(mapping.len(), 2 * kPageSize); - for (size_t index = 0; index < base::size(two_cookies); ++index) { + for (size_t index = 0; index < std::size(two_cookies); ++index) { two_cookies[index].SetUp(reinterpret_cast( mapping.addr_as() + index * kPageSize)); } diff --git a/util/posix/signals.cc b/util/posix/signals.cc index 145a4332..f53ceb2a 100644 --- a/util/posix/signals.cc +++ b/util/posix/signals.cc @@ -16,10 +16,10 @@ #include +#include #include #include "base/check_op.h" -#include "base/cxx17_backports.h" #include "base/logging.h" #include "build/build_config.h" @@ -130,7 +130,7 @@ bool IsSignalInSet(int sig, const int* set, size_t set_size) { struct sigaction* Signals::OldActions::ActionForSignal(int sig) { DCHECK_GT(sig, 0); const size_t slot = sig - 1; - DCHECK_LT(slot, base::size(actions_)); + DCHECK_LT(slot, std::size(actions_)); return &actions_[slot]; } @@ -165,8 +165,7 @@ bool Signals::InstallCrashHandlers(Handler handler, OldActions* old_actions, const std::set* unhandled_signals) { return InstallHandlers( - std::vector(kCrashSignals, - kCrashSignals + base::size(kCrashSignals)), + std::vector(kCrashSignals, kCrashSignals + std::size(kCrashSignals)), handler, flags, old_actions, @@ -179,7 +178,7 @@ bool Signals::InstallTerminateHandlers(Handler handler, OldActions* old_actions) { return InstallHandlers( std::vector(kTerminateSignals, - kTerminateSignals + base::size(kTerminateSignals)), + kTerminateSignals + std::size(kTerminateSignals)), handler, flags, old_actions, @@ -324,12 +323,12 @@ void Signals::RestoreHandlerAndReraiseSignalOnReturn( // static bool Signals::IsCrashSignal(int sig) { - return IsSignalInSet(sig, kCrashSignals, base::size(kCrashSignals)); + return IsSignalInSet(sig, kCrashSignals, std::size(kCrashSignals)); } // static bool Signals::IsTerminateSignal(int sig) { - return IsSignalInSet(sig, kTerminateSignals, base::size(kTerminateSignals)); + return IsSignalInSet(sig, kTerminateSignals, std::size(kTerminateSignals)); } } // namespace crashpad diff --git a/util/posix/signals_test.cc b/util/posix/signals_test.cc index d9b44de0..94d8e511 100644 --- a/util/posix/signals_test.cc +++ b/util/posix/signals_test.cc @@ -20,9 +20,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/files/scoped_file.h" #include "base/logging.h" #include "base/strings/stringprintf.h" @@ -410,7 +410,7 @@ TEST(Signals, WillSignalReraiseAutonomously) { {SIGHUP, SEGV_MAPERR, false}, {SIGINT, SI_USER, false}, }; - for (size_t index = 0; index < base::size(kTestData); ++index) { + for (size_t index = 0; index < std::size(kTestData); ++index) { const auto test_data = kTestData[index]; SCOPED_TRACE(base::StringPrintf( "index %zu, sig %d, code %d", index, test_data.sig, test_data.code)); diff --git a/util/posix/symbolic_constants_posix.cc b/util/posix/symbolic_constants_posix.cc index 6bb08960..686de578 100644 --- a/util/posix/symbolic_constants_posix.cc +++ b/util/posix/symbolic_constants_posix.cc @@ -18,7 +18,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/strings/stringprintf.h" #include "build/build_config.h" #include "util/misc/implicit_cast.h" @@ -139,9 +140,9 @@ constexpr const char* kSignalNames[] = { }; #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) // NSIG is 64 to account for real-time signals. -static_assert(base::size(kSignalNames) == 32, "kSignalNames length"); +static_assert(std::size(kSignalNames) == 32, "kSignalNames length"); #else -static_assert(base::size(kSignalNames) == NSIG, "kSignalNames length"); +static_assert(std::size(kSignalNames) == NSIG, "kSignalNames length"); #endif constexpr char kSigPrefix[] = "SIG"; @@ -153,7 +154,7 @@ namespace crashpad { std::string SignalToString(int signal, SymbolicConstantToStringOptions options) { const char* signal_name = - implicit_cast(signal) < base::size(kSignalNames) + implicit_cast(signal) < std::size(kSignalNames) ? kSignalNames[signal] : nullptr; if (!signal_name) { @@ -178,7 +179,7 @@ bool StringToSignal(const base::StringPiece& string, string.substr(0, strlen(kSigPrefix)).compare(kSigPrefix) == 0; base::StringPiece short_string = can_match_full ? string.substr(strlen(kSigPrefix)) : string; - for (int index = 0; index < implicit_cast(base::size(kSignalNames)); + for (int index = 0; index < implicit_cast(std::size(kSignalNames)); ++index) { const char* signal_name = kSignalNames[index]; if (!signal_name) { diff --git a/util/posix/symbolic_constants_posix_test.cc b/util/posix/symbolic_constants_posix_test.cc index d59d46c1..532f7fd2 100644 --- a/util/posix/symbolic_constants_posix_test.cc +++ b/util/posix/symbolic_constants_posix_test.cc @@ -17,14 +17,15 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/strings/string_piece.h" #include "base/strings/stringprintf.h" #include "build/build_config.h" #include "gtest/gtest.h" #define NUL_TEST_DATA(string) \ - { string, base::size(string) - 1 } + { string, std::size(string) - 1 } namespace crashpad { namespace test { @@ -101,7 +102,7 @@ void TestSignalToString(int value, } TEST(SymbolicConstantsPOSIX, SignalToString) { - for (size_t index = 0; index < base::size(kSignalTestData); ++index) { + for (size_t index = 0; index < std::size(kSignalTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); TestSignalToString(kSignalTestData[index].signal, kSignalTestData[index].full_name, @@ -156,11 +157,11 @@ TEST(SymbolicConstantsPOSIX, StringToSignal) { kAllowFullName | kAllowShortName | kAllowNumber, }; - for (size_t option_index = 0; option_index < base::size(kOptions); + for (size_t option_index = 0; option_index < std::size(kOptions); ++option_index) { SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index)); StringToSymbolicConstantOptions options = kOptions[option_index]; - for (size_t index = 0; index < base::size(kSignalTestData); ++index) { + for (size_t index = 0; index < std::size(kSignalTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); int signal = kSignalTestData[index].signal; { @@ -198,7 +199,7 @@ TEST(SymbolicConstantsPOSIX, StringToSignal) { "", }; - for (size_t index = 0; index < base::size(kNegativeTestData); ++index) { + for (size_t index = 0; index < std::size(kNegativeTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); TestStringToSignal(kNegativeTestData[index], options, false, 0); } @@ -219,7 +220,7 @@ TEST(SymbolicConstantsPOSIX, StringToSignal) { NUL_TEST_DATA("1\0002"), }; - for (size_t index = 0; index < base::size(kNULTestData); ++index) { + for (size_t index = 0; index < std::size(kNULTestData); ++index) { SCOPED_TRACE(base::StringPrintf("index %zu", index)); base::StringPiece string(kNULTestData[index].string, kNULTestData[index].length); diff --git a/util/process/process_memory_range_test.cc b/util/process/process_memory_range_test.cc index 78ad81f2..381eb043 100644 --- a/util/process/process_memory_range_test.cc +++ b/util/process/process_memory_range_test.cc @@ -14,9 +14,9 @@ #include "util/process/process_memory_range.h" +#include #include -#include "base/cxx17_backports.h" #include "build/build_config.h" #include "gtest/gtest.h" #include "test/process_type.h" @@ -69,28 +69,28 @@ TEST(ProcessMemoryRange, Basic) { auto string1_addr = FromPointerCast(kTestObject.string1); auto string2_addr = FromPointerCast(kTestObject.string2); ASSERT_TRUE(range.ReadCStringSizeLimited( - string1_addr, base::size(kTestObject.string1), &string)); + string1_addr, std::size(kTestObject.string1), &string)); EXPECT_STREQ(string.c_str(), kTestObject.string1); ASSERT_TRUE(range.ReadCStringSizeLimited( - string2_addr, base::size(kTestObject.string2), &string)); + string2_addr, std::size(kTestObject.string2), &string)); EXPECT_STREQ(string.c_str(), kTestObject.string2); // Limit the range to remove access to string2. ProcessMemoryRange range2; ASSERT_TRUE(range2.Initialize(range)); ASSERT_TRUE( - range2.RestrictRange(string1_addr, base::size(kTestObject.string1))); + range2.RestrictRange(string1_addr, std::size(kTestObject.string1))); EXPECT_TRUE(range2.ReadCStringSizeLimited( - string1_addr, base::size(kTestObject.string1), &string)); + string1_addr, std::size(kTestObject.string1), &string)); EXPECT_FALSE(range2.ReadCStringSizeLimited( - string2_addr, base::size(kTestObject.string2), &string)); + string2_addr, std::size(kTestObject.string2), &string)); EXPECT_FALSE(range2.Read(object_addr, sizeof(object), &object)); // String reads fail if the NUL terminator is outside the range. ASSERT_TRUE(range2.RestrictRange(string1_addr, strlen(kTestObject.string1))); EXPECT_FALSE(range2.ReadCStringSizeLimited( - string1_addr, base::size(kTestObject.string1), &string)); + string1_addr, std::size(kTestObject.string1), &string)); // New range outside the old range. EXPECT_FALSE(range2.RestrictRange(string1_addr - 1, 1)); diff --git a/util/stdlib/string_number_conversion_test.cc b/util/stdlib/string_number_conversion_test.cc index 90b67757..9f4dcbeb 100644 --- a/util/stdlib/string_number_conversion_test.cc +++ b/util/stdlib/string_number_conversion_test.cc @@ -17,10 +17,10 @@ #include #include +#include #include #include -#include "base/cxx17_backports.h" #include "gtest/gtest.h" #define STRINGIFY(a) STR(a) @@ -277,7 +277,7 @@ TEST(StringNumberConversion, StringToInt) { // "decimal digit terminates octal escape sequence". int output; std::string kEmbeddedNullInput(kEmbeddedNullInputRaw, - base::size(kEmbeddedNullInputRaw) - 1); + std::size(kEmbeddedNullInputRaw) - 1); EXPECT_FALSE(StringToNumber(kEmbeddedNullInput, &output)); } @@ -307,7 +307,7 @@ TEST(StringNumberConversion, StringToUnsignedInt) { // "decimal digit terminates octal escape sequence". unsigned int output; std::string kEmbeddedNullInput(kEmbeddedNullInputRaw, - base::size(kEmbeddedNullInputRaw) - 1); + std::size(kEmbeddedNullInputRaw) - 1); EXPECT_FALSE(StringToNumber(kEmbeddedNullInput, &output)); } diff --git a/util/stdlib/strlcpy_test.cc b/util/stdlib/strlcpy_test.cc index b729c242..4cb93369 100644 --- a/util/stdlib/strlcpy_test.cc +++ b/util/stdlib/strlcpy_test.cc @@ -18,9 +18,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/format_macros.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" @@ -53,7 +53,7 @@ TEST(strlcpy, c16lcpy) { static constexpr char16_t test_characters[] = { 0x4d, 0xe9, 0x100, 0x151, 0x1e18}; - for (size_t index = 0; index < base::size(test_characters); ++index) { + for (size_t index = 0; index < std::size(test_characters); ++index) { char16_t test_character = test_characters[index]; SCOPED_TRACE(base::StringPrintf( "character index %" PRIuS ", character 0x%x", index, test_character)); @@ -67,13 +67,13 @@ TEST(strlcpy, c16lcpy) { EXPECT_EQ(c16lcpy(destination.data, test_string.c_str(), - base::size(destination.data)), + std::size(destination.data)), length); // Make sure that the destination buffer is NUL-terminated, and that as // much of the test string was copied as could fit. size_t expected_destination_length = - std::min(length, base::size(destination.data) - 1); + std::min(length, std::size(destination.data) - 1); EXPECT_EQ(destination.data[expected_destination_length], '\0'); EXPECT_EQ(C16Len(destination.data), expected_destination_length); @@ -86,15 +86,15 @@ TEST(strlcpy, c16lcpy) { // of the buffer passed to c16lcpy. EXPECT_TRUE(C16Memcmp(expected_untouched.lead_guard, destination.lead_guard, - base::size(destination.lead_guard)) == 0); + std::size(destination.lead_guard)) == 0); size_t expected_untouched_length = - base::size(destination.data) - expected_destination_length - 1; + std::size(destination.data) - expected_destination_length - 1; EXPECT_TRUE(C16Memcmp(expected_untouched.data, &destination.data[expected_destination_length + 1], expected_untouched_length) == 0); EXPECT_TRUE(C16Memcmp(expected_untouched.trail_guard, destination.trail_guard, - base::size(destination.trail_guard)) == 0); + std::size(destination.trail_guard)) == 0); } } } diff --git a/util/stdlib/thread_safe_vector_test.cc b/util/stdlib/thread_safe_vector_test.cc index 89624304..6558fc15 100644 --- a/util/stdlib/thread_safe_vector_test.cc +++ b/util/stdlib/thread_safe_vector_test.cc @@ -14,7 +14,8 @@ #include "util/stdlib/thread_safe_vector.h" -#include "base/cxx17_backports.h" +#include + #include "gtest/gtest.h" #include "util/thread/thread.h" @@ -57,12 +58,12 @@ TEST(ThreadSafeVector, ThreadSafeVector) { EXPECT_TRUE(vector.empty()); ThreadSafeVectorTestThread threads[100]; - for (size_t index = 0; index < base::size(threads); ++index) { + for (size_t index = 0; index < std::size(threads); ++index) { threads[index].SetTestParameters( &thread_safe_vector, static_cast(index * kElementsPerThread)); } - for (size_t index = 0; index < base::size(threads); ++index) { + for (size_t index = 0; index < std::size(threads); ++index) { threads[index].Start(); if (index % 10 == 0) { @@ -79,8 +80,8 @@ TEST(ThreadSafeVector, ThreadSafeVector) { std::vector drained = thread_safe_vector.Drain(); vector.insert(vector.end(), drained.begin(), drained.end()); - bool found[base::size(threads) * kElementsPerThread] = {}; - EXPECT_EQ(vector.size(), base::size(found)); + bool found[std::size(threads) * kElementsPerThread] = {}; + EXPECT_EQ(vector.size(), std::size(found)); for (int element : vector) { EXPECT_FALSE(found[element]) << element; found[element] = true; diff --git a/util/stream/base94_output_stream_test.cc b/util/stream/base94_output_stream_test.cc index d0a29855..34c1b434 100644 --- a/util/stream/base94_output_stream_test.cc +++ b/util/stream/base94_output_stream_test.cc @@ -17,9 +17,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/rand_util.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" @@ -237,7 +237,7 @@ TEST_F(Base94OutputStreamTest, WriteDeterministicLongDataMultipleTimes) { 4, 96, 40, kLongDataLength - 4 - 96 - 40}; size_t offset = 0; - for (size_t index = 0; index < base::size(kWriteLengths); ++index) { + for (size_t index = 0; index < std::size(kWriteLengths); ++index) { const size_t write_length = kWriteLengths[index]; SCOPED_TRACE(base::StringPrintf( "offset %zu, write_length %zu", offset, write_length)); diff --git a/util/stream/zlib_output_stream.cc b/util/stream/zlib_output_stream.cc index 3ae7d912..153adbe0 100644 --- a/util/stream/zlib_output_stream.cc +++ b/util/stream/zlib_output_stream.cc @@ -14,8 +14,9 @@ #include "util/stream/zlib_output_stream.h" +#include + #include "base/check.h" -#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/numerics/safe_conversions.h" #include "util/misc/zlib.h" @@ -65,7 +66,7 @@ bool ZlibOutputStream::Write(const uint8_t* data, size_t size) { } } zlib_stream_.next_out = buffer_; - zlib_stream_.avail_out = base::saturated_cast(base::size(buffer_)); + zlib_stream_.avail_out = base::saturated_cast(std::size(buffer_)); initialized_.set_valid(); } @@ -127,12 +128,12 @@ bool ZlibOutputStream::Flush() { } bool ZlibOutputStream::WriteOutputStream() { - auto valid_size = base::size(buffer_) - zlib_stream_.avail_out; + auto valid_size = std::size(buffer_) - zlib_stream_.avail_out; if (valid_size > 0 && !output_stream_->Write(buffer_, valid_size)) return false; zlib_stream_.next_out = buffer_; - zlib_stream_.avail_out = base::saturated_cast(base::size(buffer_)); + zlib_stream_.avail_out = base::saturated_cast(std::size(buffer_)); return true; } diff --git a/util/stream/zlib_output_stream_test.cc b/util/stream/zlib_output_stream_test.cc index 306a61b1..528800e3 100644 --- a/util/stream/zlib_output_stream_test.cc +++ b/util/stream/zlib_output_stream_test.cc @@ -17,8 +17,8 @@ #include #include +#include -#include "base/cxx17_backports.h" #include "base/rand_util.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" @@ -102,7 +102,7 @@ TEST_F(ZlibOutputStreamTest, WriteDeterministicLongDataMultipleTimes) { 4, 96, 40, kLongDataLength - 4 - 96 - 40}; size_t offset = 0; - for (size_t index = 0; index < base::size(kWriteLengths); ++index) { + for (size_t index = 0; index < std::size(kWriteLengths); ++index) { const size_t write_length = kWriteLengths[index]; SCOPED_TRACE(base::StringPrintf( "offset %zu, write_length %zu", offset, write_length)); diff --git a/util/synchronization/semaphore_test.cc b/util/synchronization/semaphore_test.cc index 08fc9e61..9a6b6dec 100644 --- a/util/synchronization/semaphore_test.cc +++ b/util/synchronization/semaphore_test.cc @@ -16,7 +16,8 @@ #include -#include "base/cxx17_backports.h" +#include + #include "build/build_config.h" #include "gtest/gtest.h" @@ -127,7 +128,7 @@ TEST(Semaphore, TenThreaded) { Semaphore semaphore(5); ThreadMainInfo info[10]; size_t iterations = 0; - for (size_t index = 0; index < base::size(info); ++index) { + for (size_t index = 0; index < std::size(info); ++index) { info[index].semaphore = &semaphore; info[index].iterations = index; iterations += info[index].iterations; @@ -139,7 +140,7 @@ TEST(Semaphore, TenThreaded) { semaphore.Signal(); } - for (size_t index = 0; index < base::size(info); ++index) { + for (size_t index = 0; index < std::size(info); ++index) { JoinThread(&info[index]); } } diff --git a/util/thread/thread_log_messages_test.cc b/util/thread/thread_log_messages_test.cc index f3dc1a66..efd6b53a 100644 --- a/util/thread/thread_log_messages_test.cc +++ b/util/thread/thread_log_messages_test.cc @@ -17,7 +17,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/logging.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" @@ -65,8 +66,8 @@ TEST(ThreadLogMessages, Basic) { const std::vector& log_messages = thread_log_messages.log_messages(); - EXPECT_EQ(log_messages.size(), base::size(kMessages)); - for (size_t index = 0; index < base::size(kMessages); ++index) { + EXPECT_EQ(log_messages.size(), std::size(kMessages)); + for (size_t index = 0; index < std::size(kMessages); ++index) { ASSERT_NO_FATAL_FAILURE( ExpectLogMessage(log_messages[index], kMessages[index])) << "index " << index; @@ -149,7 +150,7 @@ TEST(ThreadLogMessages, Multithreaded) { LoggingTestThread threads[20]; int start = 0; - for (size_t index = 0; index < base::size(threads); ++index) { + for (size_t index = 0; index < std::size(threads); ++index) { threads[index].Initialize( index, static_cast(start), static_cast(index)); start += static_cast(index); diff --git a/util/win/command_line_test.cc b/util/win/command_line_test.cc index 28b95041..6fd4b31b 100644 --- a/util/win/command_line_test.cc +++ b/util/win/command_line_test.cc @@ -18,7 +18,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/scoped_generic.h" #include "gtest/gtest.h" #include "test/errors.h" @@ -64,7 +65,7 @@ TEST(CommandLine, AppendCommandLineArgument) { L"argument 1", L"argument 2", }; - AppendCommandLineArgumentTest(base::size(kArguments), kArguments); + AppendCommandLineArgumentTest(std::size(kArguments), kArguments); } { @@ -76,7 +77,7 @@ TEST(CommandLine, AppendCommandLineArgument) { L"argument 2", L"\\some\\path with\\spaces", }; - AppendCommandLineArgumentTest(base::size(kArguments), kArguments); + AppendCommandLineArgumentTest(std::size(kArguments), kArguments); } { @@ -88,7 +89,7 @@ TEST(CommandLine, AppendCommandLineArgument) { L"she said, \"you had me at hello\"", L"\\some\\path with\\spaces", }; - AppendCommandLineArgumentTest(base::size(kArguments), kArguments); + AppendCommandLineArgumentTest(std::size(kArguments), kArguments); } { @@ -101,7 +102,7 @@ TEST(CommandLine, AppendCommandLineArgument) { L"argument3", L"argument4", }; - AppendCommandLineArgumentTest(base::size(kArguments), kArguments); + AppendCommandLineArgumentTest(std::size(kArguments), kArguments); } { @@ -112,7 +113,7 @@ TEST(CommandLine, AppendCommandLineArgument) { L"\\some\\directory with\\spaces\\", L"argument2", }; - AppendCommandLineArgumentTest(base::size(kArguments), kArguments); + AppendCommandLineArgumentTest(std::size(kArguments), kArguments); } { @@ -123,7 +124,7 @@ TEST(CommandLine, AppendCommandLineArgument) { L"", L"argument2", }; - AppendCommandLineArgumentTest(base::size(kArguments), kArguments); + AppendCommandLineArgumentTest(std::size(kArguments), kArguments); } { @@ -158,7 +159,7 @@ TEST(CommandLine, AppendCommandLineArgument) { L"\"\"", L" \t\n\v\"", }; - AppendCommandLineArgumentTest(base::size(kArguments), kArguments); + AppendCommandLineArgumentTest(std::size(kArguments), kArguments); } } diff --git a/util/win/exception_handler_server.cc b/util/win/exception_handler_server.cc index 92d5c5d4..6890a01c 100644 --- a/util/win/exception_handler_server.cc +++ b/util/win/exception_handler_server.cc @@ -18,9 +18,9 @@ #include #include +#include #include -#include "base/cxx17_backports.h" #include "base/logging.h" #include "base/numerics/safe_conversions.h" #include "base/rand_util.h" @@ -306,7 +306,7 @@ void ExceptionHandlerServer::InitializeWithInheritedDataForInitialClient( void ExceptionHandlerServer::Run(Delegate* delegate) { uint64_t shutdown_token = base::RandUint64(); ScopedKernelHANDLE thread_handles[kPipeInstances]; - for (size_t i = 0; i < base::size(thread_handles); ++i) { + for (size_t i = 0; i < std::size(thread_handles); ++i) { HANDLE pipe; if (first_pipe_instance_.is_valid()) { pipe = first_pipe_instance_.release(); @@ -358,7 +358,7 @@ void ExceptionHandlerServer::Run(Delegate* delegate) { } // Signal to the named pipe instances that they should terminate. - for (size_t i = 0; i < base::size(thread_handles); ++i) { + for (size_t i = 0; i < std::size(thread_handles); ++i) { ClientToServerMessage message; memset(&message, 0, sizeof(message)); message.type = ClientToServerMessage::kShutdown; diff --git a/util/win/ntstatus_logging.cc b/util/win/ntstatus_logging.cc index 7a134195..9c2630c9 100644 --- a/util/win/ntstatus_logging.cc +++ b/util/win/ntstatus_logging.cc @@ -14,9 +14,9 @@ #include "util/win/ntstatus_logging.h" +#include #include -#include "base/cxx17_backports.h" #include "base/strings/stringprintf.h" namespace { @@ -30,7 +30,7 @@ std::string FormatNtstatus(DWORD ntstatus) { ntstatus, 0, msgbuf, - static_cast(base::size(msgbuf)), + static_cast(std::size(msgbuf)), nullptr); if (len) { // Most system messages end in a period and a space. Remove the space if diff --git a/util/win/registration_protocol_win.cc b/util/win/registration_protocol_win.cc index e3d55c66..61dbd3d9 100644 --- a/util/win/registration_protocol_win.cc +++ b/util/win/registration_protocol_win.cc @@ -19,7 +19,8 @@ #include #include -#include "base/cxx17_backports.h" +#include + #include "base/logging.h" #include "util/win/exception_handler_server.h" #include "util/win/loader_lock.h" @@ -209,8 +210,7 @@ const void* GetFallbackSecurityDescriptorForNamedPipeInstance(size_t* size) { ACL_REVISION, // AclRevision. 0, // Sbz1. sizeof(kSecDescBlob.sacl), // AclSize. - static_cast( - base::size(kSecDescBlob.sacl.ace)), // AceCount. + static_cast(std::size(kSecDescBlob.sacl.ace)), // AceCount. 0, // Sbz2. }, @@ -231,8 +231,8 @@ const void* GetFallbackSecurityDescriptorForNamedPipeInstance(size_t* size) { { SID_REVISION, // Revision. // SubAuthorityCount. - static_cast(base::size( - kSecDescBlob.sacl.ace[0].sid.SubAuthority)), + static_cast( + std::size(kSecDescBlob.sacl.ace[0].sid.SubAuthority)), // IdentifierAuthority. {SECURITY_MANDATORY_LABEL_AUTHORITY}, {SECURITY_MANDATORY_UNTRUSTED_RID}, // SubAuthority. diff --git a/util/win/safe_terminate_process_test.cc b/util/win/safe_terminate_process_test.cc index 6ca5aa6d..30a9a32d 100644 --- a/util/win/safe_terminate_process_test.cc +++ b/util/win/safe_terminate_process_test.cc @@ -16,11 +16,11 @@ #include -#include +#include #include +#include #include "base/check.h" -#include "base/cxx17_backports.h" #include "base/files/file_path.h" #include "build/build_config.h" #include "gtest/gtest.h" @@ -150,7 +150,7 @@ TEST(SafeTerminateProcess, PatchBadly) { }; void* target = reinterpret_cast(TerminateProcess); - ScopedExecutablePatch executable_patch(target, patch, base::size(patch)); + ScopedExecutablePatch executable_patch(target, patch, std::size(patch)); // Make sure that SafeTerminateProcess() can be called. Since it’s been // patched with a no-op stub, GetLastError() shouldn’t be modified.