Skip to content

Commit

Permalink
Merge pull request #163 from elbeno/update-clang-tidy
Browse files Browse the repository at this point in the history
🚨 Update clang-tidy for C++20 checks
  • Loading branch information
elbeno authored Oct 24, 2024
2 parents 5530b5d + fb1b270 commit 3641082
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/asciidoctor-ghpages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Checkout source
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node.js
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
- name: Install Mermaid
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ jobs:
CC: "/usr/lib/llvm-${{env.DEFAULT_LLVM_VERSION}}/bin/clang"
CXX: "/usr/lib/llvm-${{env.DEFAULT_LLVM_VERSION}}/bin/clang++"
PR_TARGET_BRANCH: ${{ steps.target_branch.outputs.branch }}
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=17 -DCPM_SOURCE_CACHE=~/cpm-cache
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=${{env.DEFAULT_CXX_STANDARD}} -DCPM_SOURCE_CACHE=~/cpm-cache

- name: Save CPM cache
env:
Expand Down
3 changes: 3 additions & 0 deletions include/stdx/atomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <atomic>
#include <type_traits>

// NOLINTBEGIN(cppcoreguidelines-macro-usage)
#if __cplusplus >= 202002L
#define CPP20(...) __VA_ARGS__
#else
Expand Down Expand Up @@ -123,3 +124,5 @@ template <typename T> class atomic {
};
} // namespace v1
} // namespace stdx

// NOLINTEND(cppcoreguidelines-macro-usage)
1 change: 1 addition & 0 deletions include/stdx/atomic_bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class atomic_bitset {
auto const len = std::min(n, str.size() - pos);
auto const s = str.substr(pos, std::min(len, N));
auto i = bit;
// NOLINTNEXTLINE(modernize-loop-convert)
for (auto it = std::rbegin(s); it != std::rend(s); ++it) {
if (*it == one) {
ret |= i;
Expand Down
4 changes: 4 additions & 0 deletions include/stdx/bit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <bit>
#endif

// NOLINTBEGIN(modernize-use-constraints)

namespace stdx {
inline namespace v1 {

Expand Down Expand Up @@ -357,3 +359,5 @@ template <std::size_t N> CONSTEVAL auto smallest_uint() {
template <std::size_t N> using smallest_uint_t = decltype(smallest_uint<N>());
} // namespace v1
} // namespace stdx

// NOLINTEND(modernize-use-constraints)
1 change: 1 addition & 0 deletions include/stdx/bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class bitset {
auto const len = std::min(n, str.size() - pos);
auto i = std::size_t{};
auto const s = str.substr(pos, std::min(len, N));
// NOLINTNEXTLINE(modernize-loop-convert)
for (auto it = std::rbegin(s); it != std::rend(s); ++it) {
set(i++, *it == one);
}
Expand Down
4 changes: 4 additions & 0 deletions include/stdx/byterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <iterator>
#include <type_traits>

// NOLINTBEGIN(modernize-use-constraints)

namespace stdx {
inline namespace v1 {

Expand Down Expand Up @@ -210,3 +212,5 @@ byterator(It) -> byterator<detail::iterator_value_t<It>>;

} // namespace v1
} // namespace stdx

// NOLINTEND(modernize-use-constraints)
2 changes: 1 addition & 1 deletion include/stdx/ct_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ inline namespace v1 {
template <std::size_t N> struct ct_string {
CONSTEVAL ct_string() = default;

// NOLINTNEXTLINE(*-avoid-c-arrays)
// NOLINTNEXTLINE(*-avoid-c-arrays, google-explicit-constructor)
CONSTEVAL explicit(false) ct_string(char const (&str)[N]) {
for (auto i = std::size_t{}; i < N; ++i) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-*)
Expand Down
1 change: 1 addition & 0 deletions include/stdx/cx_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ template <typename Key, typename Value, std::size_t N> class cx_map {

public:
constexpr cx_map() = default;
// NOLINTNEXTLINE(modernize-use-constraints)
template <typename... Vs, std::enable_if_t<((sizeof...(Vs) <= N) and ... and
stdx::same_as<value_type, Vs>),
int> = 0>
Expand Down
1 change: 1 addition & 0 deletions include/stdx/cx_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ template <typename Key, std::size_t N> class cx_set {

constexpr cx_set() = default;
template <typename... Ts,
// NOLINTNEXTLINE(modernize-use-constraints)
std::enable_if_t<((sizeof...(Ts) <= N) and ... and
stdx::convertible_to<key_type, Ts>),
int> = 0>
Expand Down
1 change: 1 addition & 0 deletions include/stdx/cx_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ template <typename T, std::size_t N> class cx_vector {

constexpr cx_vector() = default;
template <typename... Ts,
// NOLINTNEXTLINE(modernize-use-constraints)
std::enable_if_t<((sizeof...(Ts) <= N) and ... and
stdx::convertible_to<value_type, Ts>),
int> = 0>
Expand Down
4 changes: 4 additions & 0 deletions include/stdx/optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <type_traits>
#include <utility>

// NOLINTBEGIN(modernize-use-constraints)

namespace stdx {
inline namespace v1 {
template <typename T, typename = void> struct tombstone_traits {
Expand Down Expand Up @@ -256,3 +258,5 @@ constexpr auto transform(F &&f, Ts &&...ts) {
}
} // namespace v1
} // namespace stdx

// NOLINTEND(modernize-use-constraints)
4 changes: 4 additions & 0 deletions include/stdx/span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <limits>
#include <type_traits>

// NOLINTBEGIN(modernize-use-constraints)

namespace stdx {
inline namespace v1 {

Expand Down Expand Up @@ -280,3 +282,5 @@ template <typename T, std::size_t N>
constexpr auto ct_capacity_v<span<T, N>> = N;
} // namespace v1
} // namespace stdx

// NOLINTEND(modernize-use-constraints)
1 change: 1 addition & 0 deletions include/stdx/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ template <typename T, typename... Ts> constexpr auto try_construct() -> T {
}

template <typename T> struct any_t {
// NOLINTNEXTLINE(modernize-use-constraints)
template <typename U, std::enable_if_t<not std::is_same_v<T, U>, int> = 0>
// NOLINTNEXTLINE(google-explicit-constructor)
constexpr operator U() {
Expand Down
3 changes: 3 additions & 0 deletions include/stdx/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <type_traits>
#include <utility>

// NOLINTBEGIN(modernize-use-constraints)

namespace stdx {
inline namespace v1 {

Expand Down Expand Up @@ -221,3 +223,4 @@ constexpr auto is_aligned_with = [](auto v) -> bool {
#endif

// NOLINTEND(cppcoreguidelines-macro-usage)
// NOLINTEND(modernize-use-constraints)
8 changes: 7 additions & 1 deletion test/pbt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
if(${CMAKE_CXX_STANDARD} GREATER_EQUAL 20)
add_executable(pbt_prototype_driver EXCLUDE_FROM_ALL
pbt_prototype_driver.cpp)
target_link_libraries(pbt_prototype_driver PUBLIC sanitizers warnings stdx)
target_link_libraries(pbt_prototype_driver PRIVATE sanitizers warnings stdx)
target_compile_options(
pbt_prototype_driver
PRIVATE -fconstexpr-depth=4096
$<$<CXX_COMPILER_ID:Clang>:-fconstexpr-steps=4000000000>
$<$<CXX_COMPILER_ID:GNU>:-fconstexpr-ops-limit=4000000000>
$<$<CXX_COMPILER_ID:Clang>:-fbracket-depth=1024>)

add_unit_test(
tuple
Expand Down

0 comments on commit 3641082

Please sign in to comment.