From be05d43ea76174bc91fc51cab8a62cb61b737d4f Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 9 Feb 2022 11:44:56 +0100 Subject: [PATCH 1/4] Add CI test with clang-13 --- .github/workflows/unit-tests.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 391e2ad2a..ac42269c8 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -33,11 +33,11 @@ jobs: - { compiler: gcc-11, os: ubuntu-20.04, buildType: Debug, cxxStandard: 17 } - { compiler: gcc-11, os: ubuntu-20.04, buildType: Release } # Latest Clang with externals - - { compiler: clang-12, os: ubuntu-20.04, buildType: Debug, cxxStandard: 14, externalSanitizer: true } - - { compiler: clang-12, os: ubuntu-20.04, buildType: Debug, cxxStandard: 17 } - - { compiler: clang-12, os: ubuntu-20.04, buildType: Release } + - { compiler: clang-13, os: ubuntu-20.04, buildType: Debug, cxxStandard: 14, externalSanitizer: true } + - { compiler: clang-13, os: ubuntu-20.04, buildType: Debug, cxxStandard: 17 } + - { compiler: clang-13, os: ubuntu-20.04, buildType: Release } # Latest Clang with latest boost - - { compiler: clang-12, os: ubuntu-20.04, buildType: Debug, boostVersion: 1.77.0, externalSanitizer: true } + - { compiler: clang-13, os: ubuntu-20.04, buildType: Debug, boostVersion: 1.78.0, externalSanitizer: true } runs-on: ${{matrix.os}} @@ -65,6 +65,12 @@ jobs: path: ${{env.DEPS_DIR}} key: ${{matrix.os}}-${{env.BOOST_VERSION}} + - name: Add LLVM repo + if: matrix.compiler == 'clang-13' && matrix.os == 'ubuntu-20.04' + run: | + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main' + sudo apt update - name: Install Compiler if: "!startsWith(runner.os, 'macos')" run: | From d7767abc60c1af7e804f9c7e8ce4d0325ca2d67e Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 9 Feb 2022 14:17:09 +0100 Subject: [PATCH 2/4] Add missing defaulted copy-assignment to Point class Otherwise this is disabled due to the custom copy ctor --- libs/common/include/Point.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/common/include/Point.h b/libs/common/include/Point.h index c7a54ea4e..43364804b 100644 --- a/libs/common/include/Point.h +++ b/libs/common/include/Point.h @@ -24,10 +24,11 @@ struct Point //-V690 T x, y; constexpr Point() noexcept : x(getInvalidValue()), y(getInvalidValue()) {} constexpr Point(const T x, const T y) noexcept : x(x), y(y) {} - constexpr Point(const Point&) = default; template constexpr explicit Point(const Point& pt) noexcept : x(static_cast(pt.x)), y(static_cast(pt.y)) {} + constexpr Point(const Point&) = default; + constexpr Point& operator=(const Point&) = default; static constexpr Point Invalid() noexcept { return Point(); } /// Create a new point with all coordinates set to value From 0fce204dba364ed9e9092ba78fb9a51a48ecf6c9 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 9 Feb 2022 14:19:40 +0100 Subject: [PATCH 3/4] Fix AI ordering tools The AI may ignore tool requirements caused by multiple worker types using the same tool as the tool requirement was checked against the total available number of tools not the number of tools available after taking into account workers checked earlier. --- libs/s25main/ai/aijh/AIPlayerJH.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/s25main/ai/aijh/AIPlayerJH.cpp b/libs/s25main/ai/aijh/AIPlayerJH.cpp index 19c8f9ab7..cd8088751 100644 --- a/libs/s25main/ai/aijh/AIPlayerJH.cpp +++ b/libs/s25main/ai/aijh/AIPlayerJH.cpp @@ -2371,7 +2371,7 @@ void AIPlayerJH::AdjustSettings() const unsigned requiredTools = numBuildingsRequiringWorker - inventory[job]; // When we are missing tools produce some. // Slightly higher priority if we don't have any tool at all. - if(requiredTools > inventory[good]) + if(requiredTools > numToolsAvailable) return (inventory[good] == 0) ? 4 : 2; numToolsAvailable -= requiredTools; } From 5bc1f78061cd9c689071785b6b66a95fc693a8b6 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 9 Feb 2022 14:55:27 +0100 Subject: [PATCH 4/4] Update GoogleBenchmark to 1.6.1 Version up to 1.5.5 cause an unused variable warning on clang-13, so use that to update to latest release --- tests/s25Main/benchmarks/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/s25Main/benchmarks/CMakeLists.txt b/tests/s25Main/benchmarks/CMakeLists.txt index 838064f7e..5ed33b8df 100644 --- a/tests/s25Main/benchmarks/CMakeLists.txt +++ b/tests/s25Main/benchmarks/CMakeLists.txt @@ -10,7 +10,7 @@ else() FetchContent_Declare( GoogleBenchmark GIT_REPOSITORY https://github.com/google/benchmark.git - GIT_TAG v1.5.3 + GIT_TAG v1.6.1 ) set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "") set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "")