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