Commit 98b87154 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm][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 wasm code to 'using' declarations.

R=ahaas@chromium.org

Bug: v8:8834
Change-Id: Ibdce88a5cc31e0785cbc1b34088bd39aa3ec84b3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1545890Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60519}
parent 6576b284
...@@ -37,8 +37,8 @@ enum class TrapId : uint32_t; ...@@ -37,8 +37,8 @@ enum class TrapId : uint32_t;
namespace wasm { namespace wasm {
struct DecodeStruct; struct DecodeStruct;
// Expose {Node} and {Graph} opaquely as {wasm::TFNode} and {wasm::TFGraph}. // Expose {Node} and {Graph} opaquely as {wasm::TFNode} and {wasm::TFGraph}.
typedef compiler::Node TFNode; using TFNode = compiler::Node;
typedef compiler::MachineGraph TFGraph; using TFGraph = compiler::MachineGraph;
class WasmCode; class WasmCode;
struct WasmFeatures; struct WasmFeatures;
} // namespace wasm } // namespace wasm
......
...@@ -341,7 +341,7 @@ class Decoder { ...@@ -341,7 +341,7 @@ class Decoder {
DCHECK_LT(pc, end_); DCHECK_LT(pc, end_);
b = *pc; b = *pc;
TRACE_IF(trace, "%02x ", b); TRACE_IF(trace, "%02x ", b);
typedef typename std::make_unsigned<IntType>::type Unsigned; using Unsigned = typename std::make_unsigned<IntType>::type;
result = result | result = result |
(static_cast<Unsigned>(static_cast<IntType>(b) & 0x7f) << shift); (static_cast<Unsigned>(static_cast<IntType>(b) & 0x7f) << shift);
} }
......
...@@ -27,18 +27,18 @@ inline bool IsValidSectionCode(uint8_t byte) { ...@@ -27,18 +27,18 @@ inline bool IsValidSectionCode(uint8_t byte) {
const char* SectionName(SectionCode code); const char* SectionName(SectionCode code);
typedef Result<std::shared_ptr<WasmModule>> ModuleResult; using ModuleResult = Result<std::shared_ptr<WasmModule>>;
typedef Result<std::unique_ptr<WasmFunction>> FunctionResult; using FunctionResult = Result<std::unique_ptr<WasmFunction>>;
typedef std::vector<std::pair<int, int>> FunctionOffsets; using FunctionOffsets = std::vector<std::pair<int, int>>;
typedef Result<FunctionOffsets> FunctionOffsetsResult; using FunctionOffsetsResult = Result<FunctionOffsets>;
struct AsmJsOffsetEntry { struct AsmJsOffsetEntry {
int byte_offset; int byte_offset;
int source_position_call; int source_position_call;
int source_position_number_conversion; int source_position_number_conversion;
}; };
typedef std::vector<std::vector<AsmJsOffsetEntry>> AsmJsOffsets; using AsmJsOffsets = std::vector<std::vector<AsmJsOffsetEntry>>;
typedef Result<AsmJsOffsets> AsmJsOffsetsResult; using AsmJsOffsetsResult = Result<AsmJsOffsets>;
struct LocalName { struct LocalName {
int local_index; int local_index;
......
...@@ -71,7 +71,7 @@ void memory_copy_wrapper(Address dst, Address src, uint32_t size); ...@@ -71,7 +71,7 @@ void memory_copy_wrapper(Address dst, Address src, uint32_t size);
void memory_fill_wrapper(Address dst, uint32_t value, uint32_t size); void memory_fill_wrapper(Address dst, uint32_t value, uint32_t size);
typedef void (*WasmTrapCallbackForTesting)(); using WasmTrapCallbackForTesting = void (*)();
V8_EXPORT_PRIVATE void set_trap_callback_for_testing( V8_EXPORT_PRIVATE void set_trap_callback_for_testing(
WasmTrapCallbackForTesting callback); WasmTrapCallbackForTesting callback);
......
...@@ -72,7 +72,7 @@ struct WasmGlobal { ...@@ -72,7 +72,7 @@ struct WasmGlobal {
// Note: An exception signature only uses the params portion of a // Note: An exception signature only uses the params portion of a
// function signature. // function signature.
typedef FunctionSig WasmExceptionSig; using WasmExceptionSig = FunctionSig;
// Static representation of a wasm exception type. // Static representation of a wasm exception type.
struct WasmException { struct WasmException {
......
...@@ -19,21 +19,21 @@ namespace test_run_wasm_simd { ...@@ -19,21 +19,21 @@ namespace test_run_wasm_simd {
namespace { namespace {
typedef float (*FloatUnOp)(float); using FloatUnOp = float (*)(float);
typedef float (*FloatBinOp)(float, float); using FloatBinOp = float (*)(float, float);
typedef int (*FloatCompareOp)(float, float); using FloatCompareOp = int (*)(float, float);
typedef int32_t (*Int32UnOp)(int32_t); using Int32UnOp = int32_t (*)(int32_t);
typedef int32_t (*Int32BinOp)(int32_t, int32_t); using Int32BinOp = int32_t (*)(int32_t, int32_t);
typedef int (*Int32CompareOp)(int32_t, int32_t); using Int32CompareOp = int (*)(int32_t, int32_t);
typedef int32_t (*Int32ShiftOp)(int32_t, int); using Int32ShiftOp = int32_t (*)(int32_t, int);
typedef int16_t (*Int16UnOp)(int16_t); using Int16UnOp = int16_t (*)(int16_t);
typedef int16_t (*Int16BinOp)(int16_t, int16_t); using Int16BinOp = int16_t (*)(int16_t, int16_t);
typedef int (*Int16CompareOp)(int16_t, int16_t); using Int16CompareOp = int (*)(int16_t, int16_t);
typedef int16_t (*Int16ShiftOp)(int16_t, int); using Int16ShiftOp = int16_t (*)(int16_t, int);
typedef int8_t (*Int8UnOp)(int8_t); using Int8UnOp = int8_t (*)(int8_t);
typedef int8_t (*Int8BinOp)(int8_t, int8_t); using Int8BinOp = int8_t (*)(int8_t, int8_t);
typedef int (*Int8CompareOp)(int8_t, int8_t); using Int8CompareOp = int (*)(int8_t, int8_t);
typedef int8_t (*Int8ShiftOp)(int8_t, int); using Int8ShiftOp = int8_t (*)(int8_t, int);
#define WASM_SIMD_TEST(name) \ #define WASM_SIMD_TEST(name) \
void RunWasm_##name##_Impl(LowerSimd lower_simd, \ void RunWasm_##name##_Impl(LowerSimd lower_simd, \
......
...@@ -47,7 +47,7 @@ bool TrueCallback(Local<v8::Context>, Local<v8::String>) { return true; } ...@@ -47,7 +47,7 @@ bool TrueCallback(Local<v8::Context>, Local<v8::String>) { return true; }
bool FalseCallback(Local<v8::Context>, Local<v8::String>) { return false; } bool FalseCallback(Local<v8::Context>, Local<v8::String>) { return false; }
typedef bool (*CallbackFn)(Local<v8::Context>, Local<v8::String>); using CallbackFn = bool (*)(Local<v8::Context>, Local<v8::String>);
// Defines the Callback to use for the corresponding TestValue. // Defines the Callback to use for the corresponding TestValue.
CallbackFn Callback[kNumTestValues] = {nullptr, FalseCallback, TrueCallback}; CallbackFn Callback[kNumTestValues] = {nullptr, FalseCallback, TrueCallback};
......
...@@ -21,10 +21,10 @@ namespace wasm { ...@@ -21,10 +21,10 @@ namespace wasm {
V(Xor) \ V(Xor) \
V(Exchange) V(Exchange)
typedef uint64_t (*Uint64BinOp)(uint64_t, uint64_t); using Uint64BinOp = uint64_t (*)(uint64_t, uint64_t);
typedef uint32_t (*Uint32BinOp)(uint32_t, uint32_t); using Uint32BinOp = uint32_t (*)(uint32_t, uint32_t);
typedef uint16_t (*Uint16BinOp)(uint16_t, uint16_t); using Uint16BinOp = uint16_t (*)(uint16_t, uint16_t);
typedef uint8_t (*Uint8BinOp)(uint8_t, uint8_t); using Uint8BinOp = uint8_t (*)(uint8_t, uint8_t);
template <typename T> template <typename T>
T Add(T a, T b) { T Add(T a, T b) {
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "test/fuzzer/fuzzer-support.h" #include "test/fuzzer/fuzzer-support.h"
#include "test/fuzzer/wasm-fuzzer-common.h" #include "test/fuzzer/wasm-fuzzer-common.h"
typedef uint8_t byte;
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace wasm { namespace wasm {
......
...@@ -57,7 +57,7 @@ static const WasmOpcode kInt32BinopOpcodes[] = { ...@@ -57,7 +57,7 @@ static const WasmOpcode kInt32BinopOpcodes[] = {
class FunctionBodyDecoderTest : public TestWithZone { class FunctionBodyDecoderTest : public TestWithZone {
public: public:
typedef std::pair<uint32_t, ValueType> LocalsDecl; using LocalsDecl = std::pair<uint32_t, ValueType>;
// All features are disabled by default and must be activated with // All features are disabled by default and must be activated with
// a WASM_FEATURE_SCOPE in individual tests. // a WASM_FEATURE_SCOPE in individual tests.
WasmFeatures enabled_features_; WasmFeatures enabled_features_;
...@@ -3384,7 +3384,7 @@ TEST_F(WasmOpcodeLengthTest, SimdExpressions) { ...@@ -3384,7 +3384,7 @@ TEST_F(WasmOpcodeLengthTest, SimdExpressions) {
ExpectLength(2, kSimdPrefix, 0xFF); ExpectLength(2, kSimdPrefix, 0xFF);
} }
typedef ZoneVector<ValueType> TypesOfLocals; using TypesOfLocals = ZoneVector<ValueType>;
class LocalDeclDecoderTest : public TestWithZone { class LocalDeclDecoderTest : public TestWithZone {
public: public:
......
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