From 48b19b29ab49faa29b32f1eee3ca7660822520d1 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Fri, 31 Aug 2018 20:57:00 +0000 Subject: [PATCH] [WebAssembly] clang-format (NFC) Summary: This patch runs clang-format on all wasm-only files. Subscribers: dschuff, sbc100, jgravelle-google, sunfish, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D51448 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341254 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains/WebAssembly.cpp | 15 ++++----- lib/Driver/ToolChains/WebAssembly.h | 13 ++++---- test/CodeGen/builtins-wasm.c | 44 +++++++++++++------------- test/CodeGen/wasm-arguments.c | 1 - test/CodeGen/wasm-varargs.c | 6 ++-- test/CodeGenCXX/static-init-wasm.cpp | 2 +- test/CodeGenCXX/wasm-args-returns.cpp | 26 ++++++++------- test/Driver/wasm32-unknown-unknown.cpp | 17 ++++++---- test/Driver/wasm64-unknown-unknown.cpp | 17 ++++++---- 9 files changed, 74 insertions(+), 67 deletions(-) diff --git a/lib/Driver/ToolChains/WebAssembly.cpp b/lib/Driver/ToolChains/WebAssembly.cpp index 03fb1ec7d2..6776a41dad 100644 --- a/lib/Driver/ToolChains/WebAssembly.cpp +++ b/lib/Driver/ToolChains/WebAssembly.cpp @@ -22,15 +22,11 @@ using namespace clang; using namespace llvm::opt; wasm::Linker::Linker(const ToolChain &TC) - : GnuTool("wasm::Linker", "lld", TC) {} + : GnuTool("wasm::Linker", "lld", TC) {} -bool wasm::Linker::isLinkJob() const { - return true; -} +bool wasm::Linker::isLinkJob() const { return true; } -bool wasm::Linker::hasIntegratedCPP() const { - return false; -} +bool wasm::Linker::hasIntegratedCPP() const { return false; } void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, @@ -73,7 +69,7 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA, WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args) - : ToolChain(D, Triple, Args) { + : ToolChain(D, Triple, Args) { assert(Triple.isArch32Bit() != Triple.isArch64Bit()); @@ -115,7 +111,8 @@ ToolChain::RuntimeLibType WebAssembly::GetDefaultRuntimeLibType() const { return ToolChain::RLT_CompilerRT; } -ToolChain::CXXStdlibType WebAssembly::GetCXXStdlibType(const ArgList &Args) const { +ToolChain::CXXStdlibType +WebAssembly::GetCXXStdlibType(const ArgList &Args) const { if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) { StringRef Value = A->getValue(); if (Value != "libc++") diff --git a/lib/Driver/ToolChains/WebAssembly.h b/lib/Driver/ToolChains/WebAssembly.h index b69549aaf8..d795bad900 100644 --- a/lib/Driver/ToolChains/WebAssembly.h +++ b/lib/Driver/ToolChains/WebAssembly.h @@ -51,14 +51,15 @@ private: bool hasBlocksRuntime() const override; bool SupportsProfiling() const override; bool HasNativeLLVMSupport() const override; - void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, - llvm::opt::ArgStringList &CC1Args, - Action::OffloadKind DeviceOffloadKind) const override; + void + addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args, + Action::OffloadKind DeviceOffloadKind) const override; RuntimeLibType GetDefaultRuntimeLibType() const override; CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override; - void AddClangSystemIncludeArgs( - const llvm::opt::ArgList &DriverArgs, - llvm::opt::ArgStringList &CC1Args) const override; + void + AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const override; void AddClangCXXStdlibIncludeArgs( const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; diff --git a/test/CodeGen/builtins-wasm.c b/test/CodeGen/builtins-wasm.c index 1eb5222884..775bca374b 100644 --- a/test/CodeGen/builtins-wasm.c +++ b/test/CodeGen/builtins-wasm.c @@ -5,66 +5,66 @@ __SIZE_TYPE__ f0(void) { return __builtin_wasm_memory_size(0); -// WEBASSEMBLY32: call {{i.*}} @llvm.wasm.memory.size.i32(i32 0) -// WEBASSEMBLY64: call {{i.*}} @llvm.wasm.memory.size.i64(i32 0) + // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.memory.size.i32(i32 0) + // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.memory.size.i64(i32 0) } __SIZE_TYPE__ f1(__SIZE_TYPE__ delta) { return __builtin_wasm_memory_grow(0, delta); -// WEBASSEMBLY32: call i32 @llvm.wasm.memory.grow.i32(i32 0, i32 %{{.*}}) -// WEBASSEMBLY64: call i64 @llvm.wasm.memory.grow.i64(i32 0, i64 %{{.*}}) + // WEBASSEMBLY32: call i32 @llvm.wasm.memory.grow.i32(i32 0, i32 %{{.*}}) + // WEBASSEMBLY64: call i64 @llvm.wasm.memory.grow.i64(i32 0, i64 %{{.*}}) } __SIZE_TYPE__ f2(void) { return __builtin_wasm_mem_size(0); -// WEBASSEMBLY32: call {{i.*}} @llvm.wasm.mem.size.i32(i32 0) -// WEBASSEMBLY64: call {{i.*}} @llvm.wasm.mem.size.i64(i32 0) + // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.mem.size.i32(i32 0) + // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.mem.size.i64(i32 0) } __SIZE_TYPE__ f3(__SIZE_TYPE__ delta) { return __builtin_wasm_mem_grow(0, delta); -// WEBASSEMBLY32: call i32 @llvm.wasm.mem.grow.i32(i32 0, i32 %{{.*}}) -// WEBASSEMBLY64: call i64 @llvm.wasm.mem.grow.i64(i32 0, i64 %{{.*}}) + // WEBASSEMBLY32: call i32 @llvm.wasm.mem.grow.i32(i32 0, i32 %{{.*}}) + // WEBASSEMBLY64: call i64 @llvm.wasm.mem.grow.i64(i32 0, i64 %{{.*}}) } __SIZE_TYPE__ f4(void) { return __builtin_wasm_current_memory(); -// WEBASSEMBLY32: call {{i.*}} @llvm.wasm.current.memory.i32() -// WEBASSEMBLY64: call {{i.*}} @llvm.wasm.current.memory.i64() + // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.current.memory.i32() + // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.current.memory.i64() } __SIZE_TYPE__ f5(__SIZE_TYPE__ delta) { return __builtin_wasm_grow_memory(delta); -// WEBASSEMBLY32: call i32 @llvm.wasm.grow.memory.i32(i32 %{{.*}}) -// WEBASSEMBLY64: call i64 @llvm.wasm.grow.memory.i64(i64 %{{.*}}) + // WEBASSEMBLY32: call i32 @llvm.wasm.grow.memory.i32(i32 %{{.*}}) + // WEBASSEMBLY64: call i64 @llvm.wasm.grow.memory.i64(i64 %{{.*}}) } void f6(unsigned int tag, void *obj) { return __builtin_wasm_throw(tag, obj); -// WEBASSEMBLY32: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}}) -// WEBASSEMBLY64: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}}) + // WEBASSEMBLY32: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}}) + // WEBASSEMBLY64: call void @llvm.wasm.throw(i32 %{{.*}}, i8* %{{.*}}) } void f7(void) { return __builtin_wasm_rethrow(); -// WEBASSEMBLY32: call void @llvm.wasm.rethrow() -// WEBASSEMBLY64: call void @llvm.wasm.rethrow() + // WEBASSEMBLY32: call void @llvm.wasm.rethrow() + // WEBASSEMBLY64: call void @llvm.wasm.rethrow() } int f8(int *addr, int expected, long long timeout) { return __builtin_wasm_atomic_wait_i32(addr, expected, timeout); -// WEBASSEMBLY32: call i32 @llvm.wasm.atomic.wait.i32(i32* %{{.*}}, i32 %{{.*}}, i64 %{{.*}}) -// WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i32(i32* %{{.*}}, i32 %{{.*}}, i64 %{{.*}}) + // WEBASSEMBLY32: call i32 @llvm.wasm.atomic.wait.i32(i32* %{{.*}}, i32 %{{.*}}, i64 %{{.*}}) + // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i32(i32* %{{.*}}, i32 %{{.*}}, i64 %{{.*}}) } int f9(long long *addr, long long expected, long long timeout) { return __builtin_wasm_atomic_wait_i64(addr, expected, timeout); -// WEBASSEMBLY32: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 %{{.*}}, i64 %{{.*}}) -// WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 %{{.*}}, i64 %{{.*}}) + // WEBASSEMBLY32: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 %{{.*}}, i64 %{{.*}}) + // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 %{{.*}}, i64 %{{.*}}) } unsigned int f10(int *addr, int count) { return __builtin_wasm_atomic_notify(addr, count); -// WEBASSEMBLY32: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}}) -// WEBASSEMBLY64: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}}) + // WEBASSEMBLY32: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}}) + // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}}) } diff --git a/test/CodeGen/wasm-arguments.c b/test/CodeGen/wasm-arguments.c index 9283dd5d15..cd3f45ab1a 100644 --- a/test/CodeGen/wasm-arguments.c +++ b/test/CodeGen/wasm-arguments.c @@ -54,7 +54,6 @@ void f5(char a, short b) {} // WEBASSEMBLY64: define void @f6(i8 zeroext %a, i16 zeroext %b) void f6(unsigned char a, unsigned short b) {} - enum my_enum { ENUM1, ENUM2, diff --git a/test/CodeGen/wasm-varargs.c b/test/CodeGen/wasm-varargs.c index acbd590cc2..4cb46f1c19 100644 --- a/test/CodeGen/wasm-varargs.c +++ b/test/CodeGen/wasm-varargs.c @@ -65,9 +65,9 @@ long long test_i64(char *fmt, ...) { // CHECK: } struct S { - int x; - int y; - int z; + int x; + int y; + int z; }; struct S test_struct(char *fmt, ...) { diff --git a/test/CodeGenCXX/static-init-wasm.cpp b/test/CodeGenCXX/static-init-wasm.cpp index 68d139157e..579818ce5a 100644 --- a/test/CodeGenCXX/static-init-wasm.cpp +++ b/test/CodeGenCXX/static-init-wasm.cpp @@ -38,7 +38,7 @@ void g() { // Test various aspects of static constructor calls. struct A { - A(); + A(); }; A theA; diff --git a/test/CodeGenCXX/wasm-args-returns.cpp b/test/CodeGenCXX/wasm-args-returns.cpp index 24adc8e087..a7c4e1e282 100644 --- a/test/CodeGenCXX/wasm-args-returns.cpp +++ b/test/CodeGenCXX/wasm-args-returns.cpp @@ -3,16 +3,18 @@ // RUN: %clang_cc1 -O1 -triple wasm64-unknown-unknown -emit-llvm -o - %s \ // RUN: | FileCheck %s -#define concat_(x, y) x ## y +#define concat_(x, y) x##y #define concat(x, y) concat_(x, y) -#define test(T) \ +#define test(T) \ T forward(T x) { return x; } \ - void use(T x); \ - T concat(def_, T)(void); \ + void use(T x); \ + T concat(def_, T)(void); \ void concat(test_, T)(void) { use(concat(def_, T)()); } -struct one_field { double d; }; +struct one_field { + double d; +}; test(one_field); // CHECK: define double @_Z7forward9one_field(double returned %{{.*}}) // @@ -24,7 +26,9 @@ test(one_field); // CHECK: declare void @_Z3use9one_field(double) // CHECK: declare double @_Z13def_one_fieldv() -struct two_fields { double d, e; }; +struct two_fields { + double d, e; +}; test(two_fields); // CHECK: define void @_Z7forward10two_fields(%struct.two_fields* noalias nocapture sret %{{.*}}, %struct.two_fields* byval nocapture readonly align 8 %{{.*}}) // @@ -38,8 +42,8 @@ test(two_fields); // CHECK: declare void @_Z14def_two_fieldsv(%struct.two_fields* sret) struct copy_ctor { - double d; - copy_ctor(copy_ctor const&); + double d; + copy_ctor(copy_ctor const &); }; test(copy_ctor); // CHECK: define void @_Z7forward9copy_ctor(%struct.copy_ctor* noalias sret %{{.*}}, %struct.copy_ctor* %{{.*}}) @@ -56,8 +60,8 @@ test(copy_ctor); // CHECK: declare void @_Z13def_copy_ctorv(%struct.copy_ctor* sret) struct __attribute__((aligned(16))) aligned_copy_ctor { - double d, e; - aligned_copy_ctor(aligned_copy_ctor const&); + double d, e; + aligned_copy_ctor(aligned_copy_ctor const &); }; test(aligned_copy_ctor); // CHECK: define void @_Z7forward17aligned_copy_ctor(%struct.aligned_copy_ctor* noalias sret %{{.*}}, %struct.aligned_copy_ctor* %{{.*}}) @@ -86,7 +90,7 @@ test(empty); // CHECK: declare void @_Z9def_emptyv() struct one_bitfield { - int d:3; + int d : 3; }; test(one_bitfield); // CHECK: define i32 @_Z7forward12one_bitfield(i32 returned %{{.*}}) diff --git a/test/Driver/wasm32-unknown-unknown.cpp b/test/Driver/wasm32-unknown-unknown.cpp index 3f44d93df5..90b58503fa 100644 --- a/test/Driver/wasm32-unknown-unknown.cpp +++ b/test/Driver/wasm32-unknown-unknown.cpp @@ -29,7 +29,7 @@ int align_l = __alignof(long); int align_ll = __alignof(long long); // CHECK: @align_p = hidden global i32 4 -int align_p = __alignof(void*); +int align_p = __alignof(void *); // CHECK: @align_f = hidden global i32 4 int align_f = __alignof(float); @@ -99,17 +99,20 @@ double check_double() { return 0; } // CHECK: fp128 @check_longdouble() long double check_longdouble() { return 0; } - } -template void Switch(); -template<> void Switch<4>(); -template<> void Switch<8>(); -template<> void Switch<16>(); +template +void Switch(); +template <> +void Switch<4>(); +template <> +void Switch<8>(); +template <> +void Switch<16>(); void check_pointer_size() { // CHECK: SwitchILi4 - Switch(); + Switch(); // CHECK: SwitchILi8 Switch(); diff --git a/test/Driver/wasm64-unknown-unknown.cpp b/test/Driver/wasm64-unknown-unknown.cpp index 6162759884..9ee4a1b566 100644 --- a/test/Driver/wasm64-unknown-unknown.cpp +++ b/test/Driver/wasm64-unknown-unknown.cpp @@ -29,7 +29,7 @@ int align_l = __alignof(long); int align_ll = __alignof(long long); // CHECK: @align_p = hidden global i32 8 -int align_p = __alignof(void*); +int align_p = __alignof(void *); // CHECK: @align_f = hidden global i32 4 int align_f = __alignof(float); @@ -99,17 +99,20 @@ double check_double() { return 0; } // CHECK: fp128 @check_longdouble() long double check_longdouble() { return 0; } - } -template void Switch(); -template<> void Switch<4>(); -template<> void Switch<8>(); -template<> void Switch<16>(); +template +void Switch(); +template <> +void Switch<4>(); +template <> +void Switch<8>(); +template <> +void Switch<16>(); void check_pointer_size() { // CHECK: SwitchILi8 - Switch(); + Switch(); // CHECK: SwitchILi8 Switch(); -- 2.40.0