From b3949463dfd46f6f1464193ff61dae29a9a5b415 Mon Sep 17 00:00:00 2001 From: Ivan-lis Date: Fri, 18 Oct 2024 07:36:50 +0000 Subject: [PATCH 1/9] CI: Added repo downloading --- .forgejo/workflows/pr_check.yaml | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .forgejo/workflows/pr_check.yaml diff --git a/.forgejo/workflows/pr_check.yaml b/.forgejo/workflows/pr_check.yaml new file mode 100644 index 0000000..3489167 --- /dev/null +++ b/.forgejo/workflows/pr_check.yaml @@ -0,0 +1,48 @@ +name: PR Check +run-name: ${{ github.actor }} is testing +on: [push] +jobs: + on-push-commit-check: + runs-on: archlinux-latest + steps: + - name: Setup environment + shell: sh + run: | + pacman -Syyu --noconfirm + pacman -S --noconfirm git less vim sudo python-pip wget which pkgconf nodejs-lts-iron + pacman -S --noconfirm cmake make gcc ninja meson + pacman -S --noconfirm gtk4 gtkmm-4.0 boost spdlog fmt libxml++-5.0 + + - name: List CI environment variables + run: | + echo "Runner OS: ${{ runner.os }}" + echo "Job triggered event: ${{ github.event_name }}" + echo "Repository name: ${{ github.repository }}" + echo "Workspace path: ${{ github.workspace }}" + echo "Actor: ${{ github.actor }}" + echo "Ref: ${{ github.ref }}" + echo "Ref name: ${{ github.ref_name }}" + echo "SHA: ${{ github.sha }}" + + - name: Check out repository code + run: | + export GIT_TERMINAL_PROMPT=0 + mkdir -p ${{ github.workspace }} + cd ${{ github.workspace }} + + echo "Configure project settings and remote credentials" + git init + git config credential.helper store + git remote add origin https://${{ github.token }}@helicopter.myftp.org/git/Larra/larra + + echo "Fetch repo state on pushed commit" + git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +${{ github.sha }}:${{ github.ref }} + + echo "Checkout to fetched repo state" + git checkout ${{ github.ref }} + + - name: Show repo content + run: | + echo "github.workspace content" + ls -la ${{ github.workspace }} + echo "This job's status is ${{ job.status }}." From 65cae2727f26a0b2e70c3a1829ed7dcd3b3dce4b Mon Sep 17 00:00:00 2001 From: Ivan-lis Date: Fri, 18 Oct 2024 07:38:07 +0000 Subject: [PATCH 2/9] CI: Added LLVM bins and clang&gcc build --- .forgejo/workflows/pr_check.yaml | 83 ++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/.forgejo/workflows/pr_check.yaml b/.forgejo/workflows/pr_check.yaml index 3489167..2df7053 100644 --- a/.forgejo/workflows/pr_check.yaml +++ b/.forgejo/workflows/pr_check.yaml @@ -46,3 +46,86 @@ jobs: echo "github.workspace content" ls -la ${{ github.workspace }} echo "This job's status is ${{ job.status }}." + + #- name: Delete cache + # run: | + # rm -rf ${{ runner.tool_cache }}/cache-llvm-19-restore + + - name: Try restore LLVM-19 binaries from cache + id: cache-llvm-19-bins-restore + uses: actions/cache@v4 + with: + path: /LLVM-19.1.0-Linux-X64-small.tar.xz + key: LLVM-19.1.0-Linux-X64-small + + - name: Download and unzip LLVM-19 if not in cache + if: steps.cache-llvm-19-bins-restore.outputs.cache-hit != 'true' + run: | + echo "::group::Download LLVM-19.1.0" + wget https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0/LLVM-19.1.0-Linux-X64.tar.xz -O /LLVM-19.1.0-Linux-X64.tar.xz + echo "::endgroup::" + + echo "::group::Extracting LLVM-19.1.0" + mkdir -p /home/LLVM-19.1.0/ + tar -xf /LLVM-19.1.0-Linux-X64.tar.xz -C "/home/LLVM-19.1.0/" --strip-components=1 LLVM-19.1.0-Linux-X64/bin/clang-19 LLVM-19.1.0-Linux-X64/bin/clang LLVM-19.1.0-Linux-X64/bin/clang++ LLVM-19.1.0-Linux-X64/bin/clang-scan-deps LLVM-19.1.0-Linux-X64/bin/clang-format LLVM-19.1.0-Linux-X64/bin/clang-tidy LLVM-19.1.0-Linux-X64/include/ LLVM-19.1.0-Linux-X64/lib/ LLVM-19.1.0-Linux-X64/libexec/ LLVM-19.1.0-Linux-X64/local/ LLVM-19.1.0-Linux-X64/share/ + rm /LLVM-19.1.0-Linux-X64.tar.xz + echo "::endgroup::" + + tar -cf /LLVM-19.1.0-Linux-X64-small.tar.xz /home/LLVM-19.1.0/ + + - name: Save LLVM-19 to cache + if: steps.cache-llvm-19-bins-restore.outputs.cache-hit != 'true' + id: cache-llvm-19-save + uses: actions/cache/save@v4 + with: + path: /LLVM-19.1.0-Linux-X64-small.tar.xz + key: LLVM-19.1.0-Linux-X64-small + + - name: Install LLVM + run: | + mkdir -p /home/LLVM-19.1.0 + tar -xf /LLVM-19.1.0-Linux-X64-small.tar.xz -C "/home/LLVM-19.1.0/" --strip-components=2 + ls -la /home/LLVM-19.1.0/bin/ + export PATH="/home/LLVM-19.1.0/bin:${PATH}" + + - name: Clang build with -fsanitize=address + environment: + CC: /home/LLVM-19.1.0/bin/clang + CXX: /home/LLVM-19.1.0/bin/clang++ + run: | + mkdir -p ${{ github.workspace }}/build_clang + cmake -Wno-dev \ + -DCMAKE_C_COMPILER=/home/LLVM-19.1.0/bin/clang \ + -DCMAKE_CXX_COMPILER=/home/LLVM-19.1.0/bin/clang++ \ + -S ${{ github.workspace }} \ + -B ${{ github.workspace }}/build_clang \ + -GNinja -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_EXAMPLES=ON \ + -DENABLE_TESTS=ON \ + -DCMAKE_CXX_FLAGS="-stdlib=libstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr" \ + -DCMAKE_EXE_LINKER_FLAGS="-L/usr/lib/x86_64-linux-gnu -lstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr" + cmake --build ${{ github.workspace }}/build_clang --parallel `nproc` + + - name: Clang unit tests with -fsanitize=address + run: | + cd ${{ github.workspace }}/build_clang + ASAN_SYMBOLIZER_PATH=/home/LLVM-19.1.0/bin/llvm-symbolizer ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=1:atexit=1:abort_on_error=1 ./larra_xmpp_tests + + - name: GCC build + environment: + CC: /usr/sbin/gcc + CXX: /usr/sbin/g++ + run: | + mkdir -p ${{ github.workspace }}/build_gcc + cmake -Wno-dev \ + -S ${{ github.workspace }} \ + -B ${{ github.workspace }}/build_gcc \ + -GNinja -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_EXAMPLES=ON \ + -DENABLE_TESTS=ON + cmake --build ${{ github.workspace }}/build_gcc --parallel `nproc` + + - name: GCC unit tests + run: | + cd ${{ github.workspace }}/build_gcc + ./larra_xmpp_tests From 89f31655511005b667d680ad6140c56ea209e70f Mon Sep 17 00:00:00 2001 From: Ivan-lis Date: Fri, 18 Oct 2024 07:38:35 +0000 Subject: [PATCH 3/9] CI: Added clang-format and clang-tidy --- .forgejo/workflows/pr_check.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.forgejo/workflows/pr_check.yaml b/.forgejo/workflows/pr_check.yaml index 2df7053..7d02cb0 100644 --- a/.forgejo/workflows/pr_check.yaml +++ b/.forgejo/workflows/pr_check.yaml @@ -88,6 +88,21 @@ jobs: ls -la /home/LLVM-19.1.0/bin/ export PATH="/home/LLVM-19.1.0/bin:${PATH}" + - name: Check clang-format + run: | + export PATH="/home/LLVM-19.1.0/bin:${PATH}" + cd ${{ github.workspace }} + find -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.c" -o -name "*.cpp" \) > repo_sources_to_check.txt + export REPO_FILES=$(cat repo_sources_to_check.txt) + + printf "\nList of files to be checked:\n" + echo "::group::files to be checked" + for FILE in $REPO_FILES; do printf "\t ${{ github.workspace }}/$FILE \n"; done + echo "::endgroup::" + + for FILE in $REPO_FILES; do clang-format -i ${{ github.workspace }}/$FILE --dry-run --Werror; done + echo "No clang-format violations detected!" + - name: Clang build with -fsanitize=address environment: CC: /home/LLVM-19.1.0/bin/clang @@ -111,6 +126,13 @@ jobs: cd ${{ github.workspace }}/build_clang ASAN_SYMBOLIZER_PATH=/home/LLVM-19.1.0/bin/llvm-symbolizer ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=1:atexit=1:abort_on_error=1 ./larra_xmpp_tests + - name: Check clang-tidy + run: | + export PATH="/home/LLVM-19.1.0/bin:${PATH}" + wget https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py + python run-clang-tidy.py -use-color -exclude-header-filter .*build.* -header-filter .hpp -p ${{ github.workspace }}/build_clang/ -config-file ${{ github.workspace }}/.clang-tidy ${{ github.workspace }}/examples ${{ github.workspace }}/library/ ${{ github.workspace }}/src/ + echo "::warning::TODO Fix warnings and add '-warnings-as-errors' flags to report clang-tidy errors" + - name: GCC build environment: CC: /usr/sbin/gcc From d9d301167c43d4bd32ebfdf1dafa61958d26efe5 Mon Sep 17 00:00:00 2001 From: Ivan-lis Date: Fri, 18 Oct 2024 07:39:14 +0000 Subject: [PATCH 4/9] Fixed clang-format violations --- library/include/larra/impl/public_cast.hpp | 34 ++++++++++++++++++++++ library/include/larra/utils.hpp | 6 ++-- 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 library/include/larra/impl/public_cast.hpp diff --git a/library/include/larra/impl/public_cast.hpp b/library/include/larra/impl/public_cast.hpp new file mode 100644 index 0000000..111909a --- /dev/null +++ b/library/include/larra/impl/public_cast.hpp @@ -0,0 +1,34 @@ +#pragma once +#include +#include + +namespace larra::xmpp::impl { + +template +struct PublicCastTag { + friend constexpr auto MagicGetPrivateMember(PublicCastTag); +}; + +template +struct PublicCast {}; + +template +struct PublicCast { + friend constexpr auto MagicGetPrivateMember(PublicCastTag) { + return ptr; + } +}; + +template +struct PublicCast { + friend constexpr auto MagicGetPrivateMember(PublicCastTag) { + return ptr; + } +}; + +template +constexpr auto GetPrivateMember(const T&) { + return MagicGetPrivateMember(PublicCastTag, I>{}); +}; + +} // namespace larra::xmpp::impl diff --git a/library/include/larra/utils.hpp b/library/include/larra/utils.hpp index bca4277..1141b7b 100644 --- a/library/include/larra/utils.hpp +++ b/library/include/larra/utils.hpp @@ -83,9 +83,9 @@ struct FieldsDescription { * \param value new value for field * \return an object of type std::decay_t with data from T with fields from \ref self and the \ref value of the field \ref ptr */ - template // NOLINTNEXTLINE - constexpr auto With(Type(T::* ptr), Self&& self, Value&& value) const -> std::decay_t - requires(std::is_constructible_v...> && std::constructible_from, T> && + template + constexpr auto With(Type(T::* ptr), Self&& self, Value&& value) const + requires(std::is_constructible_v...> && std::is_constructible_v, T> && std::is_constructible_v && impl::SetConcept) { return std::decay_t{utempl::Unpack(this->tuple, [&](auto... fs) -> T { From 5942f366f94e5d884eeaa98c9ad50cda8ce3e5ed Mon Sep 17 00:00:00 2001 From: Ivan-lis Date: Fri, 18 Oct 2024 07:40:17 +0000 Subject: [PATCH 5/9] Added latest LLVM with to dev container --- .devcontainer/Dockerfile | 23 +++++++++++++++++++---- .devcontainer/post_create_config.sh | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 50b253e..858746c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,14 +3,29 @@ # Url: https://hub.docker.com/layers/library/archlinux/latest/images/sha256-a10e51dd0694d6c4142754e9d06cbce7baf91ace8031a30df37064d1091ab414?context=explore FROM archlinux@sha256:a10e51dd0694d6c4142754e9d06cbce7baf91ace8031a30df37064d1091ab414 -# Update the package database and install clang +# Update the package database # 1. system tools # 2. build/test tools # 3. libraries RUN pacman -Syyu --noconfirm \ - && pacman -Syyu --noconfirm git less vim sudo base-devel python-pip \ - && pacman -Syyu --noconfirm clang cmake make ninja meson shellcheck \ - && pacman -Syyu --noconfirm gtk4 gtkmm-4.0 boost spdlog fmt libxml++-5.0 + && pacman -S --noconfirm git less vim sudo python-pip wget which pkgconf \ + && pacman -S --noconfirm cmake make gcc ninja meson shellcheck \ + && pacman -S --noconfirm gtk4 gtkmm-4.0 boost spdlog fmt libxml++-5.0 + +# Add cached layer with the latest LLVM-19.1.0 +RUN mkdir -p /home/artifacts +ADD https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0/LLVM-19.1.0-Linux-X64.tar.xz /home/artifacts/ + +# Create the LLVM directory and extract only binaries into it +RUN mkdir -p /home/LLVM-19.1.0 +RUN tar -xJf /home/artifacts/LLVM-19.1.0-Linux-X64.tar.xz -C /home/LLVM-19.1.0 --strip-components=1 LLVM-19.1.0-Linux-X64/bin/clang-19 LLVM-19.1.0-Linux-X64/bin/clang LLVM-19.1.0-Linux-X64/bin/clang++ LLVM-19.1.0-Linux-X64/bin/clang-scan-deps LLVM-19.1.0-Linux-X64/bin/clang-format LLVM-19.1.0-Linux-X64/bin/clang-tidy LLVM-19.1.0-Linux-X64/include/ LLVM-19.1.0-Linux-X64/lib/ LLVM-19.1.0-Linux-X64/libexec/ LLVM-19.1.0-Linux-X64/local/ LLVM-19.1.0-Linux-X64/share/ + +# Add /home/LLVM-19.1.0/bin to the PATH environment variable +ENV PATH="/home/LLVM-19.1.0/bin:${PATH}" + +# Add extra tools +RUN mkdir -p /home/tools +ADD https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py /home/tools/ # Create a non-root user 'dev' RUN useradd -ms /bin/bash dev \ diff --git a/.devcontainer/post_create_config.sh b/.devcontainer/post_create_config.sh index 65b424d..c0607f0 100755 --- a/.devcontainer/post_create_config.sh +++ b/.devcontainer/post_create_config.sh @@ -1,4 +1,4 @@ -sleep 1 +sleep 5 # Check that ejabberd server started successfully red='\e[1;31m' From 8aecc897d7bbdf6c6f92725f346a81af592c70af Mon Sep 17 00:00:00 2001 From: Ivan-lis Date: Fri, 18 Oct 2024 07:44:15 +0000 Subject: [PATCH 6/9] Added Cland/GCC builds and Analyzers tasks for vscode --- .vscode/launch.json | 2 +- .vscode/tasks.json | 273 +++++++++++++++++++++++++++++++++++++++----- CMakeLists.txt | 2 +- 3 files changed, 244 insertions(+), 33 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 1ee66a5..2a94c2f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,7 +11,7 @@ "program": "${workspaceFolder}/build/examples/output/connect", "args": [], "cwd": "${workspaceFolder}", - "preLaunchTask": "Build Debug GCC" + "preLaunchTask": "GCC: Build" } ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 55a74f4..970b6dd 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -3,6 +3,33 @@ // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ + // + // Checkers/Analyzers tasks + // + { + "label": "Checker: clang-format dry-run", + "type": "shell", + "command": "for FILE in $(find . -type f \\( -name '*.c' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \\) ! -path '*build*'); do clang-format -i $FILE --dry-run --Werror; done" + }, + { + "label": "Checker: clang-format fix errors", + "type": "shell", + "command": "for FILE in $(find . -type f \\( -name '*.c' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \\) ! -path '*build*'); do clang-format -i $FILE --Werror; done" + }, + { + // https://clang.llvm.org/extra/clang-tidy/ + "label": "Checker: clang-tidy dry-run", + "type": "shell", + "command": [ + "python /home/tools/run-clang-tidy.py -exclude-header-filter .*build.* -use-color -header-filter .hpp -p ${workspaceFolder}/build_clang/ -config-file ${workspaceFolder}/.clang-tidy ", + " ${workspaceFolder}/examples ", + " ${workspaceFolder}/library/ ", + " ${workspaceFolder}/src/" + ] + }, + // + // Ejabberd tasks + // { "label": "Ejabberd: show logs", "type": "shell", @@ -11,54 +38,238 @@ ] }, { - "label": "Ejabberd: open shell", + "label": "Ejabberd: show localhost registered users", "type": "shell", "command": [ - "sudo docker exec -it ejabberd sh" + "sudo docker exec -it ejabberd ejabberdctl registered_users localhost" ] }, { - "label": "Build Debug GCC", + "label": "Ejabberd: open shell", + "type": "shell", + "command": [ + "printf 'Example cmd: ejabberdctl registered_users localhost\n\n';", + "sudo docker exec -it ejabberd sh" + ] + }, + // + // GCC build related tasks + // + { + "label": "GCC: Clean build folder", + "type": "shell", + "command": "if [ -n \"$(ls -A ${workspaceFolder}/build)\" ]; then rm -rf ${workspaceFolder}/build/*; fi", + "hide": true + }, + { + "label": "GCC: Configure Debug", "type": "shell", "command": [ "cd ${workspaceFolder} &&", "mkdir -p build && cd build &&", - "cmake -Wno-dev -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON .. &&", - "cmake --build . --parallel `nproc`", - "|| ( printf '\n\n\t\\e[31mERROR: Build failed!\\e[0m\n\n\n' && exit 1 )" - ], - "options": { - "env": {} - }, - "presentation": { - "clear": true - }, - "problemMatcher": [], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "Build Debug Clang", - "type": "shell", - "command": [ - "cd ${workspaceFolder} &&", - "mkdir -p build_clang && cd build_clang &&", - "cmake -Wno-dev -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON .. &&", - "cmake --build . --parallel `nproc`", - "|| ( printf '\n\n\t\\e[31mERROR: Build failed!\\e[0m\n\n\n' && exit 1 )" + "cmake -Wno-dev ", + " -DCMAKE_CXX_FLAGS=\"-Wno-non-template-friend\"", + " -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON .." ], "options": { "env": { - "CC": "/usr/sbin/clang", - "CXX": "/usr/sbin/clang++" + "CC": "/usr/sbin/gcc", + "CXX": "/usr/sbin/g++" } }, "presentation": { "clear": true }, - "problemMatcher": [] + "hide": true + }, + { + "label": "GCC: Build", + "type": "shell", + "command": [ + "cd ${workspaceFolder}/build &&", + "cmake --build . --parallel `nproc`", + "|| ( printf '\n\n\t\\e[31mERROR: Build failed!\\e[0m\n\n\n' && exit 1 )" + ], + "presentation": { + "clear": true + }, + "hide": true, + "group": { + "kind": "build" + } + }, + { + "label": "GCC: Configure and build Debug", + "type": "shell", + "command": "echo Finished!", + "presentation": { + "clear": true + }, + "dependsOrder": "sequence", + "dependsOn":[ + "GCC: Clean build folder", + "GCC: Configure Debug", + "GCC: Build" + ], + "group": { + "kind": "build", + "isDefault": true + } + }, + // + // Clang build related tasks + // + { + "label": "Clang: Configure Debug", + "type": "shell", + "command": [ + "cd ${workspaceFolder} &&", + "mkdir -p build_clang && cd build_clang &&", + "cmake -Wno-dev ", + " -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON ", + " -DCMAKE_CXX_FLAGS=\"-stdlib=libstdc++\"", + " -DCMAKE_EXE_LINKER_FLAGS=\"-L/usr/lib/x86_64-linux-gnu -lstdc++\" .." + ], + "options": { + "env": { + "CC": "/home/LLVM-19.1.0/bin/clang", + "CXX": "/home/LLVM-19.1.0/bin/clang++" + } + }, + "presentation": { + "clear": true + }, + "hide": true + }, + { + "label": "Clang: Configure Debug with -fsanitize=address", + "type": "shell", + "command": [ + "cd ${workspaceFolder} &&", + "mkdir -p build_clang && cd build_clang &&", + "cmake -Wno-dev ", + " -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON ", + " -DCMAKE_CXX_FLAGS=\"-stdlib=libstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr\"", + " -DCMAKE_EXE_LINKER_FLAGS=\"-L/usr/lib/x86_64-linux-gnu -lstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr\" ..", + ], + "options": { + "env": { + "CC": "/home/LLVM-19.1.0/bin/clang", + "CXX": "/home/LLVM-19.1.0/bin/clang++" + } + }, + "presentation": { + "clear": true + }, + "hide": true + }, + { + // + // Useful links: + // - https://github.com/google/sanitizers/wiki/addresssanitizerflags + // - https://clang.llvm.org/docs/AddressSanitizer.html + // + "label": "Clang: Exec gtest with -fsanitize=address", + "type": "shell", + "command": [ + "cd ${workspaceFolder} &&", + "mkdir -p build_clang && cd build_clang &&", + "ASAN_SYMBOLIZER_PATH=/home/LLVM-19.1.0/bin/llvm-symbolizer ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=1:atexit=1:abort_on_error=1 ./larra_xmpp_tests ; echo \"exit code: $?\"", + ], + "presentation": { + "clear": true + }, + "dependsOrder": "sequence", + "dependsOn":[ + "Clang: Clean build folder", + "Clang: Configure Debug with -fsanitize=address", + "Clang: Build" + ] + }, + { + "label": "Clang: Configure Debug with -fsanitize=memory", + "type": "shell", + "command": [ + "cd ${workspaceFolder} &&", + "mkdir -p build_clang && cd build_clang &&", + "cmake -Wno-dev ", + " -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON ", + " -DCMAKE_CXX_FLAGS=\"-stdlib=libstdc++ -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -fsanitize=memory\"", + " -DCMAKE_EXE_LINKER_FLAGS=\"-L/usr/lib/x86_64-linux-gnu -lstdc++ -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -fsanitize=memory\" ..", + ], + "options": { + "env": { + "CC": "/home/LLVM-19.1.0/bin/clang", + "CXX": "/home/LLVM-19.1.0/bin/clang++" + } + }, + "presentation": { + "clear": true + }, + "hide": true + }, + { + // + // Useful links: + // - https://github.com/google/sanitizers/wiki/MemorySanitizer + // - https://clang.llvm.org/docs/MemorySanitizer.html + // + "label": "Clang: Exec gtest with -fsanitize=memory", + "type": "shell", + "command": [ + "cd ${workspaceFolder} &&", + "mkdir -p build_clang && cd build_clang &&", + "MSAN_SYMBOLIZER_PATH=/home/LLVM-19.1.0/bin/llvm-symbolizer MSAN_OPTIONS=abort_on_error=1 ./larra_xmpp_tests ; echo \"exit code: $?\"", + ], + "presentation": { + "clear": true + }, + "dependsOrder": "sequence", + "dependsOn":[ + "Clang: Clean build folder", + "Clang: Configure Debug with -fsanitize=memory", + "Clang: Build" + ] + }, + { + "label": "Clang: Build", + "type": "shell", + "command": [ + "cd ${workspaceFolder}/build_clang &&", + "cmake --build . --parallel `nproc`", + "|| ( printf '\n\n\t\\e[31mERROR: Build failed!\\e[0m\n\n\n' && exit 1 )" + ], + "presentation": { + "clear": true + }, + "group": { + "kind": "build" + }, + "hide": true + }, + { + "label": "Clang: Configure and build Debug", + "type": "shell", + "command": [ + "cd ${workspaceFolder} &&", + "mkdir -p build_clang && cd build_clang &&", + "MSAN_SYMBOLIZER_PATH=/home/LLVM-19.1.0/bin/llvm-symbolizer MSAN_OPTIONS=abort_on_error=1 ./larra_xmpp_tests ; echo \"exit code: $?\"", + ], + "presentation": { + "clear": true + }, + "dependsOrder": "sequence", + "dependsOn":[ + "Clang: Clean build folder", + "Clang: Configure Debug", + "Clang: Build" + ] + }, + { + "label": "Clang: Clean build folder", + "type": "shell", + "command": "if [ -n \"$(ls -A ${workspaceFolder}/build_clang)\" ]; then rm -rf ${workspaceFolder}/build_clang/*; fi", + "hide": true } ] } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c4cf7e..9ed1307 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,7 +164,7 @@ add_library(larra::larra_xmpp ALIAS larra_xmpp) target_compile_features(larra_xmpp PUBLIC cxx_std_23) -target_compile_options(larra_xmpp PUBLIC -Wno-changes-meaning) +target_compile_options(larra_xmpp PUBLIC "$<$:-Wno-changes-meaning>") target_include_directories(larra_xmpp PUBLIC $ From 72f96c2a865b08764599f6292fb51142ed071625 Mon Sep 17 00:00:00 2001 From: Ivan-lis Date: Fri, 18 Oct 2024 11:17:26 +0000 Subject: [PATCH 7/9] CI: Updated LLVM ver and removed using cache --- .forgejo/workflows/pr_check.yaml | 90 ++++++++++++++++---------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/.forgejo/workflows/pr_check.yaml b/.forgejo/workflows/pr_check.yaml index 7d02cb0..91fb7ca 100644 --- a/.forgejo/workflows/pr_check.yaml +++ b/.forgejo/workflows/pr_check.yaml @@ -5,7 +5,7 @@ jobs: on-push-commit-check: runs-on: archlinux-latest steps: - - name: Setup environment + - name: Setup environment - Install pacman packages shell: sh run: | pacman -Syyu --noconfirm @@ -13,6 +13,28 @@ jobs: pacman -S --noconfirm cmake make gcc ninja meson pacman -S --noconfirm gtk4 gtkmm-4.0 boost spdlog fmt libxml++-5.0 + - name: Setup environment - Install LLVM-19.1.1 + run: | + echo "" >> ~/.bashrc + echo "export LLVM_VER='LLVM-19.1.1'" >> ~/.bashrc + source ~/.bashrc + + echo "::group::Download $LLVM_VER" + wget https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.1/LLVM-19.1.1-Linux-X64.tar.xz -O /$LLVM_VER-Linux-X64.tar.xz + echo "::endgroup::" + + echo "::group::Extracting $LLVM_VER" + mkdir -p /home/$LLVM_VER/ + tar -xf /$LLVM_VER-Linux-X64.tar.xz -C "/home/$LLVM_VER/" --strip-components=1 $LLVM_VER-Linux-X64/bin/clang-19 $LLVM_VER-Linux-X64/bin/clang $LLVM_VER-Linux-X64/bin/clang++ $LLVM_VER-Linux-X64/bin/clang-scan-deps $LLVM_VER-Linux-X64/bin/clang-format $LLVM_VER-Linux-X64/bin/clang-tidy $LLVM_VER-Linux-X64/include/ $LLVM_VER-Linux-X64/lib/ $LLVM_VER-Linux-X64/libexec/ $LLVM_VER-Linux-X64/local/ $LLVM_VER-Linux-X64/share/ + rm /$LLVM_VER-Linux-X64.tar.xz + echo "::endgroup::" + + echo "" >> ~/.bashrc + echo "export PATH='/home/$LLVM_VER/bin:${PATH}'" >> ~/.bashrc + + echo "Available LLVM binaries:" + ls -la /home/$LLVM_VER/bin/ + - name: List CI environment variables run: | echo "Runner OS: ${{ runner.os }}" @@ -50,47 +72,25 @@ jobs: #- name: Delete cache # run: | # rm -rf ${{ runner.tool_cache }}/cache-llvm-19-restore - - - name: Try restore LLVM-19 binaries from cache - id: cache-llvm-19-bins-restore - uses: actions/cache@v4 - with: - path: /LLVM-19.1.0-Linux-X64-small.tar.xz - key: LLVM-19.1.0-Linux-X64-small - - - name: Download and unzip LLVM-19 if not in cache - if: steps.cache-llvm-19-bins-restore.outputs.cache-hit != 'true' - run: | - echo "::group::Download LLVM-19.1.0" - wget https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0/LLVM-19.1.0-Linux-X64.tar.xz -O /LLVM-19.1.0-Linux-X64.tar.xz - echo "::endgroup::" - - echo "::group::Extracting LLVM-19.1.0" - mkdir -p /home/LLVM-19.1.0/ - tar -xf /LLVM-19.1.0-Linux-X64.tar.xz -C "/home/LLVM-19.1.0/" --strip-components=1 LLVM-19.1.0-Linux-X64/bin/clang-19 LLVM-19.1.0-Linux-X64/bin/clang LLVM-19.1.0-Linux-X64/bin/clang++ LLVM-19.1.0-Linux-X64/bin/clang-scan-deps LLVM-19.1.0-Linux-X64/bin/clang-format LLVM-19.1.0-Linux-X64/bin/clang-tidy LLVM-19.1.0-Linux-X64/include/ LLVM-19.1.0-Linux-X64/lib/ LLVM-19.1.0-Linux-X64/libexec/ LLVM-19.1.0-Linux-X64/local/ LLVM-19.1.0-Linux-X64/share/ - rm /LLVM-19.1.0-Linux-X64.tar.xz - echo "::endgroup::" - - tar -cf /LLVM-19.1.0-Linux-X64-small.tar.xz /home/LLVM-19.1.0/ - - - name: Save LLVM-19 to cache - if: steps.cache-llvm-19-bins-restore.outputs.cache-hit != 'true' - id: cache-llvm-19-save - uses: actions/cache/save@v4 - with: - path: /LLVM-19.1.0-Linux-X64-small.tar.xz - key: LLVM-19.1.0-Linux-X64-small - - - name: Install LLVM - run: | - mkdir -p /home/LLVM-19.1.0 - tar -xf /LLVM-19.1.0-Linux-X64-small.tar.xz -C "/home/LLVM-19.1.0/" --strip-components=2 - ls -la /home/LLVM-19.1.0/bin/ - export PATH="/home/LLVM-19.1.0/bin:${PATH}" + # + #- name: Try restore LLVM-19 binaries from cache + # id: cache-llvm-19-bins-restore + # uses: actions/cache@v4 + # with: + # path: /$LLVM_VER-Linux-X64-small.tar.xz + # key: $LLVM_VER-Linux-X64-small + # + #- name: Save LLVM-19 to cache + # if: steps.cache-llvm-19-bins-restore.outputs.cache-hit != 'true' + # id: cache-llvm-19-save + # uses: actions/cache/save@v4 + # with: + # path: /$LLVM_VER-Linux-X64-small.tar.xz + # key: $LLVM_VER-Linux-X64-small - name: Check clang-format run: | - export PATH="/home/LLVM-19.1.0/bin:${PATH}" + export PATH="/home/$LLVM_VER/bin:${PATH}" cd ${{ github.workspace }} find -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.c" -o -name "*.cpp" \) > repo_sources_to_check.txt export REPO_FILES=$(cat repo_sources_to_check.txt) @@ -105,13 +105,13 @@ jobs: - name: Clang build with -fsanitize=address environment: - CC: /home/LLVM-19.1.0/bin/clang - CXX: /home/LLVM-19.1.0/bin/clang++ + CC: /home/$LLVM_VER/bin/clang + CXX: /home/$LLVM_VER/bin/clang++ run: | mkdir -p ${{ github.workspace }}/build_clang cmake -Wno-dev \ - -DCMAKE_C_COMPILER=/home/LLVM-19.1.0/bin/clang \ - -DCMAKE_CXX_COMPILER=/home/LLVM-19.1.0/bin/clang++ \ + -DCMAKE_C_COMPILER=/home/$LLVM_VER/bin/clang \ + -DCMAKE_CXX_COMPILER=/home/$LLVM_VER/bin/clang++ \ -S ${{ github.workspace }} \ -B ${{ github.workspace }}/build_clang \ -GNinja -DCMAKE_BUILD_TYPE=Release \ @@ -124,11 +124,11 @@ jobs: - name: Clang unit tests with -fsanitize=address run: | cd ${{ github.workspace }}/build_clang - ASAN_SYMBOLIZER_PATH=/home/LLVM-19.1.0/bin/llvm-symbolizer ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=1:atexit=1:abort_on_error=1 ./larra_xmpp_tests + ASAN_SYMBOLIZER_PATH=/home/$LLVM_VER/bin/llvm-symbolizer ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=1:atexit=1:abort_on_error=1 ./larra_xmpp_tests - name: Check clang-tidy run: | - export PATH="/home/LLVM-19.1.0/bin:${PATH}" + export PATH="/home/$LLVM_VER/bin:${PATH}" wget https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py python run-clang-tidy.py -use-color -exclude-header-filter .*build.* -header-filter .hpp -p ${{ github.workspace }}/build_clang/ -config-file ${{ github.workspace }}/.clang-tidy ${{ github.workspace }}/examples ${{ github.workspace }}/library/ ${{ github.workspace }}/src/ echo "::warning::TODO Fix warnings and add '-warnings-as-errors' flags to report clang-tidy errors" From 7315fda512761bacf5f3059a305351fe8a81c3b2 Mon Sep 17 00:00:00 2001 From: Ivan-lis Date: Mon, 21 Oct 2024 09:08:40 +0000 Subject: [PATCH 8/9] Fixed analyzer issues and disabled clang in CI --- .devcontainer/Dockerfile | 54 ++++++---- .forgejo/workflows/pr_check.yaml | 125 ++++++++++++++--------- .vscode/tasks.json | 34 +++--- CMakeLists.txt | 6 +- library/include/larra/printer_stream.hpp | 2 +- library/include/larra/user_account.hpp | 3 +- library/include/larra/xml_stream.hpp | 2 +- library/src/encryption.cpp | 48 +++++---- library/src/jid.cpp | 10 +- 9 files changed, 170 insertions(+), 114 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 858746c..34597c9 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -12,21 +12,6 @@ RUN pacman -Syyu --noconfirm \ && pacman -S --noconfirm cmake make gcc ninja meson shellcheck \ && pacman -S --noconfirm gtk4 gtkmm-4.0 boost spdlog fmt libxml++-5.0 -# Add cached layer with the latest LLVM-19.1.0 -RUN mkdir -p /home/artifacts -ADD https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0/LLVM-19.1.0-Linux-X64.tar.xz /home/artifacts/ - -# Create the LLVM directory and extract only binaries into it -RUN mkdir -p /home/LLVM-19.1.0 -RUN tar -xJf /home/artifacts/LLVM-19.1.0-Linux-X64.tar.xz -C /home/LLVM-19.1.0 --strip-components=1 LLVM-19.1.0-Linux-X64/bin/clang-19 LLVM-19.1.0-Linux-X64/bin/clang LLVM-19.1.0-Linux-X64/bin/clang++ LLVM-19.1.0-Linux-X64/bin/clang-scan-deps LLVM-19.1.0-Linux-X64/bin/clang-format LLVM-19.1.0-Linux-X64/bin/clang-tidy LLVM-19.1.0-Linux-X64/include/ LLVM-19.1.0-Linux-X64/lib/ LLVM-19.1.0-Linux-X64/libexec/ LLVM-19.1.0-Linux-X64/local/ LLVM-19.1.0-Linux-X64/share/ - -# Add /home/LLVM-19.1.0/bin to the PATH environment variable -ENV PATH="/home/LLVM-19.1.0/bin:${PATH}" - -# Add extra tools -RUN mkdir -p /home/tools -ADD https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py /home/tools/ - # Create a non-root user 'dev' RUN useradd -ms /bin/bash dev \ && echo "dev ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/dev \ @@ -36,10 +21,46 @@ RUN useradd -ms /bin/bash dev \ COPY --from=library/docker:latest /usr/local/bin/docker /usr/bin/docker COPY --from=docker/compose:latest /usr/local/bin/docker-compose /usr/bin/docker-compose +# Allow dev to execute docker without sudo RUN groupadd docker &&\ usermod -aG docker dev &&\ newgrp docker +# Switch to the 'dev' user +USER dev + +# Add cached layer with the latest LLVM-${LLVM_VER} +ARG LLVM_VER=19.1.1 +ENV LLVM_VER=${LLVM_VER} +RUN sudo mkdir -p /home/artifacts +ADD https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VER}/LLVM-${LLVM_VER}-Linux-X64.tar.xz /home/artifacts/ + +# Create the LLVM directory and extract only binaries into it +RUN sudo mkdir -p /home/LLVM-${LLVM_VER} +RUN sudo tar -xJf /home/artifacts/LLVM-${LLVM_VER}-Linux-X64.tar.xz -C /home/LLVM-${LLVM_VER} --strip-components=1 \ + LLVM-${LLVM_VER}-Linux-X64/bin/clang-19 \ + LLVM-${LLVM_VER}-Linux-X64/bin/clang \ + LLVM-${LLVM_VER}-Linux-X64/bin/clang++ \ + LLVM-${LLVM_VER}-Linux-X64/bin/clang-scan-deps \ + LLVM-${LLVM_VER}-Linux-X64/bin/llvm-symbolizer \ + LLVM-${LLVM_VER}-Linux-X64/bin/clang-format \ + LLVM-${LLVM_VER}-Linux-X64/bin/clang-tidy \ + LLVM-${LLVM_VER}-Linux-X64/bin/clang-apply-replacements \ + LLVM-${LLVM_VER}-Linux-X64/include/ \ + LLVM-${LLVM_VER}-Linux-X64/lib/ \ + LLVM-${LLVM_VER}-Linux-X64/libexec/ \ + LLVM-${LLVM_VER}-Linux-X64/local/ \ + LLVM-${LLVM_VER}-Linux-X64/share/ + +# Add /home/LLVM-${LLVM_VER}/bin to the PATH environment variable +ENV PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}" + +# Add extra tools +RUN sudo mkdir -p /home/tools +ADD https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py /home/tools/ +RUN sudo chmod -R a+x /home/tools/ +RUN sudo chown -R dev /home/tools/ + # Add the custom bash prompt with branch info RUN printf '\n\ function modify_prompt { \n\ @@ -52,9 +73,6 @@ function modify_prompt { \n\ } \n\ modify_prompt\n' >> /home/dev/.bashrc -# Switch to the 'dev' user -USER dev - RUN git config --global core.editor vim # Set the default working directory diff --git a/.forgejo/workflows/pr_check.yaml b/.forgejo/workflows/pr_check.yaml index 91fb7ca..3cb98a3 100644 --- a/.forgejo/workflows/pr_check.yaml +++ b/.forgejo/workflows/pr_check.yaml @@ -15,25 +15,34 @@ jobs: - name: Setup environment - Install LLVM-19.1.1 run: | - echo "" >> ~/.bashrc - echo "export LLVM_VER='LLVM-19.1.1'" >> ~/.bashrc - source ~/.bashrc + export LLVM_VER=19.1.1 - echo "::group::Download $LLVM_VER" - wget https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.1/LLVM-19.1.1-Linux-X64.tar.xz -O /$LLVM_VER-Linux-X64.tar.xz + echo "::group::Download LLVM-${LLVM_VER}" + wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VER}/LLVM-${LLVM_VER}-Linux-X64.tar.xz -O /LLVM-${LLVM_VER}-Linux-X64.tar.xz echo "::endgroup::" - echo "::group::Extracting $LLVM_VER" - mkdir -p /home/$LLVM_VER/ - tar -xf /$LLVM_VER-Linux-X64.tar.xz -C "/home/$LLVM_VER/" --strip-components=1 $LLVM_VER-Linux-X64/bin/clang-19 $LLVM_VER-Linux-X64/bin/clang $LLVM_VER-Linux-X64/bin/clang++ $LLVM_VER-Linux-X64/bin/clang-scan-deps $LLVM_VER-Linux-X64/bin/clang-format $LLVM_VER-Linux-X64/bin/clang-tidy $LLVM_VER-Linux-X64/include/ $LLVM_VER-Linux-X64/lib/ $LLVM_VER-Linux-X64/libexec/ $LLVM_VER-Linux-X64/local/ $LLVM_VER-Linux-X64/share/ - rm /$LLVM_VER-Linux-X64.tar.xz + echo "::group::Extracting LLVM-${LLVM_VER}" + mkdir -p /home/LLVM-${LLVM_VER}/ + tar -xf /LLVM-${LLVM_VER}-Linux-X64.tar.xz -C "/home/LLVM-${LLVM_VER}/" --strip-components=1 \ + LLVM-${LLVM_VER}-Linux-X64/bin/clang-19 \ + LLVM-${LLVM_VER}-Linux-X64/bin/clang \ + LLVM-${LLVM_VER}-Linux-X64/bin/clang++ \ + LLVM-${LLVM_VER}-Linux-X64/bin/clang-scan-deps \ + LLVM-${LLVM_VER}-Linux-X64/bin/llvm-symbolizer \ + LLVM-${LLVM_VER}-Linux-X64/bin/clang-format \ + LLVM-${LLVM_VER}-Linux-X64/bin/clang-tidy \ + LLVM-${LLVM_VER}-Linux-X64/include/ \ + LLVM-${LLVM_VER}-Linux-X64/lib/ \ + LLVM-${LLVM_VER}-Linux-X64/libexec/ \ + LLVM-${LLVM_VER}-Linux-X64/local/ \ + LLVM-${LLVM_VER}-Linux-X64/share/ + + rm /LLVM-${LLVM_VER}-Linux-X64.tar.xz echo "::endgroup::" - echo "" >> ~/.bashrc - echo "export PATH='/home/$LLVM_VER/bin:${PATH}'" >> ~/.bashrc - + echo "LLVM version ${LLVM_VER}" echo "Available LLVM binaries:" - ls -la /home/$LLVM_VER/bin/ + ls -la /home/LLVM-${LLVM_VER}/bin/ - name: List CI environment variables run: | @@ -45,6 +54,7 @@ jobs: echo "Ref: ${{ github.ref }}" echo "Ref name: ${{ github.ref_name }}" echo "SHA: ${{ github.sha }}" + echo "PATH: ${PATH}" - name: Check out repository code run: | @@ -77,20 +87,21 @@ jobs: # id: cache-llvm-19-bins-restore # uses: actions/cache@v4 # with: - # path: /$LLVM_VER-Linux-X64-small.tar.xz - # key: $LLVM_VER-Linux-X64-small + # path: /LLVM-${LLVM_VER}-Linux-X64-small.tar.xz + # key: LLVM-${LLVM_VER}-Linux-X64-small # #- name: Save LLVM-19 to cache # if: steps.cache-llvm-19-bins-restore.outputs.cache-hit != 'true' # id: cache-llvm-19-save # uses: actions/cache/save@v4 # with: - # path: /$LLVM_VER-Linux-X64-small.tar.xz - # key: $LLVM_VER-Linux-X64-small + # path: /LLVM-${LLVM_VER}-Linux-X64-small.tar.xz + # key: LLVM-${LLVM_VER}-Linux-X64-small - name: Check clang-format run: | - export PATH="/home/$LLVM_VER/bin:${PATH}" + export LLVM_VER=19.1.1 + export PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}" cd ${{ github.workspace }} find -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.c" -o -name "*.cpp" \) > repo_sources_to_check.txt export REPO_FILES=$(cat repo_sources_to_check.txt) @@ -103,43 +114,12 @@ jobs: for FILE in $REPO_FILES; do clang-format -i ${{ github.workspace }}/$FILE --dry-run --Werror; done echo "No clang-format violations detected!" - - name: Clang build with -fsanitize=address - environment: - CC: /home/$LLVM_VER/bin/clang - CXX: /home/$LLVM_VER/bin/clang++ - run: | - mkdir -p ${{ github.workspace }}/build_clang - cmake -Wno-dev \ - -DCMAKE_C_COMPILER=/home/$LLVM_VER/bin/clang \ - -DCMAKE_CXX_COMPILER=/home/$LLVM_VER/bin/clang++ \ - -S ${{ github.workspace }} \ - -B ${{ github.workspace }}/build_clang \ - -GNinja -DCMAKE_BUILD_TYPE=Release \ - -DENABLE_EXAMPLES=ON \ - -DENABLE_TESTS=ON \ - -DCMAKE_CXX_FLAGS="-stdlib=libstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr" \ - -DCMAKE_EXE_LINKER_FLAGS="-L/usr/lib/x86_64-linux-gnu -lstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr" - cmake --build ${{ github.workspace }}/build_clang --parallel `nproc` - - - name: Clang unit tests with -fsanitize=address - run: | - cd ${{ github.workspace }}/build_clang - ASAN_SYMBOLIZER_PATH=/home/$LLVM_VER/bin/llvm-symbolizer ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=1:atexit=1:abort_on_error=1 ./larra_xmpp_tests - - - name: Check clang-tidy - run: | - export PATH="/home/$LLVM_VER/bin:${PATH}" - wget https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py - python run-clang-tidy.py -use-color -exclude-header-filter .*build.* -header-filter .hpp -p ${{ github.workspace }}/build_clang/ -config-file ${{ github.workspace }}/.clang-tidy ${{ github.workspace }}/examples ${{ github.workspace }}/library/ ${{ github.workspace }}/src/ - echo "::warning::TODO Fix warnings and add '-warnings-as-errors' flags to report clang-tidy errors" - - name: GCC build - environment: - CC: /usr/sbin/gcc - CXX: /usr/sbin/g++ run: | mkdir -p ${{ github.workspace }}/build_gcc cmake -Wno-dev \ + -DCMAKE_C_COMPILER=gcc \ + -DCMAKE_CXX_COMPILER=g++ \ -S ${{ github.workspace }} \ -B ${{ github.workspace }}/build_gcc \ -GNinja -DCMAKE_BUILD_TYPE=Release \ @@ -151,3 +131,46 @@ jobs: run: | cd ${{ github.workspace }}/build_gcc ./larra_xmpp_tests + + - name: Check clang-tidy + run: | + export LLVM_VER=19.1.1 + export PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}" + wget https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py + python run-clang-tidy.py \ + -use-color \ + -warnings-as-errors all \ + -exclude-header-filter .*build.* \ + -header-filter .hpp \ + -p ${{ github.workspace }}/build_gcc/ \ + -config-file ${{ github.workspace }}/.clang-tidy \ + \ + ${{ github.workspace }}/examples \ + ${{ github.workspace }}/library/ \ + ${{ github.workspace }}/src/ + + echo "No clang-tidy violations detected!" + + #- name: Clang build with -fsanitize=address + # run: | + # export LLVM_VER=19.1.1 + # export PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}" + # mkdir -p ${{ github.workspace }}/build_clang + # cmake -Wno-dev \ + # -DCMAKE_C_COMPILER=clang \ + # -DCMAKE_CXX_COMPILER=clang++ \ + # -S ${{ github.workspace }} \ + # -B ${{ github.workspace }}/build_clang \ + # -GNinja -DCMAKE_BUILD_TYPE=Release \ + # -DENABLE_EXAMPLES=ON \ + # -DENABLE_TESTS=ON \ + # -DCMAKE_CXX_FLAGS="-stdlib=libstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr" \ + # -DCMAKE_EXE_LINKER_FLAGS="-L/usr/lib/x86_64-linux-gnu -lstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr" + # cmake --build ${{ github.workspace }}/build_clang --parallel `nproc` + # + #- name: Clang unit tests with -fsanitize=address + # run: | + # export LLVM_VER=19.1.1 + # export PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}" + # cd ${{ github.workspace }}/build_clang + # ASAN_SYMBOLIZER_PATH=llvm-symbolizer ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=1:atexit=1:abort_on_error=1 ./larra_xmpp_tests diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 970b6dd..48f93a6 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -18,10 +18,11 @@ }, { // https://clang.llvm.org/extra/clang-tidy/ + // Add ' -fix ' to automatically fix errors "label": "Checker: clang-tidy dry-run", "type": "shell", "command": [ - "python /home/tools/run-clang-tidy.py -exclude-header-filter .*build.* -use-color -header-filter .hpp -p ${workspaceFolder}/build_clang/ -config-file ${workspaceFolder}/.clang-tidy ", + "python /home/tools/run-clang-tidy.py -exclude-header-filter .*build.* -use-color -warnings-as-errors all -header-filter .hpp -p ${workspaceFolder}/build_clang/ -config-file ${workspaceFolder}/.clang-tidy", " ${workspaceFolder}/examples ", " ${workspaceFolder}/library/ ", " ${workspaceFolder}/src/" @@ -67,8 +68,7 @@ "command": [ "cd ${workspaceFolder} &&", "mkdir -p build && cd build &&", - "cmake -Wno-dev ", - " -DCMAKE_CXX_FLAGS=\"-Wno-non-template-friend\"", + "cmake cmake -Wno-dev ", " -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON .." ], "options": { @@ -132,8 +132,8 @@ ], "options": { "env": { - "CC": "/home/LLVM-19.1.0/bin/clang", - "CXX": "/home/LLVM-19.1.0/bin/clang++" + "CC": "clang", + "CXX": "clang++" } }, "presentation": { @@ -149,13 +149,19 @@ "mkdir -p build_clang && cd build_clang &&", "cmake -Wno-dev ", " -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON ", - " -DCMAKE_CXX_FLAGS=\"-stdlib=libstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr\"", - " -DCMAKE_EXE_LINKER_FLAGS=\"-L/usr/lib/x86_64-linux-gnu -lstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr\" ..", + // + // Uncomment for GCC standart library: libstdc++ + //" -DCMAKE_CXX_FLAGS=\"-stdlib=libstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr\"", + //" -DCMAKE_EXE_LINKER_FLAGS=\"-L/usr/lib/x86_64-linux-gnu -lstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr\"", + // + " -DCMAKE_CXX_FLAGS=\"-stdlib=libc++ -I/home/LLVM-19.1.1/include/c++/v1 -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr\"", + " -DCMAKE_EXE_LINKER_FLAGS=\"-L/home/LLVM-19.1.1/lib/ -Wl,-rpath,/home/LLVM-19.1.1/lib -lc++ -lc++abi -lm -lc -lgcc_s -lgcc -fuse-ld=lld -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr\"", + " .." ], "options": { "env": { - "CC": "/home/LLVM-19.1.0/bin/clang", - "CXX": "/home/LLVM-19.1.0/bin/clang++" + "CC": "clang", + "CXX": "clang++" } }, "presentation": { @@ -174,7 +180,7 @@ "command": [ "cd ${workspaceFolder} &&", "mkdir -p build_clang && cd build_clang &&", - "ASAN_SYMBOLIZER_PATH=/home/LLVM-19.1.0/bin/llvm-symbolizer ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=1:atexit=1:abort_on_error=1 ./larra_xmpp_tests ; echo \"exit code: $?\"", + "ASAN_SYMBOLIZER_PATH=llvm-symbolizer ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=1:atexit=1:abort_on_error=1 ./larra_xmpp_tests ; echo \"exit code: $?\"", ], "presentation": { "clear": true @@ -199,8 +205,8 @@ ], "options": { "env": { - "CC": "/home/LLVM-19.1.0/bin/clang", - "CXX": "/home/LLVM-19.1.0/bin/clang++" + "CC": "clang", + "CXX": "clang++" } }, "presentation": { @@ -219,7 +225,7 @@ "command": [ "cd ${workspaceFolder} &&", "mkdir -p build_clang && cd build_clang &&", - "MSAN_SYMBOLIZER_PATH=/home/LLVM-19.1.0/bin/llvm-symbolizer MSAN_OPTIONS=abort_on_error=1 ./larra_xmpp_tests ; echo \"exit code: $?\"", + "MSAN_SYMBOLIZER_PATH=llvm-symbolizer MSAN_OPTIONS=abort_on_error=1 ./larra_xmpp_tests ; echo \"exit code: $?\"", ], "presentation": { "clear": true @@ -253,7 +259,7 @@ "command": [ "cd ${workspaceFolder} &&", "mkdir -p build_clang && cd build_clang &&", - "MSAN_SYMBOLIZER_PATH=/home/LLVM-19.1.0/bin/llvm-symbolizer MSAN_OPTIONS=abort_on_error=1 ./larra_xmpp_tests ; echo \"exit code: $?\"", + "MSAN_SYMBOLIZER_PATH=llvm-symbolizer MSAN_OPTIONS=abort_on_error=1 ./larra_xmpp_tests ; echo \"exit code: $?\"", ], "presentation": { "clear": true diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ed1307..6193f1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,8 +163,10 @@ add_library(larra::larra_xmpp ALIAS larra_xmpp) target_compile_features(larra_xmpp PUBLIC cxx_std_23) - -target_compile_options(larra_xmpp PUBLIC "$<$:-Wno-changes-meaning>") +target_compile_options(larra_xmpp PUBLIC + "$<$:-Wno-changes-meaning>" + "$<$:-Wno-non-template-friend>" +) target_include_directories(larra_xmpp PUBLIC $ diff --git a/library/include/larra/printer_stream.hpp b/library/include/larra/printer_stream.hpp index 5e3f8b6..d2cfdba 100644 --- a/library/include/larra/printer_stream.hpp +++ b/library/include/larra/printer_stream.hpp @@ -138,7 +138,7 @@ struct boost::asio::ssl::stream> : public boost auto next_layer() -> next_layer_type& { return static_cast(this->Base::next_layer()); } - auto next_layer() const -> const next_layer_type& { + [[nodiscard]] auto next_layer() const -> const next_layer_type& { return static_cast(this->Base::next_layer()); } }; diff --git a/library/include/larra/user_account.hpp b/library/include/larra/user_account.hpp index 906ea56..b6e9b07 100644 --- a/library/include/larra/user_account.hpp +++ b/library/include/larra/user_account.hpp @@ -20,7 +20,8 @@ struct PlainUserAccount { struct EncryptionUserAccount : PlainUserAccount { using PlainUserAccount::PlainUserAccount; constexpr EncryptionUserAccount(PlainUserAccount base) : PlainUserAccount{std::move(base)} {}; - constexpr EncryptionUserAccount(BareJid jid, std::string password) : PlainUserAccount{std::move(jid), std::move(password)} {}; + constexpr EncryptionUserAccount(BareJid jid, std::string password) : + PlainUserAccount{.jid = std::move(jid), .password = std::move(password)} {}; }; struct EncryptionRequiredUserAccount : EncryptionUserAccount { diff --git a/library/include/larra/xml_stream.hpp b/library/include/larra/xml_stream.hpp index 168bfff..8714785 100644 --- a/library/include/larra/xml_stream.hpp +++ b/library/include/larra/xml_stream.hpp @@ -98,7 +98,7 @@ struct XmlStream : Stream { return *this; } - auto next_layer() const -> const Stream& { + [[nodiscard]] auto next_layer() const -> const Stream& { return *this; } diff --git a/library/src/encryption.cpp b/library/src/encryption.cpp index 5a7b2fd..986359a 100644 --- a/library/src/encryption.cpp +++ b/library/src/encryption.cpp @@ -53,33 +53,39 @@ struct DataHolder { }; consteval auto GetDataForTag(sha512sum::EncryptionTag) { - return DataHolder{[] { - return EVP_sha512(); - }, - kSha512ResultSize, - [](auto... args) { - return SHA512(args...); - }}; + return DataHolder{.first = + [] { + return EVP_sha512(); + }, + .second = kSha512ResultSize, + .third = + [](auto... args) { + return SHA512(args...); + }}; } consteval auto GetDataForTag(sha256sum::EncryptionTag) { - return DataHolder{[] { - return EVP_sha256(); - }, - kSha256ResultSize, - [](auto... args) { - return SHA256(args...); - }}; + return DataHolder{.first = + [] { + return EVP_sha256(); + }, + .second = kSha256ResultSize, + .third = + [](auto... args) { + return SHA256(args...); + }}; } consteval auto GetDataForTag(sha1sum::EncryptionTag) { - return DataHolder{[] { - return EVP_sha256(); - }, - kSha1ResultSize, - [](auto... args) { - return SHA1(args...); - }}; + return DataHolder{.first = + [] { + return EVP_sha256(); + }, + .second = kSha1ResultSize, + .third = + [](auto... args) { + return SHA1(args...); + }}; } template diff --git a/library/src/jid.cpp b/library/src/jid.cpp index f9ca838..76b80ab 100644 --- a/library/src/jid.cpp +++ b/library/src/jid.cpp @@ -4,17 +4,17 @@ namespace larra::xmpp { auto ParseBareJid(std::string_view jid, std::size_t at) -> BareJid { - return {static_cast(jid.substr(0, at)), static_cast(jid.substr(at + 1))}; + return {.username = static_cast(jid.substr(0, at)), .server = static_cast(jid.substr(at + 1))}; } auto ParseBareResourceJid(std::string_view jid, std::size_t slash) -> BareResourceJid { - return {static_cast(jid.substr(0, slash)), static_cast(jid.substr(slash + 1))}; + return {.server = static_cast(jid.substr(0, slash)), .resource = static_cast(jid.substr(slash + 1))}; } auto ParseFullJid(std::string_view jid, std::size_t at, std::size_t slash) -> FullJid { - return {static_cast(jid.substr(0, at)), - static_cast(jid.substr(at + 1, slash - at - 1)), - static_cast(jid.substr(slash + 1))}; + return {.username = static_cast(jid.substr(0, at)), + .server = static_cast(jid.substr(at + 1, slash - at - 1)), + .resource = static_cast(jid.substr(slash + 1))}; } auto BareJid::Parse(std::string_view jid) -> BareJid { From 652fecf4b0c6b46e6ea33eb70d8de6bce9bb65a2 Mon Sep 17 00:00:00 2001 From: Ivan-lis Date: Mon, 21 Oct 2024 11:21:26 +0000 Subject: [PATCH 9/9] Fixed clang-tidy/format errors --- .devcontainer/Dockerfile | 9 ++++++--- .devcontainer/post_create_config.sh | 3 +++ .forgejo/workflows/pr_check.yaml | 24 ++++++++++++++++++------ .gitignore | 1 - .vscode/tasks.json | 21 ++++++++++++++++----- library/include/larra/client/client.hpp | 2 +- library/include/larra/features.hpp | 2 +- library/include/larra/stream.hpp | 7 ++++--- library/include/larra/user_account.hpp | 8 ++++---- library/include/larra/utils.hpp | 2 +- library/include/larra/xml_stream.hpp | 4 ++-- 11 files changed, 56 insertions(+), 27 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 34597c9..1e87106 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -8,9 +8,9 @@ FROM archlinux@sha256:a10e51dd0694d6c4142754e9d06cbce7baf91ace8031a30df37064d109 # 2. build/test tools # 3. libraries RUN pacman -Syyu --noconfirm \ - && pacman -S --noconfirm git less vim sudo python-pip wget which pkgconf \ - && pacman -S --noconfirm cmake make gcc ninja meson shellcheck \ - && pacman -S --noconfirm gtk4 gtkmm-4.0 boost spdlog fmt libxml++-5.0 + && pacman -Syyu --noconfirm git less vim sudo python-pip wget which pkgconf \ + && pacman -Syyu --noconfirm cmake make gcc ninja meson shellcheck \ + && pacman -Syyu --noconfirm gtk4 gtkmm-4.0 boost spdlog fmt libxml++-5.0 # Create a non-root user 'dev' RUN useradd -ms /bin/bash dev \ @@ -41,6 +41,9 @@ RUN sudo tar -xJf /home/artifacts/LLVM-${LLVM_VER}-Linux-X64.tar.xz -C /home/LLV LLVM-${LLVM_VER}-Linux-X64/bin/clang-19 \ LLVM-${LLVM_VER}-Linux-X64/bin/clang \ LLVM-${LLVM_VER}-Linux-X64/bin/clang++ \ + LLVM-${LLVM_VER}-Linux-X64/bin/lld \ + LLVM-${LLVM_VER}-Linux-X64/bin/ld.lld \ + LLVM-${LLVM_VER}-Linux-X64/bin/ld64.lld \ LLVM-${LLVM_VER}-Linux-X64/bin/clang-scan-deps \ LLVM-${LLVM_VER}-Linux-X64/bin/llvm-symbolizer \ LLVM-${LLVM_VER}-Linux-X64/bin/clang-format \ diff --git a/.devcontainer/post_create_config.sh b/.devcontainer/post_create_config.sh index c0607f0..9941468 100755 --- a/.devcontainer/post_create_config.sh +++ b/.devcontainer/post_create_config.sh @@ -1,5 +1,8 @@ sleep 5 +sudo chmod -R a+x /home/tools/ +sudo chown -R dev /home/tools/ + # Check that ejabberd server started successfully red='\e[1;31m' off='\e[0m' diff --git a/.forgejo/workflows/pr_check.yaml b/.forgejo/workflows/pr_check.yaml index 3cb98a3..3f7432e 100644 --- a/.forgejo/workflows/pr_check.yaml +++ b/.forgejo/workflows/pr_check.yaml @@ -79,6 +79,12 @@ jobs: ls -la ${{ github.workspace }} echo "This job's status is ${{ job.status }}." + - name: Store list of repo files + run: | + cd ${{ github.workspace }} + find -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.c" -o -name "*.cpp" \) > repo_files_to_check.txt + find -type f \( -name "*.c" -o -name "*.cpp" \) > repo_sources_to_check.txt + #- name: Delete cache # run: | # rm -rf ${{ runner.tool_cache }}/cache-llvm-19-restore @@ -103,8 +109,7 @@ jobs: export LLVM_VER=19.1.1 export PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}" cd ${{ github.workspace }} - find -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.c" -o -name "*.cpp" \) > repo_sources_to_check.txt - export REPO_FILES=$(cat repo_sources_to_check.txt) + export REPO_FILES=$(cat repo_files_to_check.txt) printf "\nList of files to be checked:\n" echo "::group::files to be checked" @@ -136,10 +141,17 @@ jobs: run: | export LLVM_VER=19.1.1 export PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}" + cd ${{ github.workspace }} + + sed -i 's|/usr/sbin/g++|/home/LLVM-19.1.1/bin/clang++ -stdlib=libc++ -I/home/LLVM-${LLVM_VER}/include/c++/v1|' build_gcc/compile_commands.json + sed -i 's|-fdeps-format=p1689r5||' build_gcc/compile_commands.json + sed -i 's|-fmodules-ts||' build_gcc/compile_commands.json + sed -i 's|-fmodule-mapper=.*\.modmap||' build_gcc/compile_commands.json + wget https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py python run-clang-tidy.py \ + -warnings-as-errors=* \ -use-color \ - -warnings-as-errors all \ -exclude-header-filter .*build.* \ -header-filter .hpp \ -p ${{ github.workspace }}/build_gcc/ \ @@ -164,10 +176,10 @@ jobs: # -GNinja -DCMAKE_BUILD_TYPE=Release \ # -DENABLE_EXAMPLES=ON \ # -DENABLE_TESTS=ON \ - # -DCMAKE_CXX_FLAGS="-stdlib=libstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr" \ - # -DCMAKE_EXE_LINKER_FLAGS="-L/usr/lib/x86_64-linux-gnu -lstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr" + # -DCMAKE_CXX_FLAGS="-stdlib=libc++ -I/home/LLVM-${LLVM_VER}/include/c++/v1 -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr" \ + # -DCMAKE_EXE_LINKER_FLAGS="-L/home/LLVM-${LLVM_VER}/lib/ -Wl,-rpath,/home/LLVM-${LLVM_VER}/lib -lc++ -lc++abi -lm -lc -lgcc_s -lgcc -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr" # cmake --build ${{ github.workspace }}/build_clang --parallel `nproc` - # + #- name: Clang unit tests with -fsanitize=address # run: | # export LLVM_VER=19.1.1 diff --git a/.gitignore b/.gitignore index da9f39d..d45daeb 100644 --- a/.gitignore +++ b/.gitignore @@ -29,5 +29,4 @@ ext/ libxmlplusplus-prefix/ spdlog.pc build* -larra temp* diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 48f93a6..ebd295f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -18,13 +18,24 @@ }, { // https://clang.llvm.org/extra/clang-tidy/ - // Add ' -fix ' to automatically fix errors "label": "Checker: clang-tidy dry-run", "type": "shell", "command": [ - "python /home/tools/run-clang-tidy.py -exclude-header-filter .*build.* -use-color -warnings-as-errors all -header-filter .hpp -p ${workspaceFolder}/build_clang/ -config-file ${workspaceFolder}/.clang-tidy", - " ${workspaceFolder}/examples ", - " ${workspaceFolder}/library/ ", + "python /home/tools/run-clang-tidy.py -exclude-header-filter .*build.* -use-color -warnings-as-errors=* -header-filter .hpp -p ${workspaceFolder}/build_clang/ -config-file ${workspaceFolder}/.clang-tidy", + " ${workspaceFolder}/examples", + " ${workspaceFolder}/library/", + " ${workspaceFolder}/src/" + ] + }, + { + // https://clang.llvm.org/extra/clang-tidy/ + "label": "Checker: clang-tidy fix errors", + "type": "shell", + "command": [ + "python /home/tools/run-clang-tidy.py -exclude-header-filter .*build.* -use-color -warnings-as-errors=* -header-filter .hpp -p ${workspaceFolder}/build_clang/ -config-file ${workspaceFolder}/.clang-tidy", + " -fix", + " ${workspaceFolder}/examples", + " ${workspaceFolder}/library/", " ${workspaceFolder}/src/" ] }, @@ -148,7 +159,7 @@ "cd ${workspaceFolder} &&", "mkdir -p build_clang && cd build_clang &&", "cmake -Wno-dev ", - " -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON ", + " -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON", // // Uncomment for GCC standart library: libstdc++ //" -DCMAKE_CXX_FLAGS=\"-stdlib=libstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr\"", diff --git a/library/include/larra/client/client.hpp b/library/include/larra/client/client.hpp index ac91a07..5ee658c 100644 --- a/library/include/larra/client/client.hpp +++ b/library/include/larra/client/client.hpp @@ -74,7 +74,7 @@ struct Client { private: bool active = true; - XmlStream connection; + XmlStream connection{}; BareJid jid; }; diff --git a/library/include/larra/features.hpp b/library/include/larra/features.hpp index f4ffc2e..0c99448 100644 --- a/library/include/larra/features.hpp +++ b/library/include/larra/features.hpp @@ -11,7 +11,7 @@ namespace larra::xmpp { enum class Required : bool { kNotRequired = false, kRequired = true }; struct SaslMechanisms { - std::vector mechanisms; + std::vector mechanisms{}; [[nodiscard]] static auto Parse(const xmlpp::Element*) -> SaslMechanisms; }; diff --git a/library/include/larra/stream.hpp b/library/include/larra/stream.hpp index c66f4a1..e25b882 100644 --- a/library/include/larra/stream.hpp +++ b/library/include/larra/stream.hpp @@ -19,8 +19,8 @@ struct BasicStream { static constexpr auto kAddXmlDecl = true; static inline const std::string kDefaultPrefix = ""; static inline const std::string kDefaultName = "stream:stream"; - FromType from; - ToType to; + FromType from{}; + ToType to{}; std::optional id; std::optional version; std::optional xmlLang; @@ -46,7 +46,8 @@ struct BasicStream { } template - [[nodiscard]] constexpr auto XmlLang(this Self&& self, std::optional value) -> BasicStream { + [[nodiscard]] constexpr auto XmlLang(this Self&& self, std::optional value) // NOLINT(cppcoreguidelines-missing-std-forward) + -> BasicStream { return utils::FieldSetHelper::With<"xmlLang", BasicStream>(std::forward_like(self), std::move(value)); } diff --git a/library/include/larra/user_account.hpp b/library/include/larra/user_account.hpp index b6e9b07..f46291f 100644 --- a/library/include/larra/user_account.hpp +++ b/library/include/larra/user_account.hpp @@ -36,7 +36,7 @@ using UserAccountVariant = std::variant - constexpr auto Jid(this Self&& self, BareJid value) -> UserAccount { + constexpr auto Jid(this Self&& self, BareJid value) -> UserAccount { // NOLINT(cppcoreguidelines-missing-std-forward) return std::visit( [&](auto& ref) -> std::decay_t { return {std::forward_like(ref).Jid(std::move(value))}; @@ -44,7 +44,7 @@ struct UserAccount : UserAccountVariant { self); } template - constexpr auto Password(this Self&& self, std::string value) -> UserAccount { + constexpr auto Password(this Self&& self, std::string value) -> UserAccount { // NOLINT(cppcoreguidelines-missing-std-forward) return std::visit( [&](auto& ref) -> std::decay_t { return std::forward_like(ref).Password(std::move(value)); @@ -52,7 +52,7 @@ struct UserAccount : UserAccountVariant { self); } template - constexpr auto Jid(this Self&& self) -> decltype(auto) { + constexpr auto Jid(this Self&& self) -> decltype(auto) { // NOLINT(cppcoreguidelines-missing-std-forward) return std::visit(std::declval()))>( [](auto& ref) -> decltype(auto) { return std::forward_like(ref.jid); @@ -60,7 +60,7 @@ struct UserAccount : UserAccountVariant { self); } template - constexpr auto Password(this Self&& self) -> decltype(auto) { + constexpr auto Password(this Self&& self) -> decltype(auto) { // NOLINT(cppcoreguidelines-missing-std-forward) return std::visit(std::declval()))>( [](auto& ref) -> decltype(auto) { return std::forward_like(ref.password); diff --git a/library/include/larra/utils.hpp b/library/include/larra/utils.hpp index 1141b7b..bdd7574 100644 --- a/library/include/larra/utils.hpp +++ b/library/include/larra/utils.hpp @@ -84,7 +84,7 @@ struct FieldsDescription { * \return an object of type std::decay_t with data from T with fields from \ref self and the \ref value of the field \ref ptr */ template - constexpr auto With(Type(T::* ptr), Self&& self, Value&& value) const + constexpr auto With(Type(T::* ptr), Self&& self, Value&& value) const // NOLINT(cppcoreguidelines-missing-std-forward) requires(std::is_constructible_v...> && std::is_constructible_v, T> && std::is_constructible_v && impl::SetConcept) { diff --git a/library/include/larra/xml_stream.hpp b/library/include/larra/xml_stream.hpp index 8714785..7aaeb4b 100644 --- a/library/include/larra/xml_stream.hpp +++ b/library/include/larra/xml_stream.hpp @@ -52,7 +52,7 @@ class Parser : private xmlpp::SaxParser { auto ParseChunk(std::string_view str) -> const _xmlError*; - std::stack context; + std::stack context{}; xmlpp::Document& doc; private: @@ -313,7 +313,7 @@ struct XmlStream : Stream { XmlStream(XmlStream&& other) = default; - std::unique_ptr streambuf; // Not movable :( + std::unique_ptr streambuf{}; // Not movable :( }; } // namespace larra::xmpp