Skip to content

Commit bd15416

Browse files
committed
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 <git@stefan-marr.de>
1 parent 2bc0f80 commit bd15416

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ jobs:
2626
run: |
2727
sudo apt-get install libcppunit-dev
2828
29-
- name: Install Clang 19
29+
- name: Install Clang 20
3030
run: |
3131
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
32-
sudo add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main"
32+
sudo add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main"
3333
sudo apt-get update
34-
sudo apt-get install -y clang-19 clang-tidy-19
34+
sudo apt-get install -y clang-20 clang-tidy-20
3535
if: matrix.compiler == 'clang'
3636

3737
- name: Install Clang Format
38-
run: sudo apt-get install -y clang-format-19
38+
run: sudo apt-get install -y clang-format-20
3939
if: matrix.compiler == 'clang' && matrix.gc == 'GENERATIONAL'
4040

4141
- name: Build SOM VM
@@ -68,12 +68,12 @@ jobs:
6868
- name: Clang Tidy
6969
if: matrix.compiler == 'clang'
7070
run: |
71-
clang-tidy-19 --config-file=.clang-tidy src/**/*.cpp -- -fdiagnostics-absolute-paths -DGC_TYPE=${{ matrix.gc}} ${{ matrix.integers }} -DUNITTESTS
71+
clang-tidy-20 --config-file=.clang-tidy src/**/*.cpp -- -fdiagnostics-absolute-paths -DGC_TYPE=${{ matrix.gc}} ${{ matrix.integers }} -DUNITTESTS
7272
7373
- name: Clang Format
7474
if: matrix.compiler == 'clang' && matrix.gc == 'GENERATIONAL'
7575
run: |
76-
clang-format-19 --dry-run --style=file --Werror src/*.cpp src/**/*.cpp src/**/*.h
76+
clang-format-20 --dry-run --style=file --Werror src/*.cpp src/**/*.cpp src/**/*.h
7777
7878
# Disabled because it's too slow with the sanitizers
7979
# - name: Test SomSom

lint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/bin/sh
22

3-
CLANG_FORMAT="clang-format-mp-19 -i --style=file --Werror src/*.cpp src/**/*.cpp src/**/*.h"
3+
CLANG_FORMAT="clang-format-mp-20 -i --style=file --Werror src/*.cpp src/**/*.cpp src/**/*.h"
44
$CLANG_FORMAT
55

66
## The check --enable-check-profile flag gives an overview of where clang-tidy spends its time
77
# --enable-check-profile
88

9-
CLANG_START="clang-tidy-mp-19 --config-file=.clang-tidy"
9+
CLANG_START="clang-tidy-mp-20 --config-file=.clang-tidy"
1010
CLANG_END="--fix \
1111
-- -I/opt/local/include/ -fdiagnostics-absolute-paths \
1212
-DGC_TYPE=GENERATIONAL -DUSE_TAGGING=false -DCACHE_INTEGER=false -DUNITTESTS"

src/memory/GarbageCollector.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,20 @@
2727
*/
2828

2929
#include "../misc/defs.h"
30+
#include "../vm/Print.h"
3031
#include "../vmobjects/ObjectFormats.h"
3132

33+
class IGarbageCollector {
34+
public:
35+
virtual ~IGarbageCollector() = default;
36+
virtual void Collect() = 0;
37+
};
38+
3239
template <class HEAP_T>
33-
class GarbageCollector {
40+
class GarbageCollector : public IGarbageCollector {
3441
public:
3542
explicit GarbageCollector(HEAP_T* h) : heap(h) {}
36-
virtual ~GarbageCollector() = default;
37-
virtual void Collect() = 0;
38-
void PrintGCStat() const;
39-
void PrintCollectStat() const;
43+
~GarbageCollector() override = default;
4044

4145
protected:
4246
HEAP_T* const heap;

src/vm/Universe.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ void Universe::Shutdown() {
142142
}
143143

144144
static void printVmConfig() {
145+
// NOLINTNEXTLINE(misc-redundant-expression)
145146
if (GC_TYPE == GENERATIONAL) {
146147
cout << "\tgarbage collector: generational\n";
147148
} else if (GC_TYPE == COPYING) {
@@ -644,6 +645,7 @@ VMArray* Universe::NewArray(size_t size) {
644645
auto* result = new (GetHeap<HEAP_CLS>(),
645646
additionalBytes ALLOC_OUTSIDE_NURSERY(outsideNursery))
646647
VMArray(size, additionalBytes);
648+
// NOLINTNEXTLINE(misc-redundant-expression)
647649
if ((GC_TYPE == GENERATIONAL) && outsideNursery) {
648650
result->SetGCField(MASK_OBJECT_IS_OLD);
649651
}

0 commit comments

Comments
 (0)