Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# using [clang-formt-12 options](https://releases.llvm.org/12.0.0/tools/clang/docs/ClangFormatStyleOptions.html)
# using [clang-format-20 options](https://releases.llvm.org/20.1.0/tools/clang/docs/ClangFormatStyleOptions.html)
RawStringFormats:
- Language: Cpp
Delimiters:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/coding_guidelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ jobs:
with:
fetch-depth: 0

- name: install clang-format-20
run: |
# clang-format 20 is not preinstalled on the runner; install it (and
# git-clang-format-20) from apt.llvm.org for the running Ubuntu
# release so the pinned version does not drift with the image.
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key \
| sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc >/dev/null
. /etc/os-release
echo "deb http://apt.llvm.org/${VERSION_CODENAME}/ llvm-toolchain-${VERSION_CODENAME}-20 main" \
| sudo tee /etc/apt/sources.list.d/llvm.list >/dev/null
sudo apt-get update -qq
sudo apt-get install -y -qq clang-format-20
clang-format-20 --version

# github.event.pull_request.base.label = ${{github.repository}}/${{github.base_ref}}
- name: Run Coding Guidelines Checks
run: /usr/bin/env python3 ./ci/coding_guidelines_check.py --commits ${{ github.event.pull_request.base.sha }}..HEAD
4 changes: 2 additions & 2 deletions ci/coding_guidelines_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import sys
import unittest

CLANG_FORMAT_CMD = "clang-format-14"
GIT_CLANG_FORMAT_CMD = "git-clang-format-14"
CLANG_FORMAT_CMD = "clang-format-20"
GIT_CLANG_FORMAT_CMD = "git-clang-format-20"

# glob style patterns
EXCLUDE_PATHS = [
Expand Down
10 changes: 5 additions & 5 deletions ci/pre_commit_hook_sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# This is a sample of pre-commit hook that can be used to make your code fit the WAMR CI code style requirements.
# You need to have clang-format-12 installed to use this hook.
# You need to have clang-format-20 installed to use this hook.
# To add this pre-commit hook, copy it to <path_to_wamr>/.git/hooks/pre-commit
# (you don't need any extensions here)

Expand All @@ -22,10 +22,10 @@ is_c_or_cpp_file() {
# Loop through staged files and apply command "abc" to C and C++ files
for staged_file in $(git diff --cached --name-only); do
if is_c_or_cpp_file "$staged_file"; then
clang-format-12 -Werror --style file --dry-run "$staged_file" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Issues are found in $staged_file. Applying the fix"
clang-format-12 --style file -i "$staged_file"
clang-format-20 -Werror --style file --dry-run "$staged_file" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Issues are found in $staged_file. Applying the fix"
clang-format-20 --style file -i "$staged_file"
fi
git add "$staged_file" # Add the modified file back to staging
fi
Expand Down
3 changes: 2 additions & 1 deletion core/iwasm/aot/aot_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -5553,7 +5553,8 @@ aot_const_str_set_insert(const uint8 *str, int32 len, AOTModule *module,
#if WASM_ENABLE_DYNAMIC_AOT_DEBUG != 0
AOTModule *g_dynamic_aot_module = NULL;

void __attribute__((noinline)) __enable_dynamic_aot_debug(void)
void __attribute__((noinline))
__enable_dynamic_aot_debug(void)
{
/* empty implementation. */
}
Expand Down
5 changes: 1 addition & 4 deletions core/iwasm/aot/arch/aot_reloc_riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,7 @@ typedef struct RelocTypeStrMap {
char *reloc_str;
} RelocTypeStrMap;

#define RELOC_TYPE_MAP(reloc_type) \
{ \
reloc_type, #reloc_type \
}
#define RELOC_TYPE_MAP(reloc_type) { reloc_type, #reloc_type }

static RelocTypeStrMap reloc_type_str_maps[] = {
RELOC_TYPE_MAP(R_RISCV_32), RELOC_TYPE_MAP(R_RISCV_64),
Expand Down
8 changes: 4 additions & 4 deletions core/iwasm/aot/arch/aot_reloc_x86_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr,
case R_X86_64_GOTPCRELX:
case R_X86_64_REX_GOTPCRELX:
{
intptr_t target_addr = (intptr_t) /* S + A - P */
intptr_t target_addr = (intptr_t)/* S + A - P */
((uintptr_t)symbol_addr + reloc_addend
- (uintptr_t)(target_section_addr + reloc_offset));

Expand All @@ -176,7 +176,7 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr,
}
case R_X86_64_PC64:
{
intptr_t target_addr = (intptr_t) /* S + A - P */
intptr_t target_addr = (intptr_t)/* S + A - P */
((uintptr_t)symbol_addr + reloc_addend
- (uintptr_t)(target_section_addr + reloc_offset));

Expand Down Expand Up @@ -226,12 +226,12 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr,
plt = (uint8 *)module->code + module->code_size
- get_plt_table_size()
+ get_plt_item_size() * symbol_index;
target_addr = (intptr_t) /* L + A - P */
target_addr = (intptr_t)/* L + A - P */
((uintptr_t)plt + reloc_addend
- (uintptr_t)(target_section_addr + reloc_offset));
}
else {
target_addr = (intptr_t) /* S + A - P */
target_addr = (intptr_t)/* S + A - P */
((uintptr_t)symbol_addr + reloc_addend
- (uintptr_t)(target_section_addr + reloc_offset));
}
Expand Down
5 changes: 1 addition & 4 deletions core/iwasm/aot/debug/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@
/* EI_NIDENT is defined in "Included Files" section */

#define EI_MAGIC_SIZE 4
#define EI_MAGIC \
{ \
0x7f, 'E', 'L', 'F' \
}
#define EI_MAGIC { 0x7f, 'E', 'L', 'F' }

#define ELFMAG0 0x7f /* EI_MAG */
#define ELFMAG1 'E'
Expand Down
8 changes: 4 additions & 4 deletions core/iwasm/aot/debug/elf32.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
****************************************************************************/

#define ELF32_ST_BIND(i) ((i) >> 4)
#define ELF32_ST_TYPE(i) ((i)&0xf)
#define ELF32_ST_INFO(b, t) (((b) << 4) | ((t)&0xf))
#define ELF32_ST_TYPE(i) ((i) & 0xf)
#define ELF32_ST_INFO(b, t) (((b) << 4) | ((t) & 0xf))

/* Definitions for Elf32_Rel*::r_info */

#define ELF32_R_SYM(i) ((i) >> 8)
#define ELF32_R_TYPE(i) ((i)&0xff)
#define ELF32_R_INFO(s, t) (((s) << 8) | ((t)&0xff))
#define ELF32_R_TYPE(i) ((i) & 0xff)
#define ELF32_R_INFO(s, t) (((s) << 8) | ((t) & 0xff))

#if 0
#define ELF_R_SYM(i) ELF32_R_SYM(i)
Expand Down
4 changes: 2 additions & 2 deletions core/iwasm/aot/debug/elf64.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
/* Definitions for Elf64_Rel*::r_info */

#define ELF64_R_SYM(i) ((i) >> 32)
#define ELF64_R_TYPE(i) ((i)&0xffffffffL)
#define ELF64_R_INFO(s, t) (((s) << 32) + ((t)&0xffffffffL))
#define ELF64_R_TYPE(i) ((i) & 0xffffffffL)
#define ELF64_R_INFO(s, t) (((s) << 32) + ((t) & 0xffffffffL))

#if 0
#define ELF_R_SYM(i) ELF64_R_SYM(i)
Expand Down
6 changes: 4 additions & 2 deletions core/iwasm/common/gc/stringref/stringref_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
/******************* gc finalizer *****************/
void
wasm_string_destroy(WASMString str_obj)
{}
{
}

/******************* opcode functions *****************/

Expand Down Expand Up @@ -133,4 +134,5 @@ wasm_string_rewind(WASMString str_obj, uint32 pos, uint32 count,

void
wasm_string_dump(WASMString str_obj)
{}
{
}
3 changes: 2 additions & 1 deletion core/iwasm/common/wasm_blocking_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ wasm_runtime_begin_blocking_op(wasm_exec_env_t env)

void
wasm_runtime_end_blocking_op(wasm_exec_env_t env)
{}
{
}

#endif /* WASM_ENABLE_THREAD_MGR && OS_ENABLE_WAKEUP_BLOCKING_OP */
11 changes: 6 additions & 5 deletions core/iwasm/common/wasm_c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -3248,11 +3248,12 @@ wasm_func_copy(const wasm_func_t *func)
return NULL;
}

if (!(cloned = func->with_env ? wasm_func_new_with_env_basic(
func->store, func->type, func->u.cb_env.cb,
func->u.cb_env.env, func->u.cb_env.finalizer)
: wasm_func_new_basic(func->store, func->type,
func->u.cb))) {
if (!(cloned =
func->with_env
? wasm_func_new_with_env_basic(
func->store, func->type, func->u.cb_env.cb,
func->u.cb_env.env, func->u.cb_env.finalizer)
: wasm_func_new_basic(func->store, func->type, func->u.cb))) {
goto failed;
}

Expand Down
6 changes: 3 additions & 3 deletions core/iwasm/compilation/aot_emit_aot_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

#define CHECK_SIZE(size) \
do { \
if (size == (uint32)-1) { \
if (size == (uint32) - 1) { \
aot_set_last_error("get symbol size failed."); \
return (uint32)-1; \
return (uint32) - 1; \
} \
} while (0)

Expand Down Expand Up @@ -3674,7 +3674,7 @@ aot_resolve_stack_sizes(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
unsigned int stack_consumption_to_call_wrapped_func =
musttail ? 0
: aot_estimate_stack_usage_for_function_call(
comp_ctx, func_ctx->aot_func->func_type);
comp_ctx, func_ctx->aot_func->func_type);

/*
* LLVM seems to eliminate calls to an empty function
Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/compilation/aot_llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2520,7 +2520,7 @@ jit_stack_size_callback(void *user_data, const char *name, size_t namelen,
stack_consumption_to_call_wrapped_func =
musttail ? 0
: aot_estimate_stack_usage_for_function_call(
comp_ctx, func_ctx->aot_func->func_type);
comp_ctx, func_ctx->aot_func->func_type);
LOG_VERBOSE("func %.*s stack %u + %zu + %u", (int)namelen, name,
stack_consumption_to_call_wrapped_func, stack_size, call_size);

Expand Down
6 changes: 4 additions & 2 deletions core/iwasm/compilation/aot_orc_extra2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ MyCompiler::MyCompiler(llvm::orc::JITTargetMachineBuilder JTMB, cb_t cb,
, JTMB(std::move(JTMB))
, cb(cb)
, cb_data(cb_data)
{}
{
}

class PrintStackSizes : public llvm::MachineFunctionPass
{
Expand All @@ -59,7 +60,8 @@ PrintStackSizes::PrintStackSizes(cb_t cb, void *cb_data)
: MachineFunctionPass(ID)
, cb(cb)
, cb_data(cb_data)
{}
{
}

char PrintStackSizes::ID = 0;

Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/compilation/debug/dwarf_extractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extern "C" {

typedef unsigned int LLDBLangType;
#define LLDB_TO_LLVM_LANG_TYPE(lldb_lang_type) \
(LLVMDWARFSourceLanguage)(((lldb_lang_type) > 0 ? (lldb_lang_type)-1 : 1))
(LLVMDWARFSourceLanguage)(((lldb_lang_type) > 0 ? (lldb_lang_type) - 1 : 1))

struct AOTCompData;
typedef struct AOTCompData *aot_comp_data_t;
Expand Down
3 changes: 2 additions & 1 deletion core/iwasm/fast-jit/cg/x86-64/jit_codegen_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ class JitErrorHandler : public ErrorHandler

JitErrorHandler()
: err(kErrorOk)
{}
{
}

void handleError(Error e, const char *msg, BaseEmitter *base) override
{
Expand Down
4 changes: 2 additions & 2 deletions core/iwasm/fast-jit/jit_ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -1866,14 +1866,14 @@ jit_cc_update_cfg(JitCompContext *cc);
*/
#define JIT_FOREACH_BLOCK_REVERSE(CC, I, B) \
for ((I) = (CC)->_ann._label_num; (I) > 2; (I)--) \
if (((B) = (CC)->_ann._label_basic_block[(I)-1]))
if (((B) = (CC)->_ann._label_basic_block[(I) - 1]))

/**
* The version that includes entry and exit block.
*/
#define JIT_FOREACH_BLOCK_REVERSE_ENTRY_EXIT(CC, I, B) \
for ((I) = (CC)->_ann._label_num; (I) > 0; (I)--) \
if (((B) = (CC)->_ann._label_basic_block[(I)-1]))
if (((B) = (CC)->_ann._label_basic_block[(I) - 1]))

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/interpreter/wasm_interp_classic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2438,7 +2438,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
else
cur_func_type = cur_func->u.func->func_type;

/* clang-format off */
/* clang-format off */
#if WASM_ENABLE_GC == 0
if (cur_type != cur_func_type) {
wasm_set_exception(module, "indirect call type mismatch");
Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/interpreter/wasm_interp_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
else
cur_func_type = cur_func->u.func->func_type;

/* clang-format off */
/* clang-format off */
#if WASM_ENABLE_GC == 0
if (cur_type != cur_func_type) {
wasm_set_exception(module, "indirect call type mismatch");
Expand Down
4 changes: 2 additions & 2 deletions core/iwasm/libraries/debug-engine/debug_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ typedef enum WasmAddressType {
#define WASM_ADDR(type, id, offset) \
(((uint64)type << 62) | ((uint64)0 << 32) | ((uint64)offset << 0))

#define WASM_ADDR_TYPE(addr) (((addr)&0xC000000000000000) >> 62)
#define WASM_ADDR_OFFSET(addr) (((addr)&0x00000000FFFFFFFF))
#define WASM_ADDR_TYPE(addr) (((addr) & 0xC000000000000000) >> 62)
#define WASM_ADDR_OFFSET(addr) (((addr) & 0x00000000FFFFFFFF))

#define INVALIED_ADDR (0xFFFFFFFFFFFFFFFF)

Expand Down
6 changes: 3 additions & 3 deletions core/shared/mem-alloc/ems/ems_gc_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ hmu_verify(void *vheap, hmu_t *hmu);

#endif /* end of BH_ENABLE_GC_VERIFY */

#define hmu_obj_size(s) ((s)-OBJ_EXTRA_SIZE)
#define hmu_obj_size(s) ((s) - OBJ_EXTRA_SIZE)

#define GC_ALIGN_8(s) (((uint32)(s) + 7) & (uint32)~7)

Expand Down Expand Up @@ -201,11 +201,11 @@ hmu_verify(void *vheap, hmu_t *hmu);

/* Get magic pointer from aligned object pointer */
#define ALIGNED_ALLOC_GET_MAGIC_PTR(obj) \
((uint32_t *)((char *)(obj)-ALIGNED_ALLOC_MAGIC_SIZE))
((uint32_t *)((char *)(obj) - ALIGNED_ALLOC_MAGIC_SIZE))

/* Get offset pointer from aligned object pointer */
#define ALIGNED_ALLOC_GET_OFFSET_PTR(obj) \
((uint32_t *)((char *)(obj)-ALIGNED_ALLOC_METADATA_SIZE))
((uint32_t *)((char *)(obj) - ALIGNED_ALLOC_METADATA_SIZE))

/* Extra overhead for aligned allocations beyond normal OBJ_EXTRA_SIZE */
#define ALIGNED_ALLOC_EXTRA_OVERHEAD ALIGNED_ALLOC_METADATA_SIZE
Expand Down
9 changes: 6 additions & 3 deletions core/shared/platform/alios/alios_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ os_realloc(void *ptr, unsigned size)

void
os_free(void *ptr)
{}
{
}

int
os_dumps_proc_mem_info(char *out, unsigned int size)
Expand Down Expand Up @@ -74,11 +75,13 @@ os_mprotect(void *addr, size_t size, int prot)

void
os_dcache_flush()
{}
{
}

void
os_icache_flush(void *start, size_t len)
{}
{
}

os_raw_file_handle
os_invalid_raw_handle(void)
Expand Down
3 changes: 2 additions & 1 deletion core/shared/platform/alios/alios_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,5 @@ os_thread_get_stack_boundary()

void
os_thread_jit_write_protect_np(bool enabled)
{}
{
}
3 changes: 2 additions & 1 deletion core/shared/platform/android/platform_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ bh_platform_init()

void
bh_platform_destroy()
{}
{
}

int
os_printf(const char *fmt, ...)
Expand Down
3 changes: 2 additions & 1 deletion core/shared/platform/common/freertos/freertos_malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ os_realloc(void *ptr, unsigned size)

void
os_free(void *ptr)
{}
{
}

int
os_dumps_proc_mem_info(char *out, unsigned int size)
Expand Down
Loading
Loading