From ce7f0f89b28f2a56ea5432cbf3a11c36fef35b98 Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Tue, 2 Sep 2025 20:21:31 -0600 Subject: [PATCH] :construction_worker: Add clang-21 to CI Problem: - Clang 21 has been released and is not yet used by CI. Solution: - Add clang-21 to CI. --- .github/workflows/unit_tests.yml | 15 +++++++++++++-- README.md | 2 +- docs/intro.adoc | 1 + include/stdx/compiler.hpp | 14 +++++++------- include/stdx/ct_conversions.hpp | 11 +++++++---- include/stdx/panic.hpp | 2 +- include/stdx/static_assert.hpp | 4 +++- test/fail/CMakeLists.txt | 2 -- test/fail/ct_check.cpp | 11 ----------- 9 files changed, 33 insertions(+), 29 deletions(-) delete mode 100644 test/fail/ct_check.cpp diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 6e9af3f..5302272 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -13,7 +13,7 @@ env: DEBIAN_FRONTEND: noninteractive CMAKE_GENERATOR: Ninja DEFAULT_CXX_STANDARD: 20 - DEFAULT_LLVM_VERSION: 20 + DEFAULT_LLVM_VERSION: 21 DEFAULT_GCC_VERSION: 14 MULL_LLVM_VERSION: 18 MULL_VERSION: 0.26.1 @@ -30,7 +30,7 @@ jobs: fail-fast: false matrix: compiler: [clang, gcc] - version: [12, 13, 14, 16, 17, 18, 19, 20] + version: [12, 13, 14, 16, 17, 18, 19, 20, 21] cxx_standard: [17, 20] stdlib: [libstdc++, libc++] build_type: [Debug] @@ -39,6 +39,15 @@ jobs: cc: "clang" cxx: "clang++" cxx_flags: "-stdlib=libstdc++" + - version: 21 + compiler: clang + install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 21 + toolchain_root: "/usr/lib/llvm-21" + - version: 21 + compiler: clang + stdlib: libc++ + install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 21 && sudo apt install -y libc++-21-dev libc++abi-21-dev + cxx_flags: "-stdlib=libc++" - version: 20 compiler: clang install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 20 @@ -104,6 +113,8 @@ jobs: cxx: "g++-12" cxx_flags: "" exclude: + - compiler: gcc + version: 21 - compiler: gcc version: 20 - compiler: gcc diff --git a/README.md b/README.md index 2d40dce..469d765 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Some of the extras are available only with C++20 or later. *stdx* supports: -- clang 14 through 20 +- clang 14 through 21 - gcc 12 through 14 See the [full documentation](https://intel.github.io/cpp-std-extensions/). diff --git a/docs/intro.adoc b/docs/intro.adoc index 8757026..fccb96a 100644 --- a/docs/intro.adoc +++ b/docs/intro.adoc @@ -23,6 +23,7 @@ The following compilers are supported: * clang 18 * clang 19 * clang 20 +* clang 21 * gcc 12 * gcc 13 * gcc 14 diff --git a/include/stdx/compiler.hpp b/include/stdx/compiler.hpp index b9d63ff..18ecf94 100644 --- a/include/stdx/compiler.hpp +++ b/include/stdx/compiler.hpp @@ -4,7 +4,7 @@ #ifndef CONSTINIT #ifndef __cpp_constinit -#if defined(__clang__) +#ifdef __clang__ #define CONSTINIT [[clang::require_constant_initialization]] #else #define CONSTINIT @@ -23,7 +23,7 @@ #endif #ifndef CONSTEVAL_UDL -#if defined(__clang__) +#ifdef __clang__ #define CONSTEVAL_UDL constexpr #else #define CONSTEVAL_UDL CONSTEVAL @@ -31,7 +31,7 @@ #endif #ifndef USING_ATTR_NS -#if defined(__clang__) +#ifdef __clang__ #define USING_ATTR_NS using clang: #else #define USING_ATTR_NS using gnu: @@ -51,7 +51,7 @@ #endif #ifndef MUSTTAIL -#if defined(__clang__) +#ifdef __clang__ #define MUSTTAIL [[clang::musttail]] #else #define MUSTTAIL @@ -59,7 +59,7 @@ #endif #ifndef LIFETIMEBOUND -#if defined(__clang__) +#ifdef __clang__ #define LIFETIMEBOUND [[clang::lifetimebound]] #else #define LIFETIMEBOUND @@ -67,7 +67,7 @@ #endif #define STDX_DO_PRAGMA(X) _Pragma(#X) -#if defined(__clang__) +#ifdef __clang__ #define STDX_PRAGMA(X) STDX_DO_PRAGMA(clang X) #else #define STDX_PRAGMA(X) STDX_DO_PRAGMA(GCC X) @@ -75,7 +75,7 @@ #ifndef STDX_DELETED #if __cpp_deleted_function >= 202403L -#if defined(__clang__) +#ifdef __clang__ #define STDX_DELETED(R) \ STDX_PRAGMA(diagnostic push) \ STDX_PRAGMA(diagnostic ignored "-Wunknown-warning-option") \ diff --git a/include/stdx/ct_conversions.hpp b/include/stdx/ct_conversions.hpp index 55bbd1f..a3bf5ff 100644 --- a/include/stdx/ct_conversions.hpp +++ b/include/stdx/ct_conversions.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -9,14 +10,15 @@ namespace stdx { inline namespace v1 { template CONSTEVAL static auto type_as_string() -> std::string_view { -#if defined(__clang__) +#ifdef __clang__ constexpr std::string_view function_name = __PRETTY_FUNCTION__; constexpr auto rhs = function_name.size() - 2; #elif defined(__GNUC__) || defined(__GNUG__) constexpr std::string_view function_name = __PRETTY_FUNCTION__; constexpr auto rhs = function_name.size() - 51; #else - static_assert(false, "Unknown compiler, can't build type name."); + static_assert(always_false_v, + "Unknown compiler, can't build type name."); #endif constexpr auto lhs = function_name.rfind('=', rhs) + 2; @@ -25,14 +27,15 @@ CONSTEVAL static auto type_as_string() -> std::string_view { template CONSTEVAL static auto enum_as_string() -> std::basic_string_view { -#if defined(__clang__) +#ifdef __clang__ constexpr std::string_view value_string = __PRETTY_FUNCTION__; constexpr auto rhs = value_string.size() - 2; #elif defined(__GNUC__) || defined(__GNUG__) constexpr std::string_view value_string = __PRETTY_FUNCTION__; constexpr auto rhs = value_string.size() - 2; #else - static_assert(false, "Unknown compiler, can't build type name."); + static_assert(always_false_v, + "Unknown compiler, can't build type name."); #endif constexpr auto lhs = [&]() -> std::string_view::size_type { diff --git a/include/stdx/panic.hpp b/include/stdx/panic.hpp index c0ca44d..56467f2 100644 --- a/include/stdx/panic.hpp +++ b/include/stdx/panic.hpp @@ -35,7 +35,7 @@ auto panic(Args &&...args) -> void { #if __cplusplus >= 202002L #define STDX_PANIC(MSG, ...) \ - [] { \ + []() -> void { \ using stdx::ct_string_literals::operator""_cts; \ stdx::panic(__VA_ARGS__); \ }() diff --git a/include/stdx/static_assert.hpp b/include/stdx/static_assert.hpp index 71d90e7..5fe2c14 100644 --- a/include/stdx/static_assert.hpp +++ b/include/stdx/static_assert.hpp @@ -8,6 +8,7 @@ namespace stdx { inline namespace v1 { +namespace detail { struct ct_check_value {}; template struct ct_check_t { @@ -22,6 +23,7 @@ template <> struct ct_check_t { } }; template constexpr auto ct_check = ct_check_t{}; +} // namespace detail } // namespace v1 } // namespace stdx @@ -45,7 +47,7 @@ template constexpr auto ct_check = ct_check_t{}; #define STATIC_ASSERT(cond, ...) \ [&]() -> bool { \ constexpr auto S = STDX_CT_FORMAT(__VA_ARGS__); \ - stdx::ct_check.template emit(); \ + stdx::detail::ct_check.template emit(); \ return B; \ }.template operator()() #endif diff --git a/test/fail/CMakeLists.txt b/test/fail/CMakeLists.txt index 15a8f08..d251add 100644 --- a/test/fail/CMakeLists.txt +++ b/test/fail/CMakeLists.txt @@ -55,8 +55,6 @@ function(add_test_by_compiler CPP_NAME CXX_VERSION COMPILER_ID COMPILER_VERSION) endif() endfunction() -add_test_by_compiler(ct_check 20 Clang 15) -add_test_by_compiler(ct_check 20 GNU 13.2) add_test_by_compiler(static_assert 20 Clang 15) add_test_by_compiler(static_assert 20 GNU 13.2) add_test_by_compiler(static_assert_format 20 Clang 15) diff --git a/test/fail/ct_check.cpp b/test/fail/ct_check.cpp deleted file mode 100644 index c0e511e..0000000 --- a/test/fail/ct_check.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -// EXPECT: 01234567890123456789012345678901234567890123456789 - -constexpr auto msg = - stdx::ct_string{"01234567890123456789012345678901234567890123456789"}; - -auto main() -> int { - [[maybe_unused]] auto x = stdx::ct_check.emit<"not emitted">(); - stdx::ct_check.emit(); -}