Commit 6f24e4d1 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[objects][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 src/objects to 'using' declarations.

R=mstarzinger@chromium.org

Bug: v8:8834
Change-Id: Iec455b40e9256ee3aae867a42c0e949a338d417c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1545893Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60531}
parent 52d319e0
......@@ -2486,11 +2486,11 @@ uint64_t BigInt::AsUint64(bool* lossless) {
#if V8_TARGET_ARCH_32_BIT
#define HAVE_TWODIGIT_T 1
typedef uint64_t twodigit_t;
using twodigit_t = uint64_t;
#elif defined(__SIZEOF_INT128__)
// Both Clang and GCC support this on x64.
#define HAVE_TWODIGIT_T 1
typedef __uint128_t twodigit_t;
using twodigit_t = __uint128_t;
#endif
// {carry} must point to an initialized digit_t and will either be incremented
......
......@@ -70,7 +70,7 @@ class BigIntBase : public HeapObject {
friend class ::v8::internal::BigInt; // MSVC wants full namespace.
friend class MutableBigInt;
typedef uintptr_t digit_t;
using digit_t = uintptr_t;
static const int kDigitSize = sizeof(digit_t);
// kMaxLength definition assumes this:
STATIC_ASSERT(kDigitSize == kSystemPointerSize);
......
......@@ -32,7 +32,7 @@ class Cell : public HeapObject {
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_CELL_FIELDS)
typedef FixedBodyDescriptor<kValueOffset, kSize, kSize> BodyDescriptor;
using BodyDescriptor = FixedBodyDescriptor<kValueOffset, kSize, kSize>;
OBJECT_CONSTRUCTORS(Cell, HeapObject);
};
......
......@@ -34,7 +34,7 @@ class Code : public HeapObject {
NEVER_READ_ONLY_SPACE
// Opaque data type for encapsulating code flags like kind, inline
// cache state, and arguments count.
typedef uint32_t Flags;
using Flags = uint32_t;
#define CODE_KIND_LIST(V) \
V(OPTIMIZED_FUNCTION) \
......
......@@ -33,7 +33,7 @@ class DebugInfo : public Struct {
kDebugExecutionMode = 1 << 5
};
typedef base::Flags<Flag> Flags;
using Flags = base::Flags<Flag>;
// A bitfield that lists uses of the current instance.
DECL_INT_ACCESSORS(flags)
......
......@@ -171,7 +171,7 @@ class DescriptorArray : public HeapObject {
inline ObjectSlot GetKeySlot(int descriptor);
inline MaybeObjectSlot GetValueSlot(int descriptor);
typedef FlexibleWeakBodyDescriptor<kPointersStartOffset> BodyDescriptor;
using BodyDescriptor = FlexibleWeakBodyDescriptor<kPointersStartOffset>;
// Layout of descriptor.
// Naming is consistent with Dictionary classes for easy templating.
......
......@@ -25,10 +25,10 @@ class Isolate;
template <typename Derived, typename Shape>
class Dictionary : public HashTable<Derived, Shape> {
typedef HashTable<Derived, Shape> DerivedHashTable;
using DerivedHashTable = HashTable<Derived, Shape>;
public:
typedef typename Shape::Key Key;
using Key = typename Shape::Key;
// Returns the value at entry.
Object ValueAt(int entry) {
return this->get(DerivedHashTable::EntryToIndex(entry) + 1);
......@@ -126,7 +126,7 @@ class NameDictionaryShape : public BaseDictionaryShape<Handle<Name>> {
template <typename Derived, typename Shape>
class BaseNameDictionary : public Dictionary<Derived, Shape> {
typedef typename Shape::Key Key;
using Key = typename Shape::Key;
public:
static const int kNextEnumerationIndexIndex =
......
......@@ -49,7 +49,7 @@ class EmbedderDataSlot
static constexpr int kRequiredPtrAlignment = kSmiTagSize;
// Opaque type used for storing raw embedder data.
typedef Address RawData;
using RawData = Address;
V8_INLINE Object load_tagged() const;
V8_INLINE void store_smi(Smi value);
......
......@@ -38,7 +38,7 @@ class FeedbackCell : public Struct {
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, FEEDBACK_CELL_FIELDS)
#undef FEEDBACK_CELL_FIELDS
typedef FixedBodyDescriptor<kValueOffset, kSize, kSize> BodyDescriptor;
using BodyDescriptor = FixedBodyDescriptor<kValueOffset, kSize, kSize>;
OBJECT_CONSTRUCTORS(FeedbackCell, Struct);
};
......
......@@ -15,8 +15,8 @@
namespace v8 {
namespace internal {
typedef FlexibleWeakBodyDescriptor<HeapObject::kHeaderSize>
WeakArrayBodyDescriptor;
using WeakArrayBodyDescriptor =
FlexibleWeakBodyDescriptor<HeapObject::kHeaderSize>;
#define FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(V) \
V(BYTECODE_ARRAY_CONSTANT_POOL_SUB_TYPE) \
......@@ -198,7 +198,7 @@ class FixedArray : public FixedArrayBase {
DECL_PRINTER(FixedArray)
DECL_VERIFIER(FixedArray)
typedef FlexibleBodyDescriptor<kHeaderSize> BodyDescriptor;
using BodyDescriptor = FlexibleBodyDescriptor<kHeaderSize>;
protected:
// Set operation on FixedArray without using write barriers. Can
......@@ -298,7 +298,7 @@ class WeakFixedArray : public HeapObject {
DECL_PRINTER(WeakFixedArray)
DECL_VERIFIER(WeakFixedArray)
typedef WeakArrayBodyDescriptor BodyDescriptor;
using BodyDescriptor = WeakArrayBodyDescriptor;
// Layout description.
#define WEAK_FIXED_ARRAY_FIELDS(V) \
......@@ -379,7 +379,7 @@ class WeakArrayList : public HeapObject {
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, WEAK_ARRAY_LIST_FIELDS)
#undef WEAK_ARRAY_LIST_FIELDS
typedef WeakArrayBodyDescriptor BodyDescriptor;
using BodyDescriptor = WeakArrayBodyDescriptor;
static const int kMaxCapacity =
(FixedArray::kMaxSize - kHeaderSize) / kTaggedSize;
......@@ -652,7 +652,7 @@ class FixedTypedArrayBase : public FixedArrayBase {
template <class Traits>
class FixedTypedArray : public FixedTypedArrayBase {
public:
typedef typename Traits::ElementType ElementType;
using ElementType = typename Traits::ElementType;
static const InstanceType kInstanceType = Traits::kInstanceType;
DECL_CAST(FixedTypedArray<Traits>)
......@@ -687,7 +687,7 @@ class FixedTypedArray : public FixedTypedArrayBase {
STATIC_ASSERT(sizeof(elementType) <= FixedTypedArrayBase::kMaxElementSize); \
class Type##ArrayTraits { \
public: /* NOLINT */ \
typedef elementType ElementType; \
using ElementType = elementType; \
static const InstanceType kInstanceType = FIXED_##TYPE##_ARRAY_TYPE; \
static const char* ArrayTypeName() { return "Fixed" #Type "Array"; } \
static inline Handle<Object> ToHandle(Isolate* isolate, \
......@@ -695,7 +695,7 @@ class FixedTypedArray : public FixedTypedArrayBase {
static inline elementType defaultValue(); \
}; \
\
typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array;
using Fixed##Type##Array = FixedTypedArray<Type##ArrayTraits>;
TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS)
......
......@@ -56,7 +56,7 @@ namespace internal {
template <typename KeyT>
class BaseShape {
public:
typedef KeyT Key;
using Key = KeyT;
static inline RootIndex GetMapRootIndex();
static const bool kNeedsHoleCheck = true;
static Object Unwrap(Object key) { return key; }
......@@ -132,8 +132,8 @@ class V8_EXPORT_PRIVATE HashTableBase : public NON_EXPORTED_BASE(FixedArray) {
template <typename Derived, typename Shape>
class HashTable : public HashTableBase {
public:
typedef Shape ShapeT;
typedef typename Shape::Key Key;
using ShapeT = Shape;
using Key = typename Shape::Key;
// Returns a new HashTable object.
V8_WARN_UNUSED_RESULT static Handle<Derived> New(
......
......@@ -116,7 +116,7 @@ class JSWeakCollection : public JSObject {
class BodyDescriptorImpl;
// Visit the whole object.
typedef BodyDescriptorImpl BodyDescriptor;
using BodyDescriptor = BodyDescriptorImpl;
OBJECT_CONSTRUCTORS(JSWeakCollection, JSObject);
};
......
......@@ -178,7 +178,7 @@ class JSReceiver : public HeapObject {
V8_WARN_UNUSED_RESULT static Maybe<bool> GetOwnPropertyDescriptor(
LookupIterator* it, PropertyDescriptor* desc);
typedef PropertyAttributes IntegrityLevel;
using IntegrityLevel = PropertyAttributes;
// ES6 7.3.14 (when passed kDontThrow)
// 'level' must be SEALED or FROZEN.
......@@ -1377,9 +1377,8 @@ class JSMessageObject : public JSObject {
// TODO(v8:8989): [torque] Support marker constants.
static const int kPointerFieldsEndOffset = kStartPositionOffset;
typedef FixedBodyDescriptor<HeapObject::kMapOffset, kPointerFieldsEndOffset,
kSize>
BodyDescriptor;
using BodyDescriptor = FixedBodyDescriptor<HeapObject::kMapOffset,
kPointerFieldsEndOffset, kSize>;
OBJECT_CONSTRUCTORS(JSMessageObject, JSObject);
};
......
......@@ -117,8 +117,8 @@ class JSProxy : public JSReceiver {
STATIC_ASSERT(static_cast<int>(JSObject::kElementsOffset) ==
static_cast<int>(JSProxy::kTargetOffset));
typedef FixedBodyDescriptor<JSReceiver::kPropertiesOrHashOffset, kSize, kSize>
BodyDescriptor;
using BodyDescriptor =
FixedBodyDescriptor<JSReceiver::kPropertiesOrHashOffset, kSize, kSize>;
static Maybe<bool> SetPrivateSymbol(Isolate* isolate, Handle<JSProxy> proxy,
Handle<Symbol> private_name,
......
......@@ -56,7 +56,7 @@ class JSRegExp : public JSObject {
// Update FlagCount when adding new flags.
kInvalid = 1 << FlagShiftBit::kInvalid, // Not included in FlagCount.
};
typedef base::Flags<Flag> Flags;
using Flags = base::Flags<Flag>;
static constexpr int FlagCount() { return 6; }
static int FlagShiftBits(Flag flag) {
......
......@@ -71,7 +71,7 @@ namespace {
inline int EncodeComputedEntry(ClassBoilerplate::ValueKind value_kind,
unsigned key_index) {
typedef ClassBoilerplate::ComputedEntryFlags Flags;
using Flags = ClassBoilerplate::ComputedEntryFlags;
int flags = Flags::ValueKindBits::encode(value_kind) |
Flags::KeyIndexBits::encode(key_index);
return flags;
......
......@@ -93,7 +93,7 @@ enum class ObjectFields {
kMaybePointers,
};
typedef std::vector<Handle<Map>> MapHandles;
using MapHandles = std::vector<Handle<Map>>;
// All heap objects have a Map that describes their structure.
// A Map contains information about:
......
......@@ -191,7 +191,7 @@ class Symbol : public Name {
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
#undef FLAGS_BIT_FIELDS
typedef FixedBodyDescriptor<kNameOffset, kSize, kSize> BodyDescriptor;
using BodyDescriptor = FixedBodyDescriptor<kNameOffset, kSize, kSize>;
void SymbolShortPrint(std::ostream& os);
......
......@@ -68,9 +68,8 @@ class Oddball : public HeapObject {
static const byte kStaleRegister = 10;
static const byte kSelfReferenceMarker = 10;
typedef FixedBodyDescriptor<kTaggedFieldsStartOffset, kTaggedFieldsEndOffset,
kSize>
BodyDescriptor;
using BodyDescriptor = FixedBodyDescriptor<kTaggedFieldsStartOffset,
kTaggedFieldsEndOffset, kSize>;
STATIC_ASSERT(kKindOffset == Internals::kOddballKindOffset);
STATIC_ASSERT(kNull == Internals::kNullOddballKind);
......
......@@ -336,11 +336,11 @@ template <class Derived>
class SmallOrderedHashTable : public HeapObject {
public:
// Offset points to a relative location in the table
typedef int Offset;
using Offset = int;
// ByteIndex points to a index in the table that needs to be
// converted to an Offset.
typedef int ByteIndex;
using ByteIndex = int;
void Initialize(Isolate* isolate, int capacity);
......@@ -638,7 +638,7 @@ STATIC_ASSERT(kSmallOrderedHashMapMinCapacity ==
template <class SmallTable, class LargeTable>
class OrderedHashTableHandler {
public:
typedef int Entry;
using Entry = int;
static Handle<HeapObject> Allocate(Isolate* isolate, int capacity);
static bool Delete(Handle<HeapObject> table, Handle<Object> key);
......
......@@ -53,7 +53,7 @@ class PropertyArray : public HeapObject {
static const int kHeaderSize = kSize;
// Garbage collection support.
typedef FlexibleBodyDescriptor<kHeaderSize> BodyDescriptor;
using BodyDescriptor = FlexibleBodyDescriptor<kHeaderSize>;
static const int kLengthFieldSize = 10;
class LengthField : public BitField<int, 0, kLengthFieldSize> {};
......
......@@ -68,7 +68,7 @@ class PropertyCell : public HeapObject {
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, PROPERTY_CELL_FIELDS)
#undef PROPERTY_CELL_FIELDS
typedef FixedBodyDescriptor<kNameOffset, kSize, kSize> BodyDescriptor;
using BodyDescriptor = FixedBodyDescriptor<kNameOffset, kSize, kSize>;
OBJECT_CONSTRUCTORS(PropertyCell, HeapObject);
};
......
......@@ -80,8 +80,8 @@ class PrototypeUsers : public WeakArrayList {
// The callback is called when a weak pointer to HeapObject "object" is moved
// from index "from_index" to index "to_index" during compaction. The callback
// must not cause GC.
typedef void (*CompactionCallback)(HeapObject object, int from_index,
int to_index);
using CompactionCallback = void (*)(HeapObject object, int from_index,
int to_index);
static WeakArrayList Compact(
Handle<WeakArrayList> array, Heap* heap, CompactionCallback callback,
AllocationType allocation = AllocationType::kYoung);
......
......@@ -132,9 +132,8 @@ class UncompiledData : public HeapObject {
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, UNCOMPILED_DATA_FIELDS)
#undef UNCOMPILED_DATA_FIELDS
typedef FixedBodyDescriptor<kStartOfPointerFieldsOffset,
kEndOfTaggedFieldsOffset, kSize>
BodyDescriptor;
using BodyDescriptor = FixedBodyDescriptor<kStartOfPointerFieldsOffset,
kEndOfTaggedFieldsOffset, kSize>;
// Clear uninitialized padding space.
inline void clear_padding();
......@@ -154,7 +153,7 @@ class UncompiledDataWithoutPreparseData : public UncompiledData {
static const int kSize = UncompiledData::kSize;
// No extra fields compared to UncompiledData.
typedef UncompiledData::BodyDescriptor BodyDescriptor;
using BodyDescriptor = UncompiledData::BodyDescriptor;
OBJECT_CONSTRUCTORS(UncompiledDataWithoutPreparseData, UncompiledData);
};
......@@ -193,11 +192,10 @@ class UncompiledDataWithPreparseData : public UncompiledData {
// Make sure the size is aligned
STATIC_ASSERT(IsAligned(kSize, kTaggedSize));
typedef SubclassBodyDescriptor<
using BodyDescriptor = SubclassBodyDescriptor<
UncompiledData::BodyDescriptor,
FixedBodyDescriptor<kStartOfPointerFieldsOffset, kEndOfTaggedFieldsOffset,
kSize>>
BodyDescriptor;
kSize>>;
OBJECT_CONSTRUCTORS(UncompiledDataWithPreparseData, UncompiledData);
};
......
......@@ -71,11 +71,11 @@ class AtomicSlot : public SlotBase<AtomicSlot, Tagged_t> {
// The rest of this class follows C++'s "RandomAccessIterator" requirements.
// Most of the heavy lifting is inherited from SlotBase.
typedef int difference_type;
typedef Tagged_t value_type;
typedef Reference reference;
typedef void* pointer; // Must be present, but should not be used.
typedef std::random_access_iterator_tag iterator_category;
using difference_type = int;
using value_type = Tagged_t;
using reference = Reference;
using pointer = void*; // Must be present, but should not be used.
using iterator_category = std::random_access_iterator_tag;
AtomicSlot() : SlotBase(kNullAddress) {}
explicit AtomicSlot(Address address) : SlotBase(address) {}
......
......@@ -226,11 +226,11 @@ class UnalignedSlot : public SlotBase<UnalignedSlot<T>, T, 1> {
// The rest of this class follows C++'s "RandomAccessIterator" requirements.
// Most of the heavy lifting is inherited from SlotBase.
typedef int difference_type;
typedef T value_type;
typedef Reference reference;
typedef T* pointer;
typedef std::random_access_iterator_tag iterator_category;
using difference_type = int;
using value_type = T;
using reference = Reference;
using pointer = T*;
using iterator_category = std::random_access_iterator_tag;
UnalignedSlot() : SlotBase<UnalignedSlot<T>, T, 1>(kNullAddress) {}
explicit UnalignedSlot(Address address)
......
......@@ -750,11 +750,11 @@ SubStringRange::SubStringRange(String string,
class SubStringRange::iterator final {
public:
typedef std::forward_iterator_tag iterator_category;
typedef int difference_type;
typedef uc16 value_type;
typedef uc16* pointer;
typedef uc16& reference;
using iterator_category = std::forward_iterator_tag;
using difference_type = int;
using value_type = uc16;
using pointer = uc16*;
using reference = uc16&;
iterator(const iterator& other) = default;
......
......@@ -989,7 +989,7 @@ MaybeHandle<String> String::GetSubstitution(Isolate* isolate, Match* match,
break;
}
case '<': { // $<name> - named capture
typedef String::Match::CaptureState CaptureState;
using CaptureState = String::Match::CaptureState;
if (!match->HasNamedCaptures()) {
builder.AppendCharacter('$');
......
......@@ -609,7 +609,7 @@ class ConsString : public String {
// Minimum length for a cons string.
static const int kMinLength = 13;
typedef FixedBodyDescriptor<kFirstOffset, kSize, kSize> BodyDescriptor;
using BodyDescriptor = FixedBodyDescriptor<kFirstOffset, kSize, kSize>;
DECL_VERIFIER(ConsString)
......@@ -639,7 +639,7 @@ class ThinString : public String {
DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize,
TORQUE_GENERATED_THIN_STRING_FIELDS)
typedef FixedBodyDescriptor<kActualOffset, kSize, kSize> BodyDescriptor;
using BodyDescriptor = FixedBodyDescriptor<kActualOffset, kSize, kSize>;
OBJECT_CONSTRUCTORS(ThinString, String);
};
......@@ -675,7 +675,7 @@ class SlicedString : public String {
// Minimum length for a sliced string.
static const int kMinLength = 13;
typedef FixedBodyDescriptor<kParentOffset, kSize, kSize> BodyDescriptor;
using BodyDescriptor = FixedBodyDescriptor<kParentOffset, kSize, kSize>;
DECL_VERIFIER(SlicedString)
......@@ -727,7 +727,7 @@ class ExternalOneByteString : public ExternalString {
public:
static const bool kHasOneByteEncoding = true;
typedef v8::String::ExternalOneByteStringResource Resource;
using Resource = v8::String::ExternalOneByteStringResource;
// The underlying resource.
inline const Resource* resource();
......@@ -762,7 +762,7 @@ class ExternalTwoByteString : public ExternalString {
public:
static const bool kHasOneByteEncoding = false;
typedef v8::String::ExternalStringResource Resource;
using Resource = v8::String::ExternalStringResource;
// The underlying string resource.
inline const Resource* resource();
......
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