From 5fa018106bde15d414047a38ddac162323739419 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Fri, 28 Jul 2023 01:48:42 +0200 Subject: [PATCH] Prefer clang-format-14 (#1517) * Change preferred clang version to 14 (for formatting) * Add `--show-paths` arg to format.py for printing paths to clang-* binaries used * Run formatter (clang-format-14) * run formatter --- format.py | 17 +++++++++++++++-- src/code/z_actor.c | 10 +++++----- src/code/z_effect_soft_sprite.c | 10 +++++----- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/format.py b/format.py index 826a707834..51b7b6ac7b 100755 --- a/format.py +++ b/format.py @@ -14,8 +14,8 @@ from typing import List # clang-format, clang-tidy and clang-apply-replacements default version -# Version 11 is used when available for more consistency between contributors -CLANG_VER = 11 +# This specific version is used when available, for more consistency between contributors +CLANG_VER = 14 # Clang-Format options (see .clang-format for rules applied) FORMAT_OPTS = "-i -style=file" @@ -144,6 +144,12 @@ def format_files(src_files: List[str], extra_files: List[str], nb_jobs: int): def main(): parser = argparse.ArgumentParser(description="Format files in the codebase to enforce most style rules") + parser.add_argument( + "--show-paths", + dest="show_paths", + action="store_true", + help="Print the paths to the clang-* binaries used", + ) parser.add_argument("files", metavar="file", nargs="*") parser.add_argument( "-j", @@ -155,6 +161,13 @@ def main(): ) args = parser.parse_args() + if args.show_paths: + import shutil + + print("CLANG_FORMAT ->", shutil.which(CLANG_FORMAT)) + print("CLANG_TIDY ->", shutil.which(CLANG_TIDY)) + print("CLANG_APPLY_REPLACEMENTS ->", shutil.which(CLANG_APPLY_REPLACEMENTS)) + nb_jobs = args.jobs or multiprocessing.cpu_count() if nb_jobs > 1: if CLANG_APPLY_REPLACEMENTS is None: diff --git a/src/code/z_actor.c b/src/code/z_actor.c index d7cd85e3e7..04b8bbd7f8 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -2815,11 +2815,11 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos overlayEntry->numLoaded = 0; } - actorInit = (void*)(uintptr_t)( - (overlayEntry->initInfo != NULL) - ? (void*)((uintptr_t)overlayEntry->initInfo - - (intptr_t)((uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr)) - : NULL); + actorInit = (void*)(uintptr_t)((overlayEntry->initInfo != NULL) + ? (void*)((uintptr_t)overlayEntry->initInfo - + (intptr_t)((uintptr_t)overlayEntry->vramStart - + (uintptr_t)overlayEntry->loadedRamAddr)) + : NULL); } objBankIndex = Object_GetIndex(&play->objectCtx, actorInit->objectId); diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index afd563da22..55a1245a3f 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -213,11 +213,11 @@ void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initParams) { osSyncPrintf(VT_RST); } - initInfo = (void*)(uintptr_t)( - (overlayEntry->initInfo != NULL) - ? (void*)((uintptr_t)overlayEntry->initInfo - - (intptr_t)((uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr)) - : NULL); + initInfo = (void*)(uintptr_t)((overlayEntry->initInfo != NULL) + ? (void*)((uintptr_t)overlayEntry->initInfo - + (intptr_t)((uintptr_t)overlayEntry->vramStart - + (uintptr_t)overlayEntry->loadedRamAddr)) + : NULL); } if (initInfo->init == NULL) {