Commit c9abc311 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[base][cleanup] Using 'using' instead of 'typedef'

Even though both are allowed in the style guide, it recommends to use
'using', as its syntax is more consistent with the rest of C++.
This CL turns all typedefs in base code to 'using' declarations.

R=mlippautz@chromium.org

Bug: v8:8834
Change-Id: Ic5c3d7fa2e50938c6f43e9ff304dc2289fed1133
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1547650Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60546}
parent b1a91ce5
...@@ -15,7 +15,7 @@ namespace base { ...@@ -15,7 +15,7 @@ namespace base {
// Helper class representing an address region of certain size. // Helper class representing an address region of certain size.
class AddressRegion { class AddressRegion {
public: public:
typedef uintptr_t Address; using Address = uintptr_t;
AddressRegion() = default; AddressRegion() = default;
......
...@@ -39,22 +39,22 @@ ...@@ -39,22 +39,22 @@
namespace v8 { namespace v8 {
namespace base { namespace base {
typedef char Atomic8; using Atomic8 = char;
typedef int16_t Atomic16; using Atomic16 = int16_t;
typedef int32_t Atomic32; using Atomic32 = int32_t;
#if defined(V8_HOST_ARCH_64_BIT) #if defined(V8_HOST_ARCH_64_BIT)
// We need to be able to go between Atomic64 and AtomicWord implicitly. This // We need to be able to go between Atomic64 and AtomicWord implicitly. This
// means Atomic64 and AtomicWord should be the same type on 64-bit. // means Atomic64 and AtomicWord should be the same type on 64-bit.
#if defined(__ILP32__) #if defined(__ILP32__)
typedef int64_t Atomic64; using Atomic64 = int64_t;
#else #else
typedef intptr_t Atomic64; using Atomic64 = intptr_t;
#endif // defined(__ILP32__) #endif // defined(__ILP32__)
#endif // defined(V8_HOST_ARCH_64_BIT) #endif // defined(V8_HOST_ARCH_64_BIT)
// Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or // Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or
// Atomic64 routines below, depending on your architecture. // Atomic64 routines below, depending on your architecture.
typedef intptr_t AtomicWord; using AtomicWord = intptr_t;
// Atomically execute: // Atomically execute:
// result = *ptr; // result = *ptr;
......
...@@ -25,7 +25,7 @@ namespace base { ...@@ -25,7 +25,7 @@ namespace base {
// The implementation is thread-safe. // The implementation is thread-safe.
class V8_BASE_EXPORT BoundedPageAllocator : public v8::PageAllocator { class V8_BASE_EXPORT BoundedPageAllocator : public v8::PageAllocator {
public: public:
typedef uintptr_t Address; using Address = uintptr_t;
BoundedPageAllocator(v8::PageAllocator* page_allocator, Address start, BoundedPageAllocator(v8::PageAllocator* page_allocator, Address start,
size_t size, size_t allocate_page_size); size_t size, size_t allocate_page_size);
......
...@@ -24,8 +24,8 @@ namespace base { ...@@ -24,8 +24,8 @@ namespace base {
template <typename T, typename S = int> template <typename T, typename S = int>
class Flags final { class Flags final {
public: public:
typedef T flag_type; using flag_type = T;
typedef S mask_type; using mask_type = S;
constexpr Flags() : mask_(0) {} constexpr Flags() : mask_(0) {}
constexpr Flags(flag_type flag) // NOLINT(runtime/explicit) constexpr Flags(flag_type flag) // NOLINT(runtime/explicit)
......
...@@ -27,7 +27,7 @@ class DefaultAllocationPolicy { ...@@ -27,7 +27,7 @@ class DefaultAllocationPolicy {
template <typename Key, typename Value, class MatchFun, class AllocationPolicy> template <typename Key, typename Value, class MatchFun, class AllocationPolicy>
class TemplateHashMapImpl { class TemplateHashMapImpl {
public: public:
typedef TemplateHashMapEntry<Key, Value> Entry; using Entry = TemplateHashMapEntry<Key, Value>;
// The default capacity. This is used by the call sites which want // The default capacity. This is used by the call sites which want
// to pass in a non-default AllocationPolicy but want to use the // to pass in a non-default AllocationPolicy but want to use the
...@@ -389,13 +389,12 @@ class CustomMatcherTemplateHashMapImpl ...@@ -389,13 +389,12 @@ class CustomMatcherTemplateHashMapImpl
void*, void*, void*, void*,
HashEqualityThenKeyMatcher<void*, bool (*)(void*, void*)>, HashEqualityThenKeyMatcher<void*, bool (*)(void*, void*)>,
AllocationPolicy> { AllocationPolicy> {
typedef TemplateHashMapImpl< using Base = TemplateHashMapImpl<
void*, void*, HashEqualityThenKeyMatcher<void*, bool (*)(void*, void*)>, void*, void*, HashEqualityThenKeyMatcher<void*, bool (*)(void*, void*)>,
AllocationPolicy> AllocationPolicy>;
Base;
public: public:
typedef bool (*MatchFun)(void*, void*); using MatchFun = bool (*)(void*, void*);
CustomMatcherTemplateHashMapImpl( CustomMatcherTemplateHashMapImpl(
MatchFun match, uint32_t capacity = Base::kDefaultHashMapCapacity, MatchFun match, uint32_t capacity = Base::kDefaultHashMapCapacity,
...@@ -412,8 +411,8 @@ class CustomMatcherTemplateHashMapImpl ...@@ -412,8 +411,8 @@ class CustomMatcherTemplateHashMapImpl
DISALLOW_COPY_AND_ASSIGN(CustomMatcherTemplateHashMapImpl); DISALLOW_COPY_AND_ASSIGN(CustomMatcherTemplateHashMapImpl);
}; };
typedef CustomMatcherTemplateHashMapImpl<DefaultAllocationPolicy> using CustomMatcherHashMap =
CustomMatcherHashMap; CustomMatcherTemplateHashMapImpl<DefaultAllocationPolicy>;
// Match function which compares keys directly by equality. // Match function which compares keys directly by equality.
template <typename Key> template <typename Key>
...@@ -429,9 +428,8 @@ template <typename AllocationPolicy> ...@@ -429,9 +428,8 @@ template <typename AllocationPolicy>
class PointerTemplateHashMapImpl class PointerTemplateHashMapImpl
: public TemplateHashMapImpl<void*, void*, KeyEqualityMatcher<void*>, : public TemplateHashMapImpl<void*, void*, KeyEqualityMatcher<void*>,
AllocationPolicy> { AllocationPolicy> {
typedef TemplateHashMapImpl<void*, void*, KeyEqualityMatcher<void*>, using Base = TemplateHashMapImpl<void*, void*, KeyEqualityMatcher<void*>,
AllocationPolicy> AllocationPolicy>;
Base;
public: public:
PointerTemplateHashMapImpl(uint32_t capacity = Base::kDefaultHashMapCapacity, PointerTemplateHashMapImpl(uint32_t capacity = Base::kDefaultHashMapCapacity,
...@@ -439,7 +437,7 @@ class PointerTemplateHashMapImpl ...@@ -439,7 +437,7 @@ class PointerTemplateHashMapImpl
: Base(capacity, KeyEqualityMatcher<void*>(), allocator) {} : Base(capacity, KeyEqualityMatcher<void*>(), allocator) {}
}; };
typedef PointerTemplateHashMapImpl<DefaultAllocationPolicy> HashMap; using HashMap = PointerTemplateHashMapImpl<DefaultAllocationPolicy>;
// A hash map for pointer keys and values with an STL-like interface. // A hash map for pointer keys and values with an STL-like interface.
template <class Key, class Value, class MatchFun, class AllocationPolicy> template <class Key, class Value, class MatchFun, class AllocationPolicy>
...@@ -447,10 +445,9 @@ class TemplateHashMap ...@@ -447,10 +445,9 @@ class TemplateHashMap
: private TemplateHashMapImpl<void*, void*, : private TemplateHashMapImpl<void*, void*,
HashEqualityThenKeyMatcher<void*, MatchFun>, HashEqualityThenKeyMatcher<void*, MatchFun>,
AllocationPolicy> { AllocationPolicy> {
typedef TemplateHashMapImpl<void*, void*, using Base = TemplateHashMapImpl<void*, void*,
HashEqualityThenKeyMatcher<void*, MatchFun>, HashEqualityThenKeyMatcher<void*, MatchFun>,
AllocationPolicy> AllocationPolicy>;
Base;
public: public:
STATIC_ASSERT(sizeof(Key*) == sizeof(void*)); // NOLINT STATIC_ASSERT(sizeof(Key*) == sizeof(void*)); // NOLINT
......
...@@ -57,7 +57,7 @@ namespace { ...@@ -57,7 +57,7 @@ namespace {
#if V8_TARGET_LITTLE_ENDIAN #if V8_TARGET_LITTLE_ENDIAN
typedef union { union ieee_double_shape_type {
double value; double value;
struct { struct {
uint32_t lsw; uint32_t lsw;
...@@ -66,11 +66,11 @@ typedef union { ...@@ -66,11 +66,11 @@ typedef union {
struct { struct {
uint64_t w; uint64_t w;
} xparts; } xparts;
} ieee_double_shape_type; };
#else #else
typedef union { union ieee_double_shape_type {
double value; double value;
struct { struct {
uint32_t msw; uint32_t msw;
...@@ -79,7 +79,7 @@ typedef union { ...@@ -79,7 +79,7 @@ typedef union {
struct { struct {
uint64_t w; uint64_t w;
} xparts; } xparts;
} ieee_double_shape_type; };
#endif #endif
......
...@@ -13,11 +13,11 @@ namespace base { ...@@ -13,11 +13,11 @@ namespace base {
template <class Category, class Type, class Diff = std::ptrdiff_t, template <class Category, class Type, class Diff = std::ptrdiff_t,
class Pointer = Type*, class Reference = Type&> class Pointer = Type*, class Reference = Type&>
struct iterator { struct iterator {
typedef Category iterator_category; using iterator_category = Category;
typedef Type value_type; using value_type = Type;
typedef Diff difference_type; using difference_type = Diff;
typedef Pointer pointer; using pointer = Pointer;
typedef Reference reference; using reference = Reference;
}; };
// The intention of the base::iterator_range class is to encapsulate two // The intention of the base::iterator_range class is to encapsulate two
...@@ -27,13 +27,13 @@ struct iterator { ...@@ -27,13 +27,13 @@ struct iterator {
template <typename ForwardIterator> template <typename ForwardIterator>
class iterator_range { class iterator_range {
public: public:
typedef ForwardIterator iterator; using iterator = ForwardIterator;
typedef ForwardIterator const_iterator; using const_iterator = ForwardIterator;
typedef typename std::iterator_traits<iterator>::pointer pointer; using pointer = typename std::iterator_traits<iterator>::pointer;
typedef typename std::iterator_traits<iterator>::reference reference; using reference = typename std::iterator_traits<iterator>::reference;
typedef typename std::iterator_traits<iterator>::value_type value_type; using value_type = typename std::iterator_traits<iterator>::value_type;
typedef using difference_type =
typename std::iterator_traits<iterator>::difference_type difference_type; typename std::iterator_traits<iterator>::difference_type;
iterator_range() : begin_(), end_() {} iterator_range() : begin_(), end_() {}
template <typename ForwardIterator1, typename ForwardIterator2> template <typename ForwardIterator1, typename ForwardIterator2>
......
...@@ -199,8 +199,8 @@ template <typename T, ...@@ -199,8 +199,8 @@ template <typename T,
typename InitOnceTrait = ThreadSafeInitOnceTrait, typename InitOnceTrait = ThreadSafeInitOnceTrait,
typename DestroyTrait = LeakyInstanceTrait<T> > typename DestroyTrait = LeakyInstanceTrait<T> >
struct LazyStaticInstance { struct LazyStaticInstance {
typedef LazyInstanceImpl<T, StaticallyAllocatedInstanceTrait<T>, using type = LazyInstanceImpl<T, StaticallyAllocatedInstanceTrait<T>,
CreateTrait, InitOnceTrait, DestroyTrait> type; CreateTrait, InitOnceTrait, DestroyTrait>;
}; };
...@@ -210,8 +210,8 @@ template <typename T, ...@@ -210,8 +210,8 @@ template <typename T,
typename DestroyTrait = LeakyInstanceTrait<T> > typename DestroyTrait = LeakyInstanceTrait<T> >
struct LazyInstance { struct LazyInstance {
// A LazyInstance is a LazyStaticInstance. // A LazyInstance is a LazyStaticInstance.
typedef typename LazyStaticInstance<T, CreateTrait, InitOnceTrait, using type = typename LazyStaticInstance<T, CreateTrait, InitOnceTrait,
DestroyTrait>::type type; DestroyTrait>::type;
}; };
...@@ -220,8 +220,8 @@ template <typename T, ...@@ -220,8 +220,8 @@ template <typename T,
typename InitOnceTrait = ThreadSafeInitOnceTrait, typename InitOnceTrait = ThreadSafeInitOnceTrait,
typename DestroyTrait = LeakyInstanceTrait<T> > typename DestroyTrait = LeakyInstanceTrait<T> >
struct LazyDynamicInstance { struct LazyDynamicInstance {
typedef LazyInstanceImpl<T, DynamicallyAllocatedInstanceTrait<T>, using type = LazyInstanceImpl<T, DynamicallyAllocatedInstanceTrait<T>,
CreateTrait, InitOnceTrait, DestroyTrait> type; CreateTrait, InitOnceTrait, DestroyTrait>;
}; };
// LeakyObject<T> wraps an object of type T, which is initialized in the // LeakyObject<T> wraps an object of type T, which is initialized in the
......
...@@ -74,11 +74,11 @@ enum : uint8_t { ...@@ -74,11 +74,11 @@ enum : uint8_t {
ONCE_STATE_DONE = 2 ONCE_STATE_DONE = 2
}; };
typedef void (*PointerArgFunction)(void* arg); using PointerArgFunction = void (*)(void* arg);
template <typename T> template <typename T>
struct OneArgFunction { struct OneArgFunction {
typedef void (*type)(T); using type = void (*)(T);
}; };
V8_BASE_EXPORT void CallOnceImpl(OnceType* once, V8_BASE_EXPORT void CallOnceImpl(OnceType* once,
......
...@@ -24,7 +24,7 @@ namespace base { ...@@ -24,7 +24,7 @@ namespace base {
template <typename signed_type> \ template <typename signed_type> \
inline signed_type Name##WithWraparound(signed_type a, signed_type b) { \ inline signed_type Name##WithWraparound(signed_type a, signed_type b) { \
ASSERT_SIGNED_INTEGER_TYPE(signed_type); \ ASSERT_SIGNED_INTEGER_TYPE(signed_type); \
typedef typename std::make_unsigned<signed_type>::type unsigned_type; \ using unsigned_type = typename std::make_unsigned<signed_type>::type; \
unsigned_type a_unsigned = static_cast<unsigned_type>(a); \ unsigned_type a_unsigned = static_cast<unsigned_type>(a); \
unsigned_type b_unsigned = static_cast<unsigned_type>(b); \ unsigned_type b_unsigned = static_cast<unsigned_type>(b); \
unsigned_type result = a_unsigned OP b_unsigned; \ unsigned_type result = a_unsigned OP b_unsigned; \
...@@ -57,7 +57,7 @@ inline signed_type NegateWithWraparound(signed_type a) { ...@@ -57,7 +57,7 @@ inline signed_type NegateWithWraparound(signed_type a) {
template <typename signed_type> template <typename signed_type>
inline signed_type ShlWithWraparound(signed_type a, signed_type b) { inline signed_type ShlWithWraparound(signed_type a, signed_type b) {
ASSERT_SIGNED_INTEGER_TYPE(signed_type); ASSERT_SIGNED_INTEGER_TYPE(signed_type);
typedef typename std::make_unsigned<signed_type>::type unsigned_type; using unsigned_type = typename std::make_unsigned<signed_type>::type;
const unsigned_type kMask = (sizeof(a) * 8) - 1; const unsigned_type kMask = (sizeof(a) * 8) - 1;
return static_cast<signed_type>(static_cast<unsigned_type>(a) << (b & kMask)); return static_cast<signed_type>(static_cast<unsigned_type>(a) << (b & kMask));
} }
......
...@@ -61,9 +61,9 @@ class V8_BASE_EXPORT ConditionVariable final { ...@@ -61,9 +61,9 @@ class V8_BASE_EXPORT ConditionVariable final {
// The implementation-defined native handle type. // The implementation-defined native handle type.
#if V8_OS_POSIX #if V8_OS_POSIX
typedef pthread_cond_t NativeHandle; using NativeHandle = pthread_cond_t;
#elif V8_OS_WIN #elif V8_OS_WIN
typedef CONDITION_VARIABLE NativeHandle; using NativeHandle = CONDITION_VARIABLE;
#endif #endif
NativeHandle& native_handle() { NativeHandle& native_handle() {
...@@ -89,9 +89,10 @@ class V8_BASE_EXPORT ConditionVariable final { ...@@ -89,9 +89,10 @@ class V8_BASE_EXPORT ConditionVariable final {
// MutexGuard lock_guard(&my_mutex); // MutexGuard lock_guard(&my_mutex);
// my_condvar.Pointer()->Wait(&my_mutex); // my_condvar.Pointer()->Wait(&my_mutex);
// } // }
typedef LazyStaticInstance< using LazyConditionVariable =
ConditionVariable, DefaultConstructTrait<ConditionVariable>, LazyStaticInstance<ConditionVariable,
ThreadSafeInitOnceTrait>::type LazyConditionVariable; DefaultConstructTrait<ConditionVariable>,
ThreadSafeInitOnceTrait>::type;
#define LAZY_CONDITION_VARIABLE_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER #define LAZY_CONDITION_VARIABLE_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER
......
...@@ -55,9 +55,9 @@ class V8_BASE_EXPORT Mutex final { ...@@ -55,9 +55,9 @@ class V8_BASE_EXPORT Mutex final {
// The implementation-defined native handle type. // The implementation-defined native handle type.
#if V8_OS_POSIX #if V8_OS_POSIX
typedef pthread_mutex_t NativeHandle; using NativeHandle = pthread_mutex_t;
#elif V8_OS_WIN #elif V8_OS_WIN
typedef SRWLOCK NativeHandle; using NativeHandle = SRWLOCK;
#endif #endif
NativeHandle& native_handle() { NativeHandle& native_handle() {
...@@ -101,8 +101,8 @@ class V8_BASE_EXPORT Mutex final { ...@@ -101,8 +101,8 @@ class V8_BASE_EXPORT Mutex final {
// // Do something. // // Do something.
// } // }
// //
typedef LazyStaticInstance<Mutex, DefaultConstructTrait<Mutex>, using LazyMutex = LazyStaticInstance<Mutex, DefaultConstructTrait<Mutex>,
ThreadSafeInitOnceTrait>::type LazyMutex; ThreadSafeInitOnceTrait>::type;
#define LAZY_MUTEX_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER #define LAZY_MUTEX_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER
...@@ -153,9 +153,9 @@ class V8_BASE_EXPORT RecursiveMutex final { ...@@ -153,9 +153,9 @@ class V8_BASE_EXPORT RecursiveMutex final {
private: private:
// The implementation-defined native handle type. // The implementation-defined native handle type.
#if V8_OS_POSIX #if V8_OS_POSIX
typedef pthread_mutex_t NativeHandle; using NativeHandle = pthread_mutex_t;
#elif V8_OS_WIN #elif V8_OS_WIN
typedef CRITICAL_SECTION NativeHandle; using NativeHandle = CRITICAL_SECTION;
#endif #endif
NativeHandle native_handle_; NativeHandle native_handle_;
...@@ -177,9 +177,9 @@ class V8_BASE_EXPORT RecursiveMutex final { ...@@ -177,9 +177,9 @@ class V8_BASE_EXPORT RecursiveMutex final {
// // Do something. // // Do something.
// } // }
// //
typedef LazyStaticInstance<RecursiveMutex, using LazyRecursiveMutex =
DefaultConstructTrait<RecursiveMutex>, LazyStaticInstance<RecursiveMutex, DefaultConstructTrait<RecursiveMutex>,
ThreadSafeInitOnceTrait>::type LazyRecursiveMutex; ThreadSafeInitOnceTrait>::type;
#define LAZY_RECURSIVE_MUTEX_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER #define LAZY_RECURSIVE_MUTEX_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER
...@@ -241,9 +241,9 @@ class V8_BASE_EXPORT SharedMutex final { ...@@ -241,9 +241,9 @@ class V8_BASE_EXPORT SharedMutex final {
private: private:
// The implementation-defined native handle type. // The implementation-defined native handle type.
#if V8_OS_POSIX #if V8_OS_POSIX
typedef pthread_rwlock_t NativeHandle; using NativeHandle = pthread_rwlock_t;
#elif V8_OS_WIN #elif V8_OS_WIN
typedef SRWLOCK NativeHandle; using NativeHandle = SRWLOCK;
#endif #endif
NativeHandle native_handle_; NativeHandle native_handle_;
......
...@@ -1072,58 +1072,44 @@ Win32MemoryMappedFile::~Win32MemoryMappedFile() { ...@@ -1072,58 +1072,44 @@ Win32MemoryMappedFile::~Win32MemoryMappedFile() {
// DbgHelp isn't supported on MinGW yet // DbgHelp isn't supported on MinGW yet
#ifndef __MINGW32__ #ifndef __MINGW32__
// DbgHelp.h functions. // DbgHelp.h functions.
typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymInitialize))(IN HANDLE hProcess, using DLL_FUNC_TYPE(SymInitialize) = BOOL(__stdcall*)(IN HANDLE hProcess,
IN PSTR UserSearchPath, IN PSTR UserSearchPath,
IN BOOL fInvadeProcess); IN BOOL fInvadeProcess);
typedef DWORD (__stdcall *DLL_FUNC_TYPE(SymGetOptions))(VOID); using DLL_FUNC_TYPE(SymGetOptions) = DWORD(__stdcall*)(VOID);
typedef DWORD (__stdcall *DLL_FUNC_TYPE(SymSetOptions))(IN DWORD SymOptions); using DLL_FUNC_TYPE(SymSetOptions) = DWORD(__stdcall*)(IN DWORD SymOptions);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymGetSearchPath))( using DLL_FUNC_TYPE(SymGetSearchPath) = BOOL(__stdcall*)(
IN HANDLE hProcess, IN HANDLE hProcess, OUT PSTR SearchPath, IN DWORD SearchPathLength);
OUT PSTR SearchPath, using DLL_FUNC_TYPE(SymLoadModule64) = DWORD64(__stdcall*)(
IN DWORD SearchPathLength); IN HANDLE hProcess, IN HANDLE hFile, IN PSTR ImageName, IN PSTR ModuleName,
typedef DWORD64 (__stdcall *DLL_FUNC_TYPE(SymLoadModule64))( IN DWORD64 BaseOfDll, IN DWORD SizeOfDll);
IN HANDLE hProcess, using DLL_FUNC_TYPE(StackWalk64) = BOOL(__stdcall*)(
IN HANDLE hFile, DWORD MachineType, HANDLE hProcess, HANDLE hThread,
IN PSTR ImageName, LPSTACKFRAME64 StackFrame, PVOID ContextRecord,
IN PSTR ModuleName,
IN DWORD64 BaseOfDll,
IN DWORD SizeOfDll);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(StackWalk64))(
DWORD MachineType,
HANDLE hProcess,
HANDLE hThread,
LPSTACKFRAME64 StackFrame,
PVOID ContextRecord,
PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine,
PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine,
PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine,
PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress); PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymGetSymFromAddr64))( using DLL_FUNC_TYPE(SymGetSymFromAddr64) = BOOL(__stdcall*)(
IN HANDLE hProcess, IN HANDLE hProcess, IN DWORD64 qwAddr, OUT PDWORD64 pdwDisplacement,
IN DWORD64 qwAddr,
OUT PDWORD64 pdwDisplacement,
OUT PIMAGEHLP_SYMBOL64 Symbol); OUT PIMAGEHLP_SYMBOL64 Symbol);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymGetLineFromAddr64))( using DLL_FUNC_TYPE(SymGetLineFromAddr64) =
IN HANDLE hProcess, BOOL(__stdcall*)(IN HANDLE hProcess, IN DWORD64 qwAddr,
IN DWORD64 qwAddr, OUT PDWORD pdwDisplacement, OUT PIMAGEHLP_LINE64 Line64);
OUT PDWORD pdwDisplacement,
OUT PIMAGEHLP_LINE64 Line64);
// DbgHelp.h typedefs. Implementation found in dbghelp.dll. // DbgHelp.h typedefs. Implementation found in dbghelp.dll.
typedef PVOID (__stdcall *DLL_FUNC_TYPE(SymFunctionTableAccess64))( using DLL_FUNC_TYPE(SymFunctionTableAccess64) = PVOID(__stdcall*)(
HANDLE hProcess, HANDLE hProcess,
DWORD64 AddrBase); // DbgHelp.h typedef PFUNCTION_TABLE_ACCESS_ROUTINE64 DWORD64 AddrBase); // DbgHelp.h typedef PFUNCTION_TABLE_ACCESS_ROUTINE64
typedef DWORD64 (__stdcall *DLL_FUNC_TYPE(SymGetModuleBase64))( using DLL_FUNC_TYPE(SymGetModuleBase64) = DWORD64(__stdcall*)(
HANDLE hProcess, HANDLE hProcess,
DWORD64 AddrBase); // DbgHelp.h typedef PGET_MODULE_BASE_ROUTINE64 DWORD64 AddrBase); // DbgHelp.h typedef PGET_MODULE_BASE_ROUTINE64
// TlHelp32.h functions. // TlHelp32.h functions.
typedef HANDLE (__stdcall *DLL_FUNC_TYPE(CreateToolhelp32Snapshot))( using DLL_FUNC_TYPE(CreateToolhelp32Snapshot) =
DWORD dwFlags, HANDLE(__stdcall*)(DWORD dwFlags, DWORD th32ProcessID);
DWORD th32ProcessID); using DLL_FUNC_TYPE(Module32FirstW) = BOOL(__stdcall*)(HANDLE hSnapshot,
typedef BOOL (__stdcall *DLL_FUNC_TYPE(Module32FirstW))(HANDLE hSnapshot,
LPMODULEENTRY32W lpme);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(Module32NextW))(HANDLE hSnapshot,
LPMODULEENTRY32W lpme); LPMODULEENTRY32W lpme);
using DLL_FUNC_TYPE(Module32NextW) = BOOL(__stdcall*)(HANDLE hSnapshot,
LPMODULEENTRY32W lpme);
#undef IN #undef IN
#undef VOID #undef VOID
......
...@@ -311,7 +311,7 @@ inline void EnsureConsoleOutput() { ...@@ -311,7 +311,7 @@ inline void EnsureConsoleOutput() {
class V8_BASE_EXPORT Thread { class V8_BASE_EXPORT Thread {
public: public:
// Opaque data type for thread-local storage keys. // Opaque data type for thread-local storage keys.
typedef int32_t LocalStorageKey; using LocalStorageKey = int32_t;
class Options { class Options {
public: public:
......
...@@ -50,11 +50,11 @@ class V8_BASE_EXPORT Semaphore final { ...@@ -50,11 +50,11 @@ class V8_BASE_EXPORT Semaphore final {
bool WaitFor(const TimeDelta& rel_time) V8_WARN_UNUSED_RESULT; bool WaitFor(const TimeDelta& rel_time) V8_WARN_UNUSED_RESULT;
#if V8_OS_MACOSX #if V8_OS_MACOSX
typedef semaphore_t NativeHandle; using NativeHandle = semaphore_t;
#elif V8_OS_POSIX #elif V8_OS_POSIX
typedef sem_t NativeHandle; using NativeHandle = sem_t;
#elif V8_OS_WIN #elif V8_OS_WIN
typedef HANDLE NativeHandle; using NativeHandle = HANDLE;
#endif #endif
NativeHandle& native_handle() { NativeHandle& native_handle() {
...@@ -90,8 +90,8 @@ struct CreateSemaphoreTrait { ...@@ -90,8 +90,8 @@ struct CreateSemaphoreTrait {
template <int N> template <int N>
struct LazySemaphore { struct LazySemaphore {
typedef typename LazyDynamicInstance<Semaphore, CreateSemaphoreTrait<N>, using typename LazyDynamicInstance<Semaphore, CreateSemaphoreTrait<N>,
ThreadSafeInitOnceTrait>::type type; ThreadSafeInitOnceTrait>::type;
}; };
#define LAZY_SEMAPHORE_INITIALIZER LAZY_DYNAMIC_INSTANCE_INITIALIZER #define LAZY_SEMAPHORE_INITIALIZER LAZY_DYNAMIC_INSTANCE_INITIALIZER
......
...@@ -25,7 +25,7 @@ namespace base { ...@@ -25,7 +25,7 @@ namespace base {
// Not thread-safe. // Not thread-safe.
class V8_BASE_EXPORT RegionAllocator final { class V8_BASE_EXPORT RegionAllocator final {
public: public:
typedef uintptr_t Address; using Address = uintptr_t;
static constexpr Address kAllocationFailure = static_cast<Address>(-1); static constexpr Address kAllocationFailure = static_cast<Address>(-1);
...@@ -121,7 +121,7 @@ class V8_BASE_EXPORT RegionAllocator final { ...@@ -121,7 +121,7 @@ class V8_BASE_EXPORT RegionAllocator final {
} }
}; };
// All regions ordered by addresses. // All regions ordered by addresses.
typedef std::set<Region*, AddressEndOrder> AllRegionsSet; using AllRegionsSet = std::set<Region*, AddressEndOrder>;
AllRegionsSet all_regions_; AllRegionsSet all_regions_;
struct SizeAddressOrder { struct SizeAddressOrder {
......
...@@ -47,7 +47,7 @@ namespace internal { ...@@ -47,7 +47,7 @@ namespace internal {
template <typename T> template <typename T>
class CheckedNumeric { class CheckedNumeric {
public: public:
typedef T type; using type = T;
CheckedNumeric() = default; CheckedNumeric() = default;
...@@ -200,7 +200,7 @@ class CheckedNumeric { ...@@ -200,7 +200,7 @@ class CheckedNumeric {
template <typename T> \ template <typename T> \
CheckedNumeric<typename ArithmeticPromotion<T>::type> operator OP( \ CheckedNumeric<typename ArithmeticPromotion<T>::type> operator OP( \
const CheckedNumeric<T>& lhs, const CheckedNumeric<T>& rhs) { \ const CheckedNumeric<T>& lhs, const CheckedNumeric<T>& rhs) { \
typedef typename ArithmeticPromotion<T>::type Promotion; \ using Promotion = typename ArithmeticPromotion<T>::type; \
/* Floating point always takes the fast path */ \ /* Floating point always takes the fast path */ \
if (std::numeric_limits<T>::is_iec559) \ if (std::numeric_limits<T>::is_iec559) \
return CheckedNumeric<T>(lhs.ValueUnsafe() OP rhs.ValueUnsafe()); \ return CheckedNumeric<T>(lhs.ValueUnsafe() OP rhs.ValueUnsafe()); \
...@@ -209,9 +209,9 @@ class CheckedNumeric { ...@@ -209,9 +209,9 @@ class CheckedNumeric {
lhs.ValueUnsafe() OP rhs.ValueUnsafe(), \ lhs.ValueUnsafe() OP rhs.ValueUnsafe(), \
GetRangeConstraint(rhs.validity() | lhs.validity())); \ GetRangeConstraint(rhs.validity() | lhs.validity())); \
RangeConstraint validity = RANGE_VALID; \ RangeConstraint validity = RANGE_VALID; \
T result = Checked##NAME(static_cast<Promotion>(lhs.ValueUnsafe()), \ T result = \
static_cast<Promotion>(rhs.ValueUnsafe()), \ Checked##NAME(static_cast<Promotion>(lhs.ValueUnsafe()), \
&validity); \ static_cast<Promotion>(rhs.ValueUnsafe()), &validity); \
return CheckedNumeric<Promotion>( \ return CheckedNumeric<Promotion>( \
result, \ result, \
GetRangeConstraint(validity | lhs.validity() | rhs.validity())); \ GetRangeConstraint(validity | lhs.validity() | rhs.validity())); \
...@@ -227,7 +227,7 @@ class CheckedNumeric { ...@@ -227,7 +227,7 @@ class CheckedNumeric {
template <typename T, typename Src> \ template <typename T, typename Src> \
CheckedNumeric<typename ArithmeticPromotion<T, Src>::type> operator OP( \ CheckedNumeric<typename ArithmeticPromotion<T, Src>::type> operator OP( \
const CheckedNumeric<Src>& lhs, const CheckedNumeric<T>& rhs) { \ const CheckedNumeric<Src>& lhs, const CheckedNumeric<T>& rhs) { \
typedef typename ArithmeticPromotion<T, Src>::type Promotion; \ using Promotion = typename ArithmeticPromotion<T, Src>::type; \
if (IsIntegerArithmeticSafe<Promotion, T, Src>::value) \ if (IsIntegerArithmeticSafe<Promotion, T, Src>::value) \
return CheckedNumeric<Promotion>( \ return CheckedNumeric<Promotion>( \
lhs.ValueUnsafe() OP rhs.ValueUnsafe(), \ lhs.ValueUnsafe() OP rhs.ValueUnsafe(), \
...@@ -239,7 +239,7 @@ class CheckedNumeric { ...@@ -239,7 +239,7 @@ class CheckedNumeric {
template <typename T, typename Src> \ template <typename T, typename Src> \
CheckedNumeric<typename ArithmeticPromotion<T, Src>::type> operator OP( \ CheckedNumeric<typename ArithmeticPromotion<T, Src>::type> operator OP( \
const CheckedNumeric<T>& lhs, Src rhs) { \ const CheckedNumeric<T>& lhs, Src rhs) { \
typedef typename ArithmeticPromotion<T, Src>::type Promotion; \ using Promotion = typename ArithmeticPromotion<T, Src>::type; \
if (IsIntegerArithmeticSafe<Promotion, T, Src>::value) \ if (IsIntegerArithmeticSafe<Promotion, T, Src>::value) \
return CheckedNumeric<Promotion>(lhs.ValueUnsafe() OP rhs, \ return CheckedNumeric<Promotion>(lhs.ValueUnsafe() OP rhs, \
lhs.validity()); \ lhs.validity()); \
...@@ -250,7 +250,7 @@ class CheckedNumeric { ...@@ -250,7 +250,7 @@ class CheckedNumeric {
template <typename T, typename Src> \ template <typename T, typename Src> \
CheckedNumeric<typename ArithmeticPromotion<T, Src>::type> operator OP( \ CheckedNumeric<typename ArithmeticPromotion<T, Src>::type> operator OP( \
Src lhs, const CheckedNumeric<T>& rhs) { \ Src lhs, const CheckedNumeric<T>& rhs) { \
typedef typename ArithmeticPromotion<T, Src>::type Promotion; \ using Promotion = typename ArithmeticPromotion<T, Src>::type; \
if (IsIntegerArithmeticSafe<Promotion, T, Src>::value) \ if (IsIntegerArithmeticSafe<Promotion, T, Src>::value) \
return CheckedNumeric<Promotion>(lhs OP rhs.ValueUnsafe(), \ return CheckedNumeric<Promotion>(lhs OP rhs.ValueUnsafe(), \
rhs.validity()); \ rhs.validity()); \
......
...@@ -27,14 +27,14 @@ namespace internal { ...@@ -27,14 +27,14 @@ namespace internal {
template<class T, T v> template<class T, T v>
struct integral_constant { struct integral_constant {
static const T value = v; static const T value = v;
typedef T value_type; using value_type = T;
typedef integral_constant<T, v> type; using type = integral_constant<T, v>;
}; };
template <class T, T v> const T integral_constant<T, v>::value; template <class T, T v> const T integral_constant<T, v>::value;
typedef integral_constant<bool, true> true_type; using true_type = integral_constant<bool, true>;
typedef integral_constant<bool, false> false_type; using false_type = integral_constant<bool, false>;
template <class T, class U> struct is_same : public false_type {}; template <class T, class U> struct is_same : public false_type {};
template <class T> struct is_same<T, T> : true_type {}; template <class T> struct is_same<T, T> : true_type {};
...@@ -42,8 +42,10 @@ template <class T> struct is_same<T, T> : true_type {}; ...@@ -42,8 +42,10 @@ template <class T> struct is_same<T, T> : true_type {};
template<bool B, class T = void> template<bool B, class T = void>
struct enable_if {}; struct enable_if {};
template<class T> template <class T>
struct enable_if<true, T> { typedef T type; }; struct enable_if<true, T> {
using type = T;
};
// </template_util.h> // </template_util.h>
...@@ -57,35 +59,35 @@ template <size_t Size, bool IsSigned> ...@@ -57,35 +59,35 @@ template <size_t Size, bool IsSigned>
struct IntegerForSizeAndSign; struct IntegerForSizeAndSign;
template <> template <>
struct IntegerForSizeAndSign<1, true> { struct IntegerForSizeAndSign<1, true> {
typedef int8_t type; using type = int8_t;
}; };
template <> template <>
struct IntegerForSizeAndSign<1, false> { struct IntegerForSizeAndSign<1, false> {
typedef uint8_t type; using type = uint8_t;
}; };
template <> template <>
struct IntegerForSizeAndSign<2, true> { struct IntegerForSizeAndSign<2, true> {
typedef int16_t type; using type = int16_t;
}; };
template <> template <>
struct IntegerForSizeAndSign<2, false> { struct IntegerForSizeAndSign<2, false> {
typedef uint16_t type; using type = uint16_t;
}; };
template <> template <>
struct IntegerForSizeAndSign<4, true> { struct IntegerForSizeAndSign<4, true> {
typedef int32_t type; using type = int32_t;
}; };
template <> template <>
struct IntegerForSizeAndSign<4, false> { struct IntegerForSizeAndSign<4, false> {
typedef uint32_t type; using type = uint32_t;
}; };
template <> template <>
struct IntegerForSizeAndSign<8, true> { struct IntegerForSizeAndSign<8, true> {
typedef int64_t type; using type = int64_t;
}; };
template <> template <>
struct IntegerForSizeAndSign<8, false> { struct IntegerForSizeAndSign<8, false> {
typedef uint64_t type; using type = uint64_t;
}; };
// WARNING: We have no IntegerForSizeAndSign<16, *>. If we ever add one to // WARNING: We have no IntegerForSizeAndSign<16, *>. If we ever add one to
...@@ -94,25 +96,25 @@ struct IntegerForSizeAndSign<8, false> { ...@@ -94,25 +96,25 @@ struct IntegerForSizeAndSign<8, false> {
template <typename Integer> template <typename Integer>
struct UnsignedIntegerForSize { struct UnsignedIntegerForSize {
typedef typename enable_if< using type = typename enable_if<
std::numeric_limits<Integer>::is_integer, std::numeric_limits<Integer>::is_integer,
typename IntegerForSizeAndSign<sizeof(Integer), false>::type>::type type; typename IntegerForSizeAndSign<sizeof(Integer), false>::type>::type;
}; };
template <typename Integer> template <typename Integer>
struct SignedIntegerForSize { struct SignedIntegerForSize {
typedef typename enable_if< using type = typename enable_if<
std::numeric_limits<Integer>::is_integer, std::numeric_limits<Integer>::is_integer,
typename IntegerForSizeAndSign<sizeof(Integer), true>::type>::type type; typename IntegerForSizeAndSign<sizeof(Integer), true>::type>::type;
}; };
template <typename Integer> template <typename Integer>
struct TwiceWiderInteger { struct TwiceWiderInteger {
typedef typename enable_if< using type = typename enable_if<
std::numeric_limits<Integer>::is_integer, std::numeric_limits<Integer>::is_integer,
typename IntegerForSizeAndSign< typename IntegerForSizeAndSign<
sizeof(Integer) * 2, sizeof(Integer) * 2,
std::numeric_limits<Integer>::is_signed>::type>::type type; std::numeric_limits<Integer>::is_signed>::type>::type;
}; };
template <typename Integer> template <typename Integer>
...@@ -145,7 +147,7 @@ typename enable_if<std::numeric_limits<T>::is_integer, T>::type ...@@ -145,7 +147,7 @@ typename enable_if<std::numeric_limits<T>::is_integer, T>::type
CheckedAdd(T x, T y, RangeConstraint* validity) { CheckedAdd(T x, T y, RangeConstraint* validity) {
// Since the value of x+y is undefined if we have a signed type, we compute // Since the value of x+y is undefined if we have a signed type, we compute
// it using the unsigned type of the same size. // it using the unsigned type of the same size.
typedef typename UnsignedIntegerForSize<T>::type UnsignedDst; using UnsignedDst = typename UnsignedIntegerForSize<T>::type;
UnsignedDst ux = static_cast<UnsignedDst>(x); UnsignedDst ux = static_cast<UnsignedDst>(x);
UnsignedDst uy = static_cast<UnsignedDst>(y); UnsignedDst uy = static_cast<UnsignedDst>(y);
UnsignedDst uresult = ux + uy; UnsignedDst uresult = ux + uy;
...@@ -168,7 +170,7 @@ typename enable_if<std::numeric_limits<T>::is_integer, T>::type ...@@ -168,7 +170,7 @@ typename enable_if<std::numeric_limits<T>::is_integer, T>::type
CheckedSub(T x, T y, RangeConstraint* validity) { CheckedSub(T x, T y, RangeConstraint* validity) {
// Since the value of x+y is undefined if we have a signed type, we compute // Since the value of x+y is undefined if we have a signed type, we compute
// it using the unsigned type of the same size. // it using the unsigned type of the same size.
typedef typename UnsignedIntegerForSize<T>::type UnsignedDst; using UnsignedDst = typename UnsignedIntegerForSize<T>::type;
UnsignedDst ux = static_cast<UnsignedDst>(x); UnsignedDst ux = static_cast<UnsignedDst>(x);
UnsignedDst uy = static_cast<UnsignedDst>(y); UnsignedDst uy = static_cast<UnsignedDst>(y);
UnsignedDst uresult = ux - uy; UnsignedDst uresult = ux - uy;
...@@ -195,7 +197,7 @@ typename enable_if< ...@@ -195,7 +197,7 @@ typename enable_if<
std::numeric_limits<T>::is_integer && sizeof(T) * 2 <= sizeof(uintmax_t), std::numeric_limits<T>::is_integer && sizeof(T) * 2 <= sizeof(uintmax_t),
T>::type T>::type
CheckedMul(T x, T y, RangeConstraint* validity) { CheckedMul(T x, T y, RangeConstraint* validity) {
typedef typename TwiceWiderInteger<T>::type IntermediateType; using IntermediateType = typename TwiceWiderInteger<T>::type;
IntermediateType tmp = IntermediateType tmp =
static_cast<IntermediateType>(x) * static_cast<IntermediateType>(y); static_cast<IntermediateType>(x) * static_cast<IntermediateType>(y);
*validity = DstRangeRelationToSrcRange<T>(tmp); *validity = DstRangeRelationToSrcRange<T>(tmp);
...@@ -496,17 +498,17 @@ struct ArithmeticPromotion; ...@@ -496,17 +498,17 @@ struct ArithmeticPromotion;
template <typename Lhs, typename Rhs> template <typename Lhs, typename Rhs>
struct ArithmeticPromotion<Lhs, Rhs, LEFT_PROMOTION> { struct ArithmeticPromotion<Lhs, Rhs, LEFT_PROMOTION> {
typedef Lhs type; using type = Lhs;
}; };
template <typename Lhs, typename Rhs> template <typename Lhs, typename Rhs>
struct ArithmeticPromotion<Lhs, Rhs, RIGHT_PROMOTION> { struct ArithmeticPromotion<Lhs, Rhs, RIGHT_PROMOTION> {
typedef Rhs type; using type = Rhs;
}; };
template <typename Lhs, typename Rhs> template <typename Lhs, typename Rhs>
struct ArithmeticPromotion<Lhs, Rhs, DEFAULT_PROMOTION> { struct ArithmeticPromotion<Lhs, Rhs, DEFAULT_PROMOTION> {
typedef int type; using type = int;
}; };
// We can statically check if operations on the provided types can wrap, so we // We can statically check if operations on the provided types can wrap, so we
......
...@@ -39,7 +39,7 @@ class V8_BASE_EXPORT RandomNumberGenerator final { ...@@ -39,7 +39,7 @@ class V8_BASE_EXPORT RandomNumberGenerator final {
public: public:
// EntropySource is used as a callback function when V8 needs a source of // EntropySource is used as a callback function when V8 needs a source of
// entropy. // entropy.
typedef bool (*EntropySource)(unsigned char* buffer, size_t buflen); using EntropySource = bool (*)(unsigned char* buffer, size_t buflen);
static void SetEntropySource(EntropySource entropy_source); static void SetEntropySource(EntropySource entropy_source);
RandomNumberGenerator(); RandomNumberGenerator();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment