From fc268acd6a516c10da45aaaf3c428c188c16c9e3 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 8 Nov 2024 18:26:39 -0500 Subject: [PATCH 01/19] ci: add GitHub action for clang-tidy Signed-off-by: Jared Van Bortel --- .clang-tidy | 118 +++++++++++++++++++++++++++++++ .github/workflows/cpp-linter.yml | 52 ++++++++++++++ 2 files changed, 170 insertions(+) create mode 100644 .clang-tidy create mode 100644 .github/workflows/cpp-linter.yml diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000000..ada9dca9d2a0 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,118 @@ +# vim: set ft=yaml: +HeaderFilterRegex: '/gpt4all-(backend|chat)/(src|include)/' +Checks: +- 'bugprone-*' +- 'cert-*' +- 'clang-analyzer-*' +- 'cppcoreguidelines-*' +- 'google-*' +- 'misc-*' +- 'modernize-*' +- 'performance-*' +- 'portability-*' +- 'readability-*' +- '-*-avoid-c-arrays' +- '-*-macro-to-enum' +- '-*-magic-numbers' +- '-*-narrowing-conversions' +- '-*-non-private-member-variables-in-classes' +- '-*-use-default-member-init' +- '-*readability-braces-around-statements' +- '-bugprone-assignment-in-if-condition' +- '-bugprone-branch-clone' +- '-bugprone-easily-swappable-parameters' +- '-bugprone-implicit-widening-of-multiplication-result' +- '-bugprone-inc-dec-in-conditions' +- '-bugprone-suspicious-string-compare' +- '-bugprone-switch-missing-default-case' +- '-cert-dcl03-c' +- '-cert-err33-c' +- '-cert-err58-cpp' +- '-clang-analyzer-core.CallAndMessage' +- '-clang-analyzer-deadcode.DeadStores' +- '-clang-analyzer-optin.performance.Padding' +- '-clang-diagnostic-missing-include-dirs' +- '-cppcoreguidelines-avoid-do-while' +- '-cppcoreguidelines-avoid-goto' +- '-cppcoreguidelines-avoid-non-const-global-variables' +- '-cppcoreguidelines-explicit-virtual-functions' +- '-cppcoreguidelines-init-variables' +- '-cppcoreguidelines-macro-usage' +- '-cppcoreguidelines-no-malloc' +- '-cppcoreguidelines-noexcept-move-operations' +- '-cppcoreguidelines-owning-memory' +- '-cppcoreguidelines-prefer-member-initializer' +- '-cppcoreguidelines-pro-bounds-array-to-pointer-decay' +- '-cppcoreguidelines-pro-bounds-pointer-arithmetic' +- '-cppcoreguidelines-pro-type-const-cast' +- '-cppcoreguidelines-pro-type-cstyle-cast' +- '-cppcoreguidelines-pro-type-member-init' +- '-cppcoreguidelines-pro-type-reinterpret-cast' +- '-cppcoreguidelines-pro-type-static-cast-downcast' +- '-cppcoreguidelines-pro-type-vararg' +- '-cppcoreguidelines-rvalue-reference-param-not-moved' +- '-cppcoreguidelines-special-member-functions' +- '-cppcoreguidelines-virtual-class-destructor' +- '-google-build-using-namespace' +- '-google-default-arguments' +- '-google-explicit-constructor' +- '-google-global-names-in-headers' +- '-google-readability-casting' +- '-google-readability-namespace-comments' +- '-google-readability-todo' +- '-google-runtime-int' +- '-misc-const-correctness' +- '-misc-include-cleaner' +- '-misc-no-recursion' +- '-misc-static-assert' +- '-misc-unused-parameters' +- '-misc-use-anonymous-namespace' +- '-misc-use-internal-linkage' +- '-modernize-avoid-bind' +- '-modernize-deprecated-headers' +- '-modernize-loop-convert' +- '-modernize-raw-string-literal' +- '-modernize-return-braced-init-list' +- '-modernize-use-auto' +- '-modernize-use-designated-initializers' +- '-modernize-use-equals-default' +- '-modernize-use-nodiscard' +- '-modernize-use-override' +- '-modernize-use-ranges' +- '-modernize-use-std-print' +- '-modernize-use-trailing-return-type' +- '-modernize-use-using' +- '-performance-avoid-endl' +- '-performance-enum-size' +- '-performance-faster-string-find' +- '-performance-for-range-copy' +- '-performance-implicit-conversion-in-loop' +- '-performance-move-const-arg' +- '-performance-noexcept-move-constructor' +- '-performance-unnecessary-copy-initialization' +- '-performance-unnecessary-value-param' +- '-readability-avoid-const-params-in-decls' +- '-readability-avoid-nested-conditional-operator' +- '-readability-avoid-return-with-void-value' +- '-readability-avoid-unconditional-preprocessor-if' +- '-readability-const-return-type' +- '-readability-container-size-empty' +- '-readability-convert-member-functions-to-static' +- '-readability-else-after-return' +- '-readability-function-cognitive-complexity' +- '-readability-identifier-length' +- '-readability-implicit-bool-conversion' +- '-readability-inconsistent-declaration-parameter-name' +- '-readability-math-missing-parentheses' +- '-readability-named-parameter' +- '-readability-non-const-parameter' +- '-readability-qualified-auto' +- '-readability-redundant-access-specifiers' +- '-readability-redundant-inline-specifier' +- '-readability-redundant-member-init' +- '-readability-redundant-string-init' +- '-readability-simplify-boolean-expr' +- '-readability-static-accessed-through-instance' +- '-readability-suspicious-call-argument' +- '-readability-uppercase-literal-suffix' +- '-readability-use-anyofallof' diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml new file mode 100644 index 000000000000..4e32d6cf0e20 --- /dev/null +++ b/.github/workflows/cpp-linter.yml @@ -0,0 +1,52 @@ +name: cpp-linter + +on: + pull_request: + paths: ['**.c', '**.cpp', '**.h', '**.inl', '**CMakeLists.txt', '**.cmake'] + push: + branches: [main] + paths: ['**.c', '**.cpp', '**.h', '**.inl', '**CMakeLists.txt', '**.cmake'] + +jobs: + cpp-linter: + name: Clazy + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: 'recursive' + - name: Install dependencies + run: | + wget -qO- 'https://apt.llvm.org/llvm-snapshot.gpg.key' | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc >/dev/null + sudo add-apt-repository -y 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' + sudo apt-get update + sudo apt-get install clang-18 clang-format-18 clang-tidy-18 cmake libopengl-dev libxkbcommon-dev + - name: Install Qt + env: + QT_EMAIL: ${{ secrets.QT_EMAIL }} + QT_PASSWORD: ${{ secrets.QT_PASSWORD }} + run: | + wget 'https://qt.mirror.constant.com/archive/online_installers/4.8/qt-online-installer-linux-x64-4.8.0.run' + chmod +x qt-online-installer-linux-x64-4.8.0.run + ./qt-online-installer-linux-x64-4.8.0.run --no-force-installations --no-default-installations --no-size-checking --default-answer --accept-licenses --confirm-command --accept-obligations --email "$QT_EMAIL" --password "$QT_PASSWORD" install qt.qt6.680.gcc_64 qt.qt6.680.addons.qtpdf qt.qt6.680.addons.qthttpserver + - name: Configure + run: | + sed -i '/file(DOWNLOAD/,+4 s/^/#/' CMakeLists.txt + cmake -S gpt4all-chat -B gpt4all-chat/build \ + -DCMAKE_C_COMPILER=clang-18 \ + -DCMAKE_CXX_COMPILER=clang++-18 \ + -DLLMODEL_CUDA=OFF \ + -DLLMODEL_KOMPUTE=OFF + - uses: cpp-linter/cpp-linter-action@v2 + id: linter + env: + with: + style: '' # no clang-format + extensions: 'c,cpp,h,inl' + tidy-checks: '' # use .clang-tidy config + database: gpt4all-chat/build + version: 18 + - name: Fail Fast + if: steps.linter.outputs.clang-tidy-checks-failed > 0 + run: exit 1 From b5eaa25f9c70f512d8d07883aebff703bab74b46 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 8 Nov 2024 18:31:04 -0500 Subject: [PATCH 02/19] add self to path filter Signed-off-by: Jared Van Bortel --- .github/workflows/cpp-linter.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 4e32d6cf0e20..ef6628e62db1 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -2,10 +2,10 @@ name: cpp-linter on: pull_request: - paths: ['**.c', '**.cpp', '**.h', '**.inl', '**CMakeLists.txt', '**.cmake'] + paths: ['.github/workflows/cpp-linter.yml', '**.c', '**.cpp', '**.h', '**.inl', '**CMakeLists.txt', '**.cmake'] push: branches: [main] - paths: ['**.c', '**.cpp', '**.h', '**.inl', '**CMakeLists.txt', '**.cmake'] + paths: ['.github/workflows/cpp-linter.yml', '**.c', '**.cpp', '**.h', '**.inl', '**CMakeLists.txt', '**.cmake'] jobs: cpp-linter: From 48587d987bfbf54b9aba368633bfcf226ec1bb90 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 8 Nov 2024 18:42:02 -0500 Subject: [PATCH 03/19] fix syntax Signed-off-by: Jared Van Bortel --- .github/workflows/cpp-linter.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index ef6628e62db1..ded87e38f16a 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -40,13 +40,12 @@ jobs: -DLLMODEL_KOMPUTE=OFF - uses: cpp-linter/cpp-linter-action@v2 id: linter - env: - with: - style: '' # no clang-format - extensions: 'c,cpp,h,inl' - tidy-checks: '' # use .clang-tidy config - database: gpt4all-chat/build - version: 18 + with: + style: '' # no clang-format + extensions: 'c,cpp,h,inl' + tidy-checks: '' # use .clang-tidy config + database: gpt4all-chat/build + version: 18 - name: Fail Fast if: steps.linter.outputs.clang-tidy-checks-failed > 0 run: exit 1 From db0a823dd29baf8f478f5de37c3299ab5000c7f6 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 8 Nov 2024 18:42:59 -0500 Subject: [PATCH 04/19] fix name Signed-off-by: Jared Van Bortel --- .github/workflows/cpp-linter.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index ded87e38f16a..e16acefcf26a 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -9,7 +9,6 @@ on: jobs: cpp-linter: - name: Clazy runs-on: ubuntu-24.04 steps: - name: Checkout From bab871c278b429304b5cc6c73cc8a19a543f90c2 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 8 Nov 2024 18:44:15 -0500 Subject: [PATCH 05/19] add dep Signed-off-by: Jared Van Bortel --- .github/workflows/cpp-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index e16acefcf26a..554e47687a79 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -20,7 +20,7 @@ jobs: wget -qO- 'https://apt.llvm.org/llvm-snapshot.gpg.key' | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc >/dev/null sudo add-apt-repository -y 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' sudo apt-get update - sudo apt-get install clang-18 clang-format-18 clang-tidy-18 cmake libopengl-dev libxkbcommon-dev + sudo apt-get install clang-18 clang-format-18 clang-tidy-18 cmake libopengl-dev libxkbcommon-dev libxkbcommon-x11-0 - name: Install Qt env: QT_EMAIL: ${{ secrets.QT_EMAIL }} From d902c87b2a75cbe6348b53b985ed60f5d6afcab9 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 8 Nov 2024 18:54:13 -0500 Subject: [PATCH 06/19] more deps Signed-off-by: Jared Van Bortel --- .github/workflows/cpp-linter.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 554e47687a79..e8631a952d6d 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -19,8 +19,13 @@ jobs: run: | wget -qO- 'https://apt.llvm.org/llvm-snapshot.gpg.key' | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc >/dev/null sudo add-apt-repository -y 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' + packages=( + clang-18 clang-format-18 clang-tidy-18 cmake libopengl-dev libxkbcommon-dev libx11-6 libx11-xcb1 libxcb-glx0 + libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 + libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcb-xinput0 libxcb-xkb1 libxcb1 libxkbcommon-x11-0 libxkbcommon0 + ) sudo apt-get update - sudo apt-get install clang-18 clang-format-18 clang-tidy-18 cmake libopengl-dev libxkbcommon-dev libxkbcommon-x11-0 + sudo apt-get install -y "${packages[@]}" - name: Install Qt env: QT_EMAIL: ${{ secrets.QT_EMAIL }} From 9db02ac81012bf8a13ec368a8d749f7cbb38eeca Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 8 Nov 2024 18:58:15 -0500 Subject: [PATCH 07/19] fix qt packages Signed-off-by: Jared Van Bortel --- .github/workflows/cpp-linter.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index e8631a952d6d..b030c3526adc 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -33,7 +33,10 @@ jobs: run: | wget 'https://qt.mirror.constant.com/archive/online_installers/4.8/qt-online-installer-linux-x64-4.8.0.run' chmod +x qt-online-installer-linux-x64-4.8.0.run - ./qt-online-installer-linux-x64-4.8.0.run --no-force-installations --no-default-installations --no-size-checking --default-answer --accept-licenses --confirm-command --accept-obligations --email "$QT_EMAIL" --password "$QT_PASSWORD" install qt.qt6.680.gcc_64 qt.qt6.680.addons.qtpdf qt.qt6.680.addons.qthttpserver + ./qt-online-installer-linux-x64-4.8.0.run --no-force-installations --no-default-installations \ + --no-size-checking --default-answer --accept-licenses --confirm-command --accept-obligations \ + --email "$QT_EMAIL" --password "$QT_PASSWORD" install \ + qt.qt6.680.linux_gcc_64 extensions.qtpdf.680.linux_gcc_64 qt.qt6.680.addons.qthttpserver - name: Configure run: | sed -i '/file(DOWNLOAD/,+4 s/^/#/' CMakeLists.txt From 274f5fab258b6e5aa38af8a7f9d2cc748887386b Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 8 Nov 2024 19:03:02 -0500 Subject: [PATCH 08/19] fix sed path Signed-off-by: Jared Van Bortel --- .github/workflows/cpp-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index b030c3526adc..6051401b9a69 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -39,7 +39,7 @@ jobs: qt.qt6.680.linux_gcc_64 extensions.qtpdf.680.linux_gcc_64 qt.qt6.680.addons.qthttpserver - name: Configure run: | - sed -i '/file(DOWNLOAD/,+4 s/^/#/' CMakeLists.txt + sed -i '/file(DOWNLOAD/,+4 s/^/#/' gpt4all-chat/CMakeLists.txt cmake -S gpt4all-chat -B gpt4all-chat/build \ -DCMAKE_C_COMPILER=clang-18 \ -DCMAKE_CXX_COMPILER=clang++-18 \ From 91d6e03754a0330808c3ff04b665a8579d20d7f3 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 8 Nov 2024 19:08:29 -0500 Subject: [PATCH 09/19] add CMAKE_PREFIX_PATH Signed-off-by: Jared Van Bortel --- .github/workflows/cpp-linter.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 6051401b9a69..cd2724447b6c 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -41,6 +41,7 @@ jobs: run: | sed -i '/file(DOWNLOAD/,+4 s/^/#/' gpt4all-chat/CMakeLists.txt cmake -S gpt4all-chat -B gpt4all-chat/build \ + -DCMAKE_PREFIX_PATH=~/Qt/6.8.0/gcc_64/lib/cmake \ -DCMAKE_C_COMPILER=clang-18 \ -DCMAKE_CXX_COMPILER=clang++-18 \ -DLLMODEL_CUDA=OFF \ From ea558107051d47532f4fad2fb0a718a70d931aa5 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 8 Nov 2024 19:20:02 -0500 Subject: [PATCH 10/19] add libgl-dev Signed-off-by: Jared Van Bortel --- .github/workflows/cpp-linter.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index cd2724447b6c..da806a63d4cd 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -20,9 +20,10 @@ jobs: wget -qO- 'https://apt.llvm.org/llvm-snapshot.gpg.key' | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc >/dev/null sudo add-apt-repository -y 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' packages=( - clang-18 clang-format-18 clang-tidy-18 cmake libopengl-dev libxkbcommon-dev libx11-6 libx11-xcb1 libxcb-glx0 - libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 - libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcb-xinput0 libxcb-xkb1 libxcb1 libxkbcommon-x11-0 libxkbcommon0 + clang-18 clang-format-18 clang-tidy-18 cmake libgl-dev libopengl-dev libxkbcommon-dev libx11-6 libx11-xcb1 + libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-render0 + libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcb-xinput0 libxcb-xkb1 libxcb1 libxkbcommon-x11-0 + libxkbcommon0 ) sudo apt-get update sudo apt-get install -y "${packages[@]}" From 910e79f92768d5ddd6b80fda14477af55906e305 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 6 Dec 2024 15:08:34 -0500 Subject: [PATCH 11/19] test with files-changed-only=false Signed-off-by: Jared Van Bortel --- .github/workflows/cpp-linter.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index da806a63d4cd..469375b346fa 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -55,6 +55,7 @@ jobs: tidy-checks: '' # use .clang-tidy config database: gpt4all-chat/build version: 18 + files-changed-only: false # TODO: set this back to true - name: Fail Fast if: steps.linter.outputs.clang-tidy-checks-failed > 0 run: exit 1 From f1025be542338a58b25b875cf1c2efda6867b4b7 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 6 Dec 2024 15:23:01 -0500 Subject: [PATCH 12/19] cpp-linter: ignore third-party dependencies from FetchContent Signed-off-by: Jared Van Bortel --- .github/workflows/cpp-linter.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 469375b346fa..12f4665025a5 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -56,6 +56,7 @@ jobs: database: gpt4all-chat/build version: 18 files-changed-only: false # TODO: set this back to true + ignore: 'gpt4all-chat/build/_deps' - name: Fail Fast if: steps.linter.outputs.clang-tidy-checks-failed > 0 run: exit 1 From e7ee341e282bc2eaa896e72bc2674b6fe4ae5f3a Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 6 Dec 2024 16:14:31 -0500 Subject: [PATCH 13/19] try to fix remaining annotations Signed-off-by: Jared Van Bortel --- .clang-tidy | 3 +++ .github/workflows/cpp-linter.yml | 6 +++--- gpt4all-backend/src/llamamodel_impl.h | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index ada9dca9d2a0..bac2413b91fc 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -49,6 +49,7 @@ Checks: - '-cppcoreguidelines-pro-type-member-init' - '-cppcoreguidelines-pro-type-reinterpret-cast' - '-cppcoreguidelines-pro-type-static-cast-downcast' +- '-cppcoreguidelines-pro-type-union-access' - '-cppcoreguidelines-pro-type-vararg' - '-cppcoreguidelines-rvalue-reference-param-not-moved' - '-cppcoreguidelines-special-member-functions' @@ -71,6 +72,7 @@ Checks: - '-modernize-avoid-bind' - '-modernize-deprecated-headers' - '-modernize-loop-convert' +- '-modernize-pass-by-value' - '-modernize-raw-string-literal' - '-modernize-return-braced-init-list' - '-modernize-use-auto' @@ -103,6 +105,7 @@ Checks: - '-readability-identifier-length' - '-readability-implicit-bool-conversion' - '-readability-inconsistent-declaration-parameter-name' +- '-readability-isolate-declaration' - '-readability-math-missing-parentheses' - '-readability-named-parameter' - '-readability-non-const-parameter' diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 12f4665025a5..52fc4faa838b 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -51,12 +51,12 @@ jobs: id: linter with: style: '' # no clang-format - extensions: 'c,cpp,h,inl' + extensions: 'c,cpp' tidy-checks: '' # use .clang-tidy config database: gpt4all-chat/build version: 18 - files-changed-only: false # TODO: set this back to true - ignore: 'gpt4all-chat/build/_deps' + files-changed-only: false + ignore: 'gpt4all-chat/build/_deps|gpt4all-bindings' - name: Fail Fast if: steps.linter.outputs.clang-tidy-checks-failed > 0 run: exit 1 diff --git a/gpt4all-backend/src/llamamodel_impl.h b/gpt4all-backend/src/llamamodel_impl.h index 7d018ddb1083..1f5bde4e5aa6 100644 --- a/gpt4all-backend/src/llamamodel_impl.h +++ b/gpt4all-backend/src/llamamodel_impl.h @@ -6,12 +6,13 @@ #include "llmodel.h" +#include #include #include #include #include -#include #include +#include struct LLamaPrivate; struct EmbModelSpec; From 80e831da6f074b41f648aea8b1cb01529a9f4ff8 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 6 Dec 2024 17:15:16 -0500 Subject: [PATCH 14/19] further attempts to fix warnings Signed-off-by: Jared Van Bortel --- .clang-tidy | 1 + .github/workflows/cpp-linter.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index bac2413b91fc..82dc4f2f7197 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -91,6 +91,7 @@ Checks: - '-performance-implicit-conversion-in-loop' - '-performance-move-const-arg' - '-performance-noexcept-move-constructor' +- '-performance-no-automatic-move' - '-performance-unnecessary-copy-initialization' - '-performance-unnecessary-value-param' - '-readability-avoid-const-params-in-decls' diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 52fc4faa838b..8d4f3183e259 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -18,7 +18,7 @@ jobs: - name: Install dependencies run: | wget -qO- 'https://apt.llvm.org/llvm-snapshot.gpg.key' | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc >/dev/null - sudo add-apt-repository -y 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' + sudo add-apt-repository -y 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-18 main' packages=( clang-18 clang-format-18 clang-tidy-18 cmake libgl-dev libopengl-dev libxkbcommon-dev libx11-6 libx11-xcb1 libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-render0 From 5c25b49bf0fe94aac5166b2c266e577be1c41da7 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 6 Dec 2024 18:40:34 -0500 Subject: [PATCH 15/19] explicitly install/update git and make Signed-off-by: Jared Van Bortel --- .github/workflows/cpp-linter.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 8d4f3183e259..475747008a24 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -20,10 +20,10 @@ jobs: wget -qO- 'https://apt.llvm.org/llvm-snapshot.gpg.key' | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc >/dev/null sudo add-apt-repository -y 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-18 main' packages=( - clang-18 clang-format-18 clang-tidy-18 cmake libgl-dev libopengl-dev libxkbcommon-dev libx11-6 libx11-xcb1 - libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-render0 - libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcb-xinput0 libxcb-xkb1 libxcb1 libxkbcommon-x11-0 - libxkbcommon0 + clang-18 clang-format-18 clang-tidy-18 cmake git libgl-dev libopengl-dev libx11-6 libx11-xcb1 libxcb-glx0 + libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 + libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcb-xinput0 libxcb-xkb1 libxcb1 libxkbcommon-dev + libxkbcommon-x11-0 libxkbcommon0 make ) sudo apt-get update sudo apt-get install -y "${packages[@]}" From e6a324ebca9c03c6b94e9b031b188c51c9ed7ae5 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 6 Dec 2024 18:51:08 -0500 Subject: [PATCH 16/19] update clang for __cpp_concepts=202002 required by libstdc++13 Signed-off-by: Jared Van Bortel --- .github/workflows/cpp-linter.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 475747008a24..4ca5941b7d14 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -18,15 +18,15 @@ jobs: - name: Install dependencies run: | wget -qO- 'https://apt.llvm.org/llvm-snapshot.gpg.key' | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc >/dev/null - sudo add-apt-repository -y 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-18 main' + sudo add-apt-repository -y 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main' packages=( - clang-18 clang-format-18 clang-tidy-18 cmake git libgl-dev libopengl-dev libx11-6 libx11-xcb1 libxcb-glx0 + clang-19 clang-format-19 clang-tidy-19 cmake git libgl-dev libopengl-dev libx11-6 libx11-xcb1 libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcb-xinput0 libxcb-xkb1 libxcb1 libxkbcommon-dev libxkbcommon-x11-0 libxkbcommon0 make ) sudo apt-get update - sudo apt-get install -y "${packages[@]}" + sudo apt-get install -y "${packages[@]}" --no-install-recommends - name: Install Qt env: QT_EMAIL: ${{ secrets.QT_EMAIL }} @@ -43,8 +43,8 @@ jobs: sed -i '/file(DOWNLOAD/,+4 s/^/#/' gpt4all-chat/CMakeLists.txt cmake -S gpt4all-chat -B gpt4all-chat/build \ -DCMAKE_PREFIX_PATH=~/Qt/6.8.0/gcc_64/lib/cmake \ - -DCMAKE_C_COMPILER=clang-18 \ - -DCMAKE_CXX_COMPILER=clang++-18 \ + -DCMAKE_C_COMPILER=clang-19 \ + -DCMAKE_CXX_COMPILER=clang++-19 \ -DLLMODEL_CUDA=OFF \ -DLLMODEL_KOMPUTE=OFF - uses: cpp-linter/cpp-linter-action@v2 @@ -54,7 +54,7 @@ jobs: extensions: 'c,cpp' tidy-checks: '' # use .clang-tidy config database: gpt4all-chat/build - version: 18 + version: 19 files-changed-only: false ignore: 'gpt4all-chat/build/_deps|gpt4all-bindings' - name: Fail Fast From 1f3e4d09502d3a84dc4598a79d35d2310b281ab7 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 6 Dec 2024 18:58:55 -0500 Subject: [PATCH 17/19] ignore new warnings Signed-off-by: Jared Van Bortel --- .clang-tidy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.clang-tidy b/.clang-tidy index 82dc4f2f7197..8a072e41d002 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -20,6 +20,7 @@ Checks: - '-*readability-braces-around-statements' - '-bugprone-assignment-in-if-condition' - '-bugprone-branch-clone' +- '-bugprone-crtp-constructor-accessibility' - '-bugprone-easily-swappable-parameters' - '-bugprone-implicit-widening-of-multiplication-result' - '-bugprone-inc-dec-in-conditions' @@ -29,6 +30,7 @@ Checks: - '-cert-err33-c' - '-cert-err58-cpp' - '-clang-analyzer-core.CallAndMessage' +- '-clang-analyzer-cplusplus.Move' - '-clang-analyzer-deadcode.DeadStores' - '-clang-analyzer-optin.performance.Padding' - '-clang-diagnostic-missing-include-dirs' From 4fe97d61a9b5c6efd044b0a1fe3b81d1a3f8aba7 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 6 Dec 2024 19:29:06 -0500 Subject: [PATCH 18/19] ignore the last two warnings Signed-off-by: Jared Van Bortel --- .clang-tidy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.clang-tidy b/.clang-tidy index 8a072e41d002..d2467898d7a9 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -25,6 +25,7 @@ Checks: - '-bugprone-implicit-widening-of-multiplication-result' - '-bugprone-inc-dec-in-conditions' - '-bugprone-suspicious-string-compare' +- '-bugprone-suspicious-stringview-data-usage' - '-bugprone-switch-missing-default-case' - '-cert-dcl03-c' - '-cert-err33-c' @@ -34,6 +35,7 @@ Checks: - '-clang-analyzer-deadcode.DeadStores' - '-clang-analyzer-optin.performance.Padding' - '-clang-diagnostic-missing-include-dirs' +- '-clang-diagnostic-unreachable-code-break' - '-cppcoreguidelines-avoid-do-while' - '-cppcoreguidelines-avoid-goto' - '-cppcoreguidelines-avoid-non-const-global-variables' From da32383ccb2e06116e6f710a5a9d56d8ba922b59 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Fri, 6 Dec 2024 19:29:33 -0500 Subject: [PATCH 19/19] revert #include fix for now Signed-off-by: Jared Van Bortel --- gpt4all-backend/src/llamamodel_impl.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gpt4all-backend/src/llamamodel_impl.h b/gpt4all-backend/src/llamamodel_impl.h index 1f5bde4e5aa6..7d018ddb1083 100644 --- a/gpt4all-backend/src/llamamodel_impl.h +++ b/gpt4all-backend/src/llamamodel_impl.h @@ -6,13 +6,12 @@ #include "llmodel.h" -#include #include #include #include #include -#include #include +#include struct LLamaPrivate; struct EmbModelSpec;