mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-27 15:32:10 +08:00
Use constexpr at namespace scope
This is essentially based on a search for “^const .*=”. Change-Id: I9332c1f0cf7c891ba1ae373dc537f700f9a1d956 Reviewed-on: https://chromium-review.googlesource.com/585452 Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
This commit is contained in:
parent
6dac7ecdf5
commit
8f0636288a
@ -43,8 +43,8 @@ constexpr wchar_t kSettings[] = L"settings.dat";
|
||||
|
||||
constexpr wchar_t kCrashReportFileExtension[] = L"dmp";
|
||||
|
||||
const uint32_t kMetadataFileHeaderMagic = 'CPAD';
|
||||
const uint32_t kMetadataFileVersion = 1;
|
||||
constexpr uint32_t kMetadataFileHeaderMagic = 'CPAD';
|
||||
constexpr uint32_t kMetadataFileVersion = 1;
|
||||
|
||||
using OperationStatus = CrashReportDatabase::OperationStatus;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
const uint32_t MinidumpModuleCrashpadInfo::kVersion;
|
||||
const uint32_t MinidumpCrashpadInfo::kVersion;
|
||||
constexpr uint32_t MinidumpModuleCrashpadInfo::kVersion;
|
||||
constexpr uint32_t MinidumpCrashpadInfo::kVersion;
|
||||
|
||||
} // namespace crashpad
|
||||
|
@ -290,7 +290,7 @@ struct ALIGNAS(4) PACKED MinidumpModuleCrashpadInfo {
|
||||
//! \brief The structure’s currently-defined version number.
|
||||
//!
|
||||
//! \sa version
|
||||
static const uint32_t kVersion = 1;
|
||||
static constexpr uint32_t kVersion = 1;
|
||||
|
||||
//! \brief The structure’s version number.
|
||||
//!
|
||||
@ -387,7 +387,7 @@ struct ALIGNAS(4) PACKED MinidumpCrashpadInfo {
|
||||
//! \brief The structure’s currently-defined version number.
|
||||
//!
|
||||
//! \sa version
|
||||
static const uint32_t kVersion = 1;
|
||||
static constexpr uint32_t kVersion = 1;
|
||||
|
||||
//! \brief The structure’s version number.
|
||||
//!
|
||||
|
@ -35,7 +35,7 @@ namespace crashpad {
|
||||
namespace test {
|
||||
namespace {
|
||||
|
||||
const MinidumpStreamType kBogusStreamType =
|
||||
constexpr MinidumpStreamType kBogusStreamType =
|
||||
static_cast<MinidumpStreamType>(1234);
|
||||
|
||||
// expected_streams is the expected number of streams in the file. The memory
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
const size_t kMaximumAlignment = 16;
|
||||
constexpr size_t kMaximumAlignment = 16;
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -82,7 +82,7 @@ void MinidumpWritable::RegisterLocationDescriptor(
|
||||
registered_location_descriptors_.push_back(location_descriptor);
|
||||
}
|
||||
|
||||
const size_t MinidumpWritable::kInvalidSize =
|
||||
constexpr size_t MinidumpWritable::kInvalidSize =
|
||||
std::numeric_limits<size_t>::max();
|
||||
|
||||
MinidumpWritable::MinidumpWritable()
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
const uint32_t kInvalidSegmentIndex = std::numeric_limits<uint32_t>::max();
|
||||
constexpr uint32_t kInvalidSegmentIndex = std::numeric_limits<uint32_t>::max();
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -47,16 +47,16 @@ namespace {
|
||||
// are different.
|
||||
#if defined(ARCH_CPU_64_BITS)
|
||||
using MachHeader = mach_header_64;
|
||||
const uint32_t kMachMagic = MH_MAGIC_64;
|
||||
constexpr uint32_t kMachMagic = MH_MAGIC_64;
|
||||
using SegmentCommand = segment_command_64;
|
||||
const uint32_t kSegmentCommand = LC_SEGMENT_64;
|
||||
constexpr uint32_t kSegmentCommand = LC_SEGMENT_64;
|
||||
using Section = section_64;
|
||||
using Nlist = nlist_64;
|
||||
#else
|
||||
using MachHeader = mach_header;
|
||||
const uint32_t kMachMagic = MH_MAGIC;
|
||||
constexpr uint32_t kMachMagic = MH_MAGIC;
|
||||
using SegmentCommand = segment_command;
|
||||
const uint32_t kSegmentCommand = LC_SEGMENT;
|
||||
constexpr uint32_t kSegmentCommand = LC_SEGMENT;
|
||||
using Section = section;
|
||||
|
||||
// This needs to be called “struct nlist” because “nlist” without the struct
|
||||
@ -65,9 +65,9 @@ using Nlist = struct nlist;
|
||||
#endif
|
||||
|
||||
#if defined(ARCH_CPU_X86_64)
|
||||
const int kCPUType = CPU_TYPE_X86_64;
|
||||
constexpr int kCPUType = CPU_TYPE_X86_64;
|
||||
#elif defined(ARCH_CPU_X86)
|
||||
const int kCPUType = CPU_TYPE_X86;
|
||||
constexpr int kCPUType = CPU_TYPE_X86;
|
||||
#endif
|
||||
|
||||
// Verifies that |expect_section| and |actual_section| agree.
|
||||
@ -327,7 +327,8 @@ void ExpectSegmentCommands(const MachHeader* expect_image,
|
||||
// In some cases, the expected slide value for an image is unknown, because no
|
||||
// reasonable API to return it is provided. When this happens, use kSlideUnknown
|
||||
// to avoid checking the actual slide value against anything.
|
||||
const mach_vm_size_t kSlideUnknown = std::numeric_limits<mach_vm_size_t>::max();
|
||||
constexpr mach_vm_size_t kSlideUnknown =
|
||||
std::numeric_limits<mach_vm_size_t>::max();
|
||||
|
||||
// Verifies that |expect_image| is a vaild Mach-O header for the current system
|
||||
// by checking its |magic| and |cputype| fields. Then, verifies that the
|
||||
|
@ -38,7 +38,7 @@ base::FilePath GenerateCandidateName() {
|
||||
return system_temp_dir.Append(new_dir_name);
|
||||
}
|
||||
|
||||
const int kRetries = 50;
|
||||
constexpr int kRetries = 50;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -45,11 +45,12 @@ using FileOffset = off_t;
|
||||
//! \brief Scoped wrapper of a FileHandle.
|
||||
using ScopedFileHandle = base::ScopedFD;
|
||||
|
||||
//! \brief The return value of read and write calls.
|
||||
using FileOperationResult = ssize_t;
|
||||
|
||||
//! \brief A value that can never be a valid FileHandle.
|
||||
const FileHandle kInvalidFileHandle = -1;
|
||||
|
||||
using FileOperationResult = ssize_t;
|
||||
|
||||
#elif defined(OS_WIN)
|
||||
|
||||
using FileHandle = HANDLE;
|
||||
@ -109,19 +110,28 @@ enum class StdioStream {
|
||||
|
||||
namespace internal {
|
||||
|
||||
#if defined(OS_POSIX) || DOXYGEN
|
||||
|
||||
//! \brief The name of the native read function used by ReadFile().
|
||||
//!
|
||||
//! This value may be useful for logging.
|
||||
//!
|
||||
//! \sa kNativeWriteFunctionName
|
||||
extern const char kNativeReadFunctionName[];
|
||||
constexpr char kNativeReadFunctionName[] = "read";
|
||||
|
||||
//! \brief The name of the native write function used by WriteFile().
|
||||
//!
|
||||
//! This value may be useful for logging.
|
||||
//!
|
||||
//! \sa kNativeReadFunctionName
|
||||
extern const char kNativeWriteFunctionName[];
|
||||
constexpr char kNativeWriteFunctionName[] = "write";
|
||||
|
||||
#elif defined(OS_WIN)
|
||||
|
||||
constexpr char kNativeReadFunctionName[] = "ReadFile";
|
||||
constexpr char kNativeWriteFunctionName[] = "WriteFile";
|
||||
|
||||
#endif
|
||||
|
||||
//! \brief The internal implementation of ReadFileExactly() and its wrappers.
|
||||
//!
|
||||
|
@ -96,9 +96,6 @@ FileHandle OpenFileForOutput(int rdwr_or_wronly,
|
||||
|
||||
namespace internal {
|
||||
|
||||
const char kNativeReadFunctionName[] = "read";
|
||||
const char kNativeWriteFunctionName[] = "write";
|
||||
|
||||
FileOperationResult NativeWriteFile(FileHandle file,
|
||||
const void* buffer,
|
||||
size_t size) {
|
||||
|
@ -84,9 +84,6 @@ FileHandle OpenFileForOutput(DWORD access,
|
||||
|
||||
namespace internal {
|
||||
|
||||
const char kNativeReadFunctionName[] = "ReadFile";
|
||||
const char kNativeWriteFunctionName[] = "WriteFile";
|
||||
|
||||
FileOperationResult NativeWriteFile(FileHandle file,
|
||||
const void* buffer,
|
||||
size_t size) {
|
||||
|
@ -32,12 +32,12 @@ using testing::Return;
|
||||
// Fake Mach ports. These aren’t used as ports in these tests, they’re just used
|
||||
// as cookies to make sure that the correct values get passed to the correct
|
||||
// places.
|
||||
const mach_port_t kServerLocalPort = 0x05050505;
|
||||
const mach_port_t kCheckInPort = 0x06060606;
|
||||
constexpr mach_port_t kServerLocalPort = 0x05050505;
|
||||
constexpr mach_port_t kCheckInPort = 0x06060606;
|
||||
|
||||
// Other fake values.
|
||||
const mach_msg_type_name_t kCheckInPortRightType = MACH_MSG_TYPE_PORT_SEND;
|
||||
const child_port_token_t kCheckInToken = 0xfedcba9876543210;
|
||||
constexpr mach_msg_type_name_t kCheckInPortRightType = MACH_MSG_TYPE_PORT_SEND;
|
||||
constexpr child_port_token_t kCheckInToken = 0xfedcba9876543210;
|
||||
|
||||
// The definition of the request structure from child_port.h isn’t available
|
||||
// here. It needs custom initialization code, so duplicate the expected
|
||||
|
@ -43,28 +43,28 @@ using testing::Return;
|
||||
// Fake Mach ports. These aren’t used as ports in these tests, they’re just used
|
||||
// as cookies to make sure that the correct values get passed to the correct
|
||||
// places.
|
||||
const mach_port_t kClientRemotePort = 0x01010101;
|
||||
const mach_port_t kServerLocalPort = 0x02020202;
|
||||
const thread_t kExceptionThreadPort = 0x03030303;
|
||||
const task_t kExceptionTaskPort = 0x04040404;
|
||||
constexpr mach_port_t kClientRemotePort = 0x01010101;
|
||||
constexpr mach_port_t kServerLocalPort = 0x02020202;
|
||||
constexpr thread_t kExceptionThreadPort = 0x03030303;
|
||||
constexpr task_t kExceptionTaskPort = 0x04040404;
|
||||
|
||||
// Other fake exception values.
|
||||
const exception_type_t kExceptionType = EXC_BAD_ACCESS;
|
||||
constexpr exception_type_t kExceptionType = EXC_BAD_ACCESS;
|
||||
|
||||
// Test using an exception code with the high bit set to ensure that it gets
|
||||
// promoted to the wider mach_exception_data_type_t type as a signed quantity.
|
||||
const exception_data_type_t kTestExceptonCodes[] = {
|
||||
constexpr exception_data_type_t kTestExceptonCodes[] = {
|
||||
KERN_PROTECTION_FAILURE,
|
||||
implicit_cast<exception_data_type_t>(0xfedcba98),
|
||||
};
|
||||
|
||||
const mach_exception_data_type_t kTestMachExceptionCodes[] = {
|
||||
constexpr mach_exception_data_type_t kTestMachExceptionCodes[] = {
|
||||
KERN_PROTECTION_FAILURE,
|
||||
implicit_cast<mach_exception_data_type_t>(0xfedcba9876543210),
|
||||
};
|
||||
|
||||
const thread_state_flavor_t kThreadStateFlavor = MACHINE_THREAD_STATE;
|
||||
const mach_msg_type_number_t kThreadStateFlavorCount =
|
||||
constexpr thread_state_flavor_t kThreadStateFlavor = MACHINE_THREAD_STATE;
|
||||
constexpr mach_msg_type_number_t kThreadStateFlavorCount =
|
||||
MACHINE_THREAD_STATE_COUNT;
|
||||
|
||||
void InitializeMachMsgPortDescriptor(mach_msg_port_descriptor_t* descriptor,
|
||||
|
@ -34,9 +34,9 @@ struct BootstrapCheckInTraits {
|
||||
mach_port_t* service_port) {
|
||||
return bootstrap_check_in(bootstrap_port, service_name, service_port);
|
||||
}
|
||||
static const char kName[];
|
||||
static constexpr char kName[] = "bootstrap_check_in";
|
||||
};
|
||||
const char BootstrapCheckInTraits::kName[] = "bootstrap_check_in";
|
||||
constexpr char BootstrapCheckInTraits::kName[];
|
||||
|
||||
struct BootstrapLookUpTraits {
|
||||
using Type = base::mac::ScopedMachSendRight;
|
||||
@ -45,9 +45,9 @@ struct BootstrapLookUpTraits {
|
||||
mach_port_t* service_port) {
|
||||
return bootstrap_look_up(bootstrap_port, service_name, service_port);
|
||||
}
|
||||
static const char kName[];
|
||||
static constexpr char kName[] = "bootstrap_look_up";
|
||||
};
|
||||
const char BootstrapLookUpTraits::kName[] = "bootstrap_look_up";
|
||||
constexpr char BootstrapLookUpTraits::kName[];
|
||||
|
||||
template <typename Traits>
|
||||
typename Traits::Type BootstrapCheckInOrLookUp(
|
||||
|
@ -30,7 +30,7 @@ namespace crashpad {
|
||||
//! are not performed, use kMachPortNull instead of an explicit `implicit_cast`
|
||||
//! of `MACH_PORT_NULL` to `mach_port_t`. This is useful for logging and testing
|
||||
//! assertions.
|
||||
const mach_port_t kMachPortNull = MACH_PORT_NULL;
|
||||
constexpr mach_port_t kMachPortNull = MACH_PORT_NULL;
|
||||
|
||||
//! \brief `MACH_EXCEPTION_CODES` with the correct type for a Mach exception
|
||||
//! behavior, `exception_behavior_t`.
|
||||
@ -38,7 +38,7 @@ const mach_port_t kMachPortNull = MACH_PORT_NULL;
|
||||
//! Signedness problems can occur when ORing `MACH_EXCEPTION_CODES` as a signed
|
||||
//! integer, because a signed integer overflow results. This constant can be
|
||||
//! used instead of `MACH_EXCEPTION_CODES` in such cases.
|
||||
const exception_behavior_t kMachExceptionCodes = MACH_EXCEPTION_CODES;
|
||||
constexpr exception_behavior_t kMachExceptionCodes = MACH_EXCEPTION_CODES;
|
||||
|
||||
// Because exception_mask_t is an int and has one bit for each defined
|
||||
// exception_type_t, it’s reasonable to assume that there cannot be any
|
||||
@ -49,7 +49,7 @@ const exception_behavior_t kMachExceptionCodes = MACH_EXCEPTION_CODES;
|
||||
// EXC_MASK_CRASH.
|
||||
|
||||
//! \brief An exception type to use for simulated exceptions.
|
||||
const exception_type_t kMachExceptionSimulated = 'CPsx';
|
||||
constexpr exception_type_t kMachExceptionSimulated = 'CPsx';
|
||||
|
||||
//! \brief A const version of `thread_state_t`.
|
||||
//!
|
||||
|
@ -62,7 +62,7 @@ TEST(MachExtensions, NewMachPort_DeadName) {
|
||||
EXPECT_EQ(type, MACH_PORT_TYPE_DEAD_NAME);
|
||||
}
|
||||
|
||||
const exception_mask_t kExcMaskBasic =
|
||||
constexpr exception_mask_t kExcMaskBasic =
|
||||
EXC_MASK_BAD_ACCESS |
|
||||
EXC_MASK_BAD_INSTRUCTION |
|
||||
EXC_MASK_ARITHMETIC |
|
||||
|
@ -28,7 +28,7 @@ namespace crashpad {
|
||||
|
||||
namespace {
|
||||
|
||||
const int kNanosecondsPerMillisecond = 1E6;
|
||||
constexpr int kNanosecondsPerMillisecond = 1E6;
|
||||
|
||||
// TimerRunning() determines whether |deadline| has passed. If |deadline| is
|
||||
// kMachMessageDeadlineWaitIndefinitely, |*timeout_options| is set to
|
||||
|
@ -26,7 +26,7 @@ namespace crashpad {
|
||||
//!
|
||||
//! This constant is provided because the macros normally used to request this
|
||||
//! behavior are cumbersome.
|
||||
const mach_msg_option_t kMachMessageReceiveAuditTrailer =
|
||||
constexpr mach_msg_option_t kMachMessageReceiveAuditTrailer =
|
||||
MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0) |
|
||||
MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT);
|
||||
|
||||
|
@ -147,9 +147,9 @@ struct ConvertExceptionTraits {
|
||||
ValueType* value) {
|
||||
return StringToException(string, options, value);
|
||||
}
|
||||
static const char kValueName[];
|
||||
static constexpr char kValueName[] = "exception";
|
||||
};
|
||||
const char ConvertExceptionTraits::kValueName[] = "exception";
|
||||
constexpr char ConvertExceptionTraits::kValueName[];
|
||||
|
||||
void TestExceptionToString(exception_type_t value,
|
||||
const char* expect_full,
|
||||
@ -322,9 +322,9 @@ struct ConvertExceptionMaskTraits {
|
||||
ValueType* value) {
|
||||
return StringToExceptionMask(string, options, value);
|
||||
}
|
||||
static const char kValueName[];
|
||||
static constexpr char kValueName[] = "exception_mask";
|
||||
};
|
||||
const char ConvertExceptionMaskTraits::kValueName[] = "exception_mask";
|
||||
constexpr char ConvertExceptionMaskTraits::kValueName[];
|
||||
|
||||
void TestExceptionMaskToString(exception_mask_t value,
|
||||
const char* expect_full,
|
||||
@ -565,9 +565,9 @@ struct ConvertExceptionBehaviorTraits {
|
||||
ValueType* value) {
|
||||
return StringToExceptionBehavior(string, options, value);
|
||||
}
|
||||
static const char kValueName[];
|
||||
static constexpr char kValueName[] = "behavior";
|
||||
};
|
||||
const char ConvertExceptionBehaviorTraits::kValueName[] = "behavior";
|
||||
constexpr char ConvertExceptionBehaviorTraits::kValueName[];
|
||||
|
||||
void TestExceptionBehaviorToString(exception_behavior_t value,
|
||||
const char* expect_full,
|
||||
@ -828,9 +828,9 @@ struct ConvertThreadStateFlavorTraits {
|
||||
ValueType* value) {
|
||||
return StringToThreadStateFlavor(string, options, value);
|
||||
}
|
||||
static const char kValueName[];
|
||||
static constexpr char kValueName[] = "flavor";
|
||||
};
|
||||
const char ConvertThreadStateFlavorTraits::kValueName[] = "flavor";
|
||||
constexpr char ConvertThreadStateFlavorTraits::kValueName[];
|
||||
|
||||
void TestThreadStateFlavorToString(exception_type_t value,
|
||||
const char* expect_full,
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
const uint64_t kNanosecondsPerSecond = 1E9;
|
||||
constexpr uint64_t kNanosecondsPerSecond = 1E9;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -1,23 +0,0 @@
|
||||
// Copyright 2014 The Crashpad Authors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "util/net/http_headers.h"
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
const char kContentType[] = "Content-Type";
|
||||
const char kContentLength[] = "Content-Length";
|
||||
const char kContentEncoding[] = "Content-Encoding";
|
||||
|
||||
} // namespace crashpad
|
@ -24,13 +24,13 @@ namespace crashpad {
|
||||
using HTTPHeaders = std::map<std::string, std::string>;
|
||||
|
||||
//! \brief The header name `"Content-Type"`.
|
||||
extern const char kContentType[];
|
||||
constexpr char kContentType[] = "Content-Type";
|
||||
|
||||
//! \brief The header name `"Content-Length"`.
|
||||
extern const char kContentLength[];
|
||||
constexpr char kContentLength[] = "Content-Length";
|
||||
|
||||
//! \brief The header name `"Content-Encoding"`.
|
||||
extern const char kContentEncoding[];
|
||||
constexpr char kContentEncoding[] = "Content-Encoding";
|
||||
|
||||
} // namespace crashpad
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace crashpad {
|
||||
|
||||
namespace {
|
||||
|
||||
const wchar_t kWinHttpDll[] = L"winhttp.dll";
|
||||
constexpr wchar_t kWinHttpDll[] = L"winhttp.dll";
|
||||
|
||||
std::string UserAgent() {
|
||||
std::string user_agent =
|
||||
|
@ -25,8 +25,8 @@ namespace crashpad {
|
||||
namespace test {
|
||||
namespace {
|
||||
|
||||
const int32_t kInt32Min = std::numeric_limits<int32_t>::min();
|
||||
const int64_t kInt64Min = std::numeric_limits<int64_t>::min();
|
||||
constexpr int32_t kInt32Min = std::numeric_limits<int32_t>::min();
|
||||
constexpr int64_t kInt64Min = std::numeric_limits<int64_t>::min();
|
||||
|
||||
TEST(InRangeCast, Uint32) {
|
||||
EXPECT_EQ(InRangeCast<uint32_t>(0, 1), 0u);
|
||||
|
@ -22,7 +22,7 @@ namespace crashpad {
|
||||
namespace test {
|
||||
namespace {
|
||||
|
||||
const uint64_t kNanosecondsPerSecond = static_cast<uint64_t>(1E9);
|
||||
constexpr uint64_t kNanosecondsPerSecond = static_cast<uint64_t>(1E9);
|
||||
|
||||
class WorkDelegate : public WorkerThread::Delegate {
|
||||
public:
|
||||
|
@ -140,7 +140,6 @@
|
||||
'net/http_body.h',
|
||||
'net/http_body_gzip.cc',
|
||||
'net/http_body_gzip.h',
|
||||
'net/http_headers.cc',
|
||||
'net/http_headers.h',
|
||||
'net/http_multipart_builder.cc',
|
||||
'net/http_multipart_builder.h',
|
||||
|
@ -22,7 +22,7 @@ namespace crashpad {
|
||||
|
||||
namespace {
|
||||
|
||||
const uint64_t kMicrosecondsPerSecond = static_cast<uint64_t>(1E6);
|
||||
constexpr uint64_t kMicrosecondsPerSecond = static_cast<uint64_t>(1E6);
|
||||
|
||||
uint64_t FiletimeToMicroseconds(const FILETIME& filetime) {
|
||||
uint64_t t = (static_cast<uint64_t>(filetime.dwHighDateTime) << 32) |
|
||||
|
Loading…
x
Reference in New Issue
Block a user