From 577298b266952b20fe944dedc95a51ae40a0aec4 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Sat, 16 Aug 2025 16:52:22 +0100 Subject: [PATCH] Update clang, format, and tidy to version 20 and resolve some issues - add a non-templated GC interface to ensure the vtable is initialized on all compilers Signed-off-by: Stefan Marr --- .github/workflows/ci.yml | 16 ++++++++-------- lint.sh | 4 ++-- src/memory/GarbageCollector.h | 14 +++++++++----- src/vm/Universe.cpp | 9 +++++---- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3faf7b63..bf1e3a0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,24 +26,24 @@ jobs: run: | sudo apt-get install libcppunit-dev - - name: Install Clang 19 + - name: Install Clang 20 run: | wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main" + sudo add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main" sudo apt-get update - sudo apt-get install -y clang-19 clang-tidy-19 + sudo apt-get install -y clang-20 clang-tidy-20 if: matrix.compiler == 'clang' - name: Install Clang Format - run: sudo apt-get install -y clang-format-19 + run: sudo apt-get install -y clang-format-20 if: matrix.compiler == 'clang' && matrix.gc == 'GENERATIONAL' - name: Build SOM VM run: | if [ "${{ matrix.compiler }}" = "clang" ] then - export CC=clang-19 - export CXX=clang++-19 + export CC=clang-20 + export CXX=clang++-20 else export CC=gcc export CXX=g++ @@ -68,12 +68,12 @@ jobs: - name: Clang Tidy if: matrix.compiler == 'clang' run: | - clang-tidy-19 --config-file=.clang-tidy src/**/*.cpp -- -fdiagnostics-absolute-paths -DGC_TYPE=${{ matrix.gc}} ${{ matrix.integers }} -DUNITTESTS + clang-tidy-20 --config-file=.clang-tidy src/**/*.cpp -- -fdiagnostics-absolute-paths -DGC_TYPE=${{ matrix.gc}} ${{ matrix.integers }} -DUNITTESTS - name: Clang Format if: matrix.compiler == 'clang' && matrix.gc == 'GENERATIONAL' run: | - clang-format-19 --dry-run --style=file --Werror src/*.cpp src/**/*.cpp src/**/*.h + clang-format-20 --dry-run --style=file --Werror src/*.cpp src/**/*.cpp src/**/*.h # Disabled because it's too slow with the sanitizers # - name: Test SomSom diff --git a/lint.sh b/lint.sh index ad973e5b..eb0d54cd 100755 --- a/lint.sh +++ b/lint.sh @@ -1,12 +1,12 @@ #!/bin/sh -CLANG_FORMAT="clang-format-mp-19 -i --style=file --Werror src/*.cpp src/**/*.cpp src/**/*.h" +CLANG_FORMAT="clang-format-mp-20 -i --style=file --Werror src/*.cpp src/**/*.cpp src/**/*.h" $CLANG_FORMAT ## The check --enable-check-profile flag gives an overview of where clang-tidy spends its time # --enable-check-profile -CLANG_START="clang-tidy-mp-19 --config-file=.clang-tidy" +CLANG_START="clang-tidy-mp-20 --config-file=.clang-tidy" CLANG_END="--fix \ -- -I/opt/local/include/ -fdiagnostics-absolute-paths \ -DGC_TYPE=GENERATIONAL -DUSE_TAGGING=false -DCACHE_INTEGER=false -DUNITTESTS" diff --git a/src/memory/GarbageCollector.h b/src/memory/GarbageCollector.h index 8cb0ee34..8f42e3b3 100644 --- a/src/memory/GarbageCollector.h +++ b/src/memory/GarbageCollector.h @@ -27,16 +27,20 @@ */ #include "../misc/defs.h" +#include "../vm/Print.h" #include "../vmobjects/ObjectFormats.h" +class IGarbageCollector { +public: + virtual ~IGarbageCollector() = default; + virtual void Collect() = 0; +}; + template -class GarbageCollector { +class GarbageCollector : public IGarbageCollector { public: explicit GarbageCollector(HEAP_T* h) : heap(h) {} - virtual ~GarbageCollector() = default; - virtual void Collect() = 0; - void PrintGCStat() const; - void PrintCollectStat() const; + ~GarbageCollector() override = default; protected: HEAP_T* const heap; diff --git a/src/vm/Universe.cpp b/src/vm/Universe.cpp index 017a5539..7df6503a 100644 --- a/src/vm/Universe.cpp +++ b/src/vm/Universe.cpp @@ -142,13 +142,13 @@ void Universe::Shutdown() { } static void printVmConfig() { - if (GC_TYPE == GENERATIONAL) { + if (GC_TYPE == GENERATIONAL) { // NOLINT(misc-redundant-expression) cout << "\tgarbage collector: generational\n"; - } else if (GC_TYPE == COPYING) { + } else if (GC_TYPE == COPYING) { // NOLINT(misc-redundant-expression) cout << "\tgarbage collector: copying\n"; - } else if (GC_TYPE == MARK_SWEEP) { + } else if (GC_TYPE == MARK_SWEEP) { // NOLINT(misc-redundant-expression) cout << "\tgarbage collector: mark-sweep\n"; - } else if (GC_TYPE == DEBUG_COPYING) { + } else if (GC_TYPE == DEBUG_COPYING) { // NOLINT(misc-redundant-expression) cout << "\tgarbage collector: debug copying\n"; } else { cout << "\tgarbage collector: unknown\n"; @@ -644,6 +644,7 @@ VMArray* Universe::NewArray(size_t size) { auto* result = new (GetHeap(), additionalBytes ALLOC_OUTSIDE_NURSERY(outsideNursery)) VMArray(size, additionalBytes); + // NOLINTNEXTLINE(misc-redundant-expression) if ((GC_TYPE == GENERATIONAL) && outsideNursery) { result->SetGCField(MASK_OBJECT_IS_OLD); }