Skip to content

Commit

Permalink
Merge pull request #65 from bluescarni/pr/tidy_build_fixes
Browse files Browse the repository at this point in the history
clang-tidy and build system fixes
  • Loading branch information
bluescarni authored Mar 2, 2025
2 parents 14e076a + 52647de commit 9f7f11b
Show file tree
Hide file tree
Showing 302 changed files with 17,200 additions and 4,934 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,*,-hicpp-uppercase-literal-suffix,-readability-uppercase-literal-suffix,-modernize-use-trailing-return-type,-readability-named-parameter,-hicpp-named-parameter,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-llvm-header-guard,-cppcoreguidelines-macro-usage,-google-runtime-references,-readability-isolate-declaration,-fuchsia-default-arguments-calls,-fuchsia-overloaded-operator,-fuchsia-default-arguments-declarations,-readability-else-after-return,-google-runtime-int,-hicpp-signed-bitwise,-cert-dcl21-cpp,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-avoid-c-arrays,-hicpp-avoid-c-arrays,-modernize-avoid-c-arrays,-modernize-use-transparent-functors,-cert-dcl16-c,-cppcoreguidelines-pro-type-union-access,-bugprone-branch-clone,-fuchsia-statically-constructed-objects,-cppcoreguidelines-pro-bounds-constant-array-index,-readability-static-accessed-through-instance,-cppcoreguidelines-pro-type-vararg,-hicpp-vararg,-llvmlibc-restrict-system-libc-headers,-llvmlibc-callee-namespace,-llvmlibc-implementation-in-namespace,-llvm-else-after-return,-fuchsia-trailing-return,-readability-identifier-length,-altera-unroll-loops,-altera-id-dependent-backward-branch,-altera-struct-pack-align,-performance-no-int-to-ptr,-readability-function-cognitive-complexity,-llvmlibc-inline-function-decl,-misc-include-cleaner,-fuchsia-multiple-inheritance'
WarningsAsErrors: '*'
AnalyzeTemporaryDtors: false
FormatStyle: none
User: yardbird
CheckOptions:
Expand Down
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,18 @@ if(TANUKI_WITH_BOOST_S11N)
# NOTE: we rely on Boost.align to check alignment of pointers
# at runtime in debug mode. The Boost.align library appeared in
# version 1.59.0 but its API was updated in 1.61.0.
find_package(Boost 1.61.0 REQUIRED serialization)
# NOTE: we look for Boost in CONFIG mode first, as that has become the official supported way
# of locating Boost in recent Boost/CMake versions. If we fail, we try again in
# MODULE mode as last resort.
find_package(Boost 1.61.0 QUIET COMPONENTS serialization CONFIG)
if(NOT ${Boost_FOUND})
message(STATUS "Boost not found in CONFIG mode, retrying in MODULE mode.")
find_package(Boost 1.61.0 QUIET MODULE COMPONENTS serialization)
endif()
if(NOT ${Boost_FOUND})
message(FATAL_ERROR "Could not locate Boost in either CONFIG or MODULE mode.")
endif()
message(STATUS "Found Boost version ${Boost_VERSION}.")
add_library(tanuki_boost_s11n INTERFACE)
target_link_libraries(tanuki_boost_s11n INTERFACE Boost::serialization)
target_compile_definitions(tanuki_boost_s11n INTERFACE TANUKI_WITH_BOOST_S11N)
Expand Down
16 changes: 8 additions & 8 deletions test/bidirectional_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "bidirectional_iterator.hpp"
#include "sentinel.hpp"

// NOLINTBEGIN(cert-err58-cpp,misc-use-anonymous-namespace,cppcoreguidelines-avoid-do-while)
// NOLINTBEGIN(cert-err58-cpp,misc-use-anonymous-namespace,cppcoreguidelines-avoid-do-while,bugprone-crtp-constructor-accessibility)

template <typename T>
concept can_make_bidirectional_iterator = requires(T it) { facade::make_bidirectional_iterator(it); };
Expand Down Expand Up @@ -257,17 +257,17 @@ struct iter_move1 {
void operator--() {}
};

bool operator==(const iter_move1 &, const iter_move1 &)
static bool operator==(const iter_move1 &, const iter_move1 &)
{
return true;
}

// LCOV_EXCL_STOP

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
int iter_move1_counter = 0;
static int iter_move1_counter = 0;

double iter_move(const iter_move1 &)
static double iter_move(const iter_move1 &)
{
++iter_move1_counter;

Expand Down Expand Up @@ -301,17 +301,17 @@ struct iter_move2 {
void operator--() {}
};

bool operator==(const iter_move2 &, const iter_move2 &)
static bool operator==(const iter_move2 &, const iter_move2 &)
{
return true;
}

// LCOV_EXCL_STOP

// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
int iter_move2_counter = 0;
static int iter_move2_counter = 0;

int iter_move(const iter_move2 &)
static int iter_move(const iter_move2 &)
{
++iter_move2_counter;

Expand All @@ -332,4 +332,4 @@ TEST_CASE("iter_move factory")
REQUIRE(ns::iter_move2_counter == 3);
}

// NOLINTEND(cert-err58-cpp,misc-use-anonymous-namespace,cppcoreguidelines-avoid-do-while)
// NOLINTEND(cert-err58-cpp,misc-use-anonymous-namespace,cppcoreguidelines-avoid-do-while,bugprone-crtp-constructor-accessibility)
4 changes: 4 additions & 0 deletions test/catch/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Enable Bzlmod for every Bazel command
common --enable_bzlmod

build --enable_platform_specific_config

build:gcc9 --cxxopt=-std=c++2a
Expand All @@ -8,3 +11,4 @@ build:vs2022 --cxxopt=/std:c++17

build:windows --config=vs2022
build:linux --config=gcc11
build:macos --cxxopt=-std=c++2b
82 changes: 82 additions & 0 deletions test/catch/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
# Note: Alas, `Checks` is a string, not an array.
# Comments in the block string are not parsed and are passed in the value.
# They must thus be delimited by ',' from either side - then they are
# harmless. It's terrible, but it works.
Checks: >-
clang-diagnostic-*,
clang-analyzer-*,
-clang-analyzer-optin.core.EnumCastOutOfRange,
bugprone-*,
-bugprone-unchecked-optional-access,
,# This is ridiculous, as it triggers on constants,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-easily-swappable-parameters,
,# Is not really useful, has false positives, triggers for no-noexcept move constructors ...,
-bugprone-exception-escape,
-bugprone-narrowing-conversions,
-bugprone-chained-comparison,# RIP decomposers,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-use-auto,
-modernize-use-emplace,
-modernize-use-nullptr,# it went crazy with three-way comparison operators,
-modernize-use-trailing-return-type,
-modernize-return-braced-init-list,
-modernize-concat-nested-namespaces,
-modernize-use-nodiscard,
-modernize-use-default-member-init,
-modernize-type-traits,# we need to support C++14,
-modernize-deprecated-headers,
,# There's a lot of these and most of them are probably not useful,
-modernize-pass-by-value,
performance-*,
performance-enum-size,
portability-*,
readability-*,
-readability-braces-around-statements,
-readability-container-size-empty,
-readability-convert-member-functions-to-static,
-readability-else-after-return,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-math-missing-parentheses, #no, 'a + B * C' obeying math rules is not confusing,
-readability-named-parameter,
-readability-qualified-auto,
-readability-redundant-access-specifiers,
-readability-simplify-boolean-expr,
-readability-static-definition-in-anonymous-namespace,
-readability-uppercase-literal-suffix,
-readability-use-anyofallof,
-readability-avoid-return-with-void-value,
,# time hogs,
-bugprone-throw-keyword-missing,
-modernize-replace-auto-ptr,
-readability-identifier-naming,
,# We cannot use this until clang-tidy supports custom unique_ptr,
-bugprone-use-after-move,
,# Doesn't recognize unevaluated context in CATCH_MOVE and CATCH_FORWARD,
-bugprone-macro-repeated-side-effects,
WarningsAsErrors: >-
clang-analyzer-core.*,
clang-analyzer-cplusplus.*,
clang-analyzer-security.*,
clang-analyzer-unix.*,
performance-move-const-arg,
performance-unnecessary-value-param,
readability-duplicate-include,
HeaderFilterRegex: '.*\.(c|cxx|cpp)$'
FormatStyle: none
CheckOptions: {}
...
16 changes: 6 additions & 10 deletions test/catch/.conan/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
cmake_minimum_required(VERSION 3.2.0)
project(test_package CXX)
cmake_minimum_required(VERSION 3.16)
project(PackageTest CXX)

include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup()
find_package(Catch2 CONFIG REQUIRED)

find_package(Catch2 REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)

target_link_libraries(${PROJECT_NAME} Catch2::Catch2WithMain)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14)
add_executable(test_package test_package.cpp)
target_link_libraries(test_package Catch2::Catch2WithMain)
target_compile_features(test_package PRIVATE cxx_std_14)
32 changes: 26 additions & 6 deletions test/catch/.conan/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from conans import ConanFile, CMake
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run
from conan.tools.files import save, load
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake_find_package_multi", "cmake"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def generate(self):
save(self, os.path.join(self.build_folder, "package_folder"),
self.dependencies[self.tested_reference_str].package_folder)
save(self, os.path.join(self.build_folder, "license"),
self.dependencies[self.tested_reference_str].license)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
assert os.path.isfile(os.path.join(
self.deps_cpp_info["catch2"].rootpath, "licenses", "LICENSE.txt"))
bin_path = os.path.join("bin", "test_package")
self.run("%s -s" % bin_path, run_environment=True)
if can_run(self):
cmd = os.path.join(self.cpp.build.bindir, "test_package")
self.run(cmd, env="conanrun")

package_folder = load(self, os.path.join(self.build_folder, "package_folder"))
license = load(self, os.path.join(self.build_folder, "license"))
assert os.path.isfile(os.path.join(package_folder, "licenses", "LICENSE.txt"))
assert license == 'BSL-1.0'
2 changes: 1 addition & 1 deletion test/catch/.github/workflows/linux-bazel-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
compilation_mode: [fastbuild, dbg, opt]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Mount bazel cache
uses: actions/cache@v3
Expand Down
7 changes: 4 additions & 3 deletions test/catch/.github/workflows/linux-meson-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ jobs:
other_pkgs: clang-11

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Prepare environment
run: sudo apt-get install -y meson ninja-build ${{matrix.other_pkgs}}
run: |
sudo apt-get update
sudo apt-get install -y meson ninja-build ${{matrix.other_pkgs}}
- name: Configure build
env:
Expand All @@ -38,6 +40,5 @@ jobs:

- name: Run tests
working-directory: ${{runner.workspace}}/meson-build
# Hardcode 2 cores we know are there
run: |
meson test --verbose
58 changes: 54 additions & 4 deletions test/catch/.github/workflows/linux-other-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ jobs:


steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Prepare environment
run: sudo apt-get install -y ninja-build ${{matrix.other_pkgs}}
run: |
sudo apt-get update
sudo apt-get install -y ninja-build ${{matrix.other_pkgs}}
- name: Configure build
working-directory: ${{runner.workspace}}
Expand All @@ -100,5 +102,53 @@ jobs:
env:
CTEST_OUTPUT_ON_FAILURE: 1
working-directory: ${{runner.workspace}}/build
# Hardcode 2 cores we know are there
run: ctest -C ${{matrix.build_type}} -j 2 ${{matrix.other_ctest_args}}
run: ctest -C ${{matrix.build_type}} -j `nproc` ${{matrix.other_ctest_args}}
clang-tidy:
name: clang-tidy ${{matrix.version}}, ${{matrix.build_description}}, C++${{matrix.std}} ${{matrix.build_type}}
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- version: "15"
build_description: all
build_type: Debug
std: 17
other_pkgs: ''
cmake_configurations: -DCATCH_BUILD_EXAMPLES=ON -DCATCH_ENABLE_CMAKE_HELPER_TESTS=ON
steps:
- uses: actions/checkout@v4

- name: Prepare environment
run: |
sudo apt-get update
sudo apt-get install -y ninja-build clang-${{matrix.version}} clang-tidy-${{matrix.version}} ${{matrix.other_pkgs}}
- name: Configure build
working-directory: ${{runner.workspace}}
env:
CXX: clang++-${{matrix.version}}
CXXFLAGS: ${{matrix.cxxflags}}
# Note: $GITHUB_WORKSPACE is distinct from ${{runner.workspace}}.
# This is important
run: |
clangtidy="clang-tidy-${{matrix.version}};-use-color"
# Use a dummy compiler/linker/ar/ranlib to effectively disable the
# compilation and only run clang-tidy.
cmake -Bbuild -H$GITHUB_WORKSPACE \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DCATCH_DEVELOPMENT_BUILD=ON \
-DCMAKE_CXX_CLANG_TIDY="$clangtidy" \
-DCMAKE_CXX_COMPILER_LAUNCHER=/usr/bin/true \
-DCMAKE_AR=/usr/bin/true \
-DCMAKE_CXX_COMPILER_AR=/usr/bin/true \
-DCMAKE_RANLIB=/usr/bin/true \
-DCMAKE_CXX_LINK_EXECUTABLE=/usr/bin/true \
${{matrix.cmake_configurations}} \
-G Ninja
- name: Run clang-tidy
working-directory: ${{runner.workspace}}/build
run: ninja
9 changes: 5 additions & 4 deletions test/catch/.github/workflows/linux-simple-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
other_pkgs: g++-10

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Add repositories for older GCC
run: |
Expand All @@ -92,7 +92,9 @@ jobs:
if: ${{ matrix.cxx == 'g++-5' || matrix.cxx == 'g++-6' }}

- name: Prepare environment
run: sudo apt-get install -y ninja-build ${{matrix.other_pkgs}}
run: |
sudo apt-get update
sudo apt-get install -y ninja-build ${{matrix.other_pkgs}}
- name: Configure build
working-directory: ${{runner.workspace}}
Expand All @@ -118,5 +120,4 @@ jobs:
env:
CTEST_OUTPUT_ON_FAILURE: 1
working-directory: ${{runner.workspace}}/build
# Hardcode 2 cores we know are there
run: ctest -C ${{matrix.build_type}} -j 2
run: ctest -C ${{matrix.build_type}} -j `nproc`
Loading

0 comments on commit 9f7f11b

Please sign in to comment.