Skip to content

Commit

Permalink
Merge branch 'boostorg:master' into zig-pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Feb 25, 2024
2 parents e229220 + e820551 commit f4896a1
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 30 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Hana CI

permissions:
contents: read

on: pull_request

jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
xcode-version: latest-stable
- os: macos-latest
compiler: llvm
# - os: macos-latest
# compiler: gcc
# - os: windows-latest
# compiler: llvm
- os: ubuntu-latest
compiler: llvm
# - os: ubuntu-latest
# compiler: gcc

steps:
- name: Setup build environment
uses: aminya/setup-cpp@v1
with:
vcvarsall: ${{ contains(matrix.os, 'windows') }}
cmake: true
ninja: true

- name: Setup compiler
uses: aminya/setup-cpp@v1
if: ${{ matrix.compiler }}
with:
compiler: ${{ matrix.compiler }}

- name: Install Xcode
uses: maxim-lobanov/setup-xcode@v1
if: ${{ matrix.xcode-version }}
with:
xcode-version: ${{ matrix.xcode-version }}

- name: Checkout source code
uses: actions/checkout@v3

- name: Configure CMake
run: mkdir build && cmake -S . -B build -G Ninja

- name: Run the tests
run: cmake --build build --target check
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ function(boost_hana_set_test_properties target)
if (NOT MSVC)
setflag(BOOST_HANA_HAS_FDIAGNOSTICS_COLOR -fdiagnostics-color)
setflag(BOOST_HANA_HAS_FTEMPLATE_BACKTRACE_LIMIT -ftemplate-backtrace-limit=0)
setflag(BOOST_HANA_HAS_PEDANTIC -pedantic)
setflag(BOOST_HANA_HAS_WALL -Wall)
setflag(BOOST_HANA_HAS_WERROR -Werror)
setflag(BOOST_HANA_HAS_WEXTRA -Wextra)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ re-run the CMake generation step, a new target named `path.to.file` will be
created, and a test of the same name will also be created. Hence,
```shell
cmake --build build --target path.to.file # Builds the program associated to path/to/file.cpp
cd build && ctest -R path.to.file # Runs the program as a test
ctest --test-dir build -R path.to.file # Runs the program as a test
```
> #### Tip for Sublime Text users
Expand Down
2 changes: 2 additions & 0 deletions include/boost/hana/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ Distributed under the Boost Software License, Version 1.0.

#elif defined(__clang__) && defined(_MSC_VER) // Clang-cl (Clang for Windows)

# define BOOST_HANA_CONFIG_CLANG_CL
# define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION( \
__clang_major__, __clang_minor__, __clang_patchlevel__)

#elif defined(__clang__) && defined(__apple_build_version__) // Apple's Clang

# define BOOST_HANA_CONFIG_APPLE_CLANG
# if __apple_build_version__ >= 6020049
# define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION(3, 6, 0)
# endif
Expand Down
15 changes: 10 additions & 5 deletions include/boost/hana/experimental/type_name.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,23 @@ namespace boost { namespace hana { namespace experimental {

// Note: We substract the null terminator from the string sizes below.
template <typename T>
constexpr cstring type_name_impl2() {

#if defined(__clang__)
constexpr auto type_name_impl2() {
#if defined(BOOST_HANA_CONFIG_CLANG)
constexpr char const* pretty_function = __PRETTY_FUNCTION__;
constexpr std::size_t total_size = sizeof(__PRETTY_FUNCTION__) - 1;
constexpr std::size_t prefix_size = sizeof("auto boost::hana::experimental::detail::type_name_impl2() [T = ") - 1;
constexpr std::size_t suffix_size = sizeof("]") - 1;
#elif defined(BOOST_HANA_CONFIG_GCC)
constexpr char const* pretty_function = __PRETTY_FUNCTION__;
constexpr std::size_t total_size = sizeof(__PRETTY_FUNCTION__) - 1;
constexpr std::size_t prefix_size = sizeof("boost::hana::experimental::detail::cstring boost::hana::experimental::detail::type_name_impl2() [T = ") - 1;
constexpr std::size_t prefix_size = sizeof("constexpr auto boost::hana::experimental::detail::type_name_impl2() [with T = ") - 1;
constexpr std::size_t suffix_size = sizeof("]") - 1;
#else
#error "No support for this compiler."
#endif

return {pretty_function + prefix_size, total_size - prefix_size - suffix_size};
cstring s{pretty_function + prefix_size, total_size - prefix_size - suffix_size};
return s;
}

template <typename T, std::size_t ...i>
Expand Down
20 changes: 0 additions & 20 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,6 @@ if (NOT Boost_FOUND)
list(APPEND EXCLUDED_PUBLIC_HEADERS ${PUBLIC_HEADERS_REQUIRING_BOOST})
endif()

# The experimental::type_name test is only supported on Clang and AppleClang >= 7.0
if (NOT (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"
OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang" AND
NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 7)))
list(APPEND EXCLUDED_PUBLIC_HEADERS
"boost/hana/experimental/type_name.hpp")
list(APPEND EXCLUDED_UNIT_TESTS "experimental/type_name.cpp")
endif()

# On Windows, Clang-cl emulates a MSVC bug that causes EBO not to be applied
# properly. We disable the tests that check for EBO.
if (MSVC AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
list(APPEND EXCLUDED_UNIT_TESTS
"detail/ebo.cpp"
"issues/github_202.cpp"
"pair/empty_storage.cpp"
"tuple/empty_member.cpp"
)
endif()


##############################################################################
# Generate tests that include each public header.
Expand Down
4 changes: 2 additions & 2 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ project boost/hana :

rule hana-all-tests {
local toolset =
<toolset>clang:<cxxflags>"-std=c++1y -pedantic -Wall -Wextra"
<toolset>darwin:<cxxflags>"-std=c++1y -pedantic -Wall -Wextra"
<toolset>clang:<cxxflags>"-std=c++1y -Wall -Wextra"
<toolset>darwin:<cxxflags>"-std=c++1y -Wall -Wextra"
[ requires
cxx14_constexpr
cxx14_decltype_auto
Expand Down
3 changes: 2 additions & 1 deletion test/detail/ebo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ template <typename ...Bases> struct __declspec(empty_bases) inherit : Bases... {
template <typename ...Bases> struct inherit : Bases... { };
#endif

#ifndef BOOST_HANA_CONFIG_CLANG_CL // MSVC doesn't implement EBO in all cases
static_assert(sizeof(inherit<>) == sizeof(inherit<ebo<idx<0>, empty<0>>>), "");
static_assert(sizeof(inherit<>) == sizeof(inherit<ebo<idx<0>, empty<0>>, ebo<idx<1>, empty<1>>>), "");
static_assert(sizeof(inherit<>) == sizeof(inherit<ebo<idx<0>, empty<0>>, ebo<idx<1>, empty<1>>, ebo<idx<2>, empty<2>>>), "");

#endif

int main() {
// Test default-construction
Expand Down
6 changes: 6 additions & 0 deletions test/issues/github_202.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)

#include <boost/hana/config.hpp>

#ifndef BOOST_HANA_CONFIG_CLANG_CL // EBO is not well supported on Windows

#include <boost/hana/integral_constant.hpp>
#include <boost/hana/pair.hpp>
#include <boost/hana/tuple.hpp>
Expand All @@ -23,4 +27,6 @@ static_assert(
sizeof(hana::tuple<Vector, Vector, Vector, Vector>)
, "");

#endif // BOOST_HANA_CONFIG_CLANG_CL

int main() { }

0 comments on commit f4896a1

Please sign in to comment.