Skip to content

Commit

Permalink
Merge pull request #937 from xtensor-stack/feature/all-inline-check
Browse files Browse the repository at this point in the history
Setup extra inliner check based on clang-query
  • Loading branch information
JohanMabille authored Jun 21, 2023
2 parents 7b46294 + f91153c commit ac04b31
Show file tree
Hide file tree
Showing 12 changed files with 207 additions and 162 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: clang-format
name: style check
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
Expand All @@ -14,3 +14,11 @@ jobs:
with:
clang-format-version: '13'
exclude-regex: 'doctest.h'
inlining-check:
runs-on: ubuntu-latest
name: Check inline keyword usage
steps:
- uses: actions/checkout@v2
- run: sudo apt install clang-tools
- run: sh ./test/check_inline_specifier.sh .

8 changes: 4 additions & 4 deletions include/xsimd/arch/xsimd_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ namespace xsimd
template <>
struct minvalue_impl<float>
{
static float get_value() noexcept
inline static float get_value() noexcept
{
return bit_cast<float>((uint32_t)0xff7fffff);
}
Expand All @@ -355,15 +355,15 @@ namespace xsimd
template <>
struct minvalue_impl<double>
{
static double get_value() noexcept
inline static double get_value() noexcept
{
return bit_cast<double>((uint64_t)0xffefffffffffffff);
}
};
}

template <class T>
inline constexpr T minvalue() noexcept
constexpr T minvalue() noexcept
{
return T(detail::minvalue_impl<typename T::value_type>::get_value());
}
Expand All @@ -373,7 +373,7 @@ namespace xsimd
***************************/

template <class T>
inline constexpr T maxvalue() noexcept
constexpr T maxvalue() noexcept
{
return T(std::numeric_limits<typename T::value_type>::max());
}
Expand Down
28 changes: 14 additions & 14 deletions include/xsimd/arch/xsimd_scalar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,14 +1001,14 @@ namespace xsimd

namespace detail
{
#define XSIMD_HASSINCOS_TRAIT(func) \
template <class S> \
struct has##func \
{ \
template <class T> \
static auto get(T* ptr) -> decltype(func(std::declval<T>(), std::declval<T*>(), std::declval<T*>()), std::true_type {}); \
static std::false_type get(...); \
static constexpr bool value = decltype(get((S*)nullptr))::value; \
#define XSIMD_HASSINCOS_TRAIT(func) \
template <class S> \
struct has##func \
{ \
template <class T> \
static inline auto get(T* ptr) -> decltype(func(std::declval<T>(), std::declval<T*>(), std::declval<T*>()), std::true_type {}); \
static inline std::false_type get(...); \
static constexpr bool value = decltype(get((S*)nullptr))::value; \
}

#define XSIMD_HASSINCOS(func, T) has##func<T>::value
Expand All @@ -1021,21 +1021,21 @@ namespace xsimd
struct generic_sincosf
{
template <class T>
typename std::enable_if<XSIMD_HASSINCOS(sincosf, T), void>::type
inline typename std::enable_if<XSIMD_HASSINCOS(sincosf, T), void>::type
operator()(float val, T& s, T& c)
{
sincosf(val, &s, &c);
}

template <class T>
typename std::enable_if<!XSIMD_HASSINCOS(sincosf, T) && XSIMD_HASSINCOS(__sincosf, T), void>::type
inline typename std::enable_if<!XSIMD_HASSINCOS(sincosf, T) && XSIMD_HASSINCOS(__sincosf, T), void>::type
operator()(float val, T& s, T& c)
{
__sincosf(val, &s, &c);
}

template <class T>
typename std::enable_if<!XSIMD_HASSINCOS(sincosf, T) && !XSIMD_HASSINCOS(__sincosf, T), void>::type
inline typename std::enable_if<!XSIMD_HASSINCOS(sincosf, T) && !XSIMD_HASSINCOS(__sincosf, T), void>::type
operator()(float val, T& s, T& c)
{
s = std::sin(val);
Expand All @@ -1046,21 +1046,21 @@ namespace xsimd
struct generic_sincos
{
template <class T>
typename std::enable_if<XSIMD_HASSINCOS(sincos, T), void>::type
inline typename std::enable_if<XSIMD_HASSINCOS(sincos, T), void>::type
operator()(double val, T& s, T& c)
{
sincos(val, &s, &c);
}

template <class T>
typename std::enable_if<!XSIMD_HASSINCOS(sincos, T) && XSIMD_HASSINCOS(__sincos, T), void>::type
inline typename std::enable_if<!XSIMD_HASSINCOS(sincos, T) && XSIMD_HASSINCOS(__sincos, T), void>::type
operator()(double val, T& s, T& c)
{
__sincos(val, &s, &c);
}

template <class T>
typename std::enable_if<!XSIMD_HASSINCOS(sincos, T) && !XSIMD_HASSINCOS(__sincos, T), void>::type
inline typename std::enable_if<!XSIMD_HASSINCOS(sincos, T) && !XSIMD_HASSINCOS(__sincos, T), void>::type
operator()(double val, T& s, T& c)
{
s = std::sin(val);
Expand Down
10 changes: 5 additions & 5 deletions include/xsimd/config/xsimd_arch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ namespace xsimd
}

template <class F>
static void for_each(F&& f) noexcept
static inline void for_each(F&& f) noexcept
{
(void)std::initializer_list<bool> { (f(Archs {}), true)... };
}
Expand Down Expand Up @@ -217,14 +217,14 @@ namespace xsimd
F functor;

template <class Arch, class... Tys>
auto walk_archs(arch_list<Arch>, Tys&&... args) noexcept -> decltype(functor(Arch {}, std::forward<Tys>(args)...))
inline auto walk_archs(arch_list<Arch>, Tys&&... args) noexcept -> decltype(functor(Arch {}, std::forward<Tys>(args)...))
{
assert(Arch::available() && "At least one arch must be supported during dispatch");
return functor(Arch {}, std::forward<Tys>(args)...);
}

template <class Arch, class ArchNext, class... Archs, class... Tys>
auto walk_archs(arch_list<Arch, ArchNext, Archs...>, Tys&&... args) noexcept -> decltype(functor(Arch {}, std::forward<Tys>(args)...))
inline auto walk_archs(arch_list<Arch, ArchNext, Archs...>, Tys&&... args) noexcept -> decltype(functor(Arch {}, std::forward<Tys>(args)...))
{
if (Arch::version() <= best_arch_found)
return functor(Arch {}, std::forward<Tys>(args)...);
Expand All @@ -233,14 +233,14 @@ namespace xsimd
}

public:
dispatcher(F f) noexcept
inline dispatcher(F f) noexcept
: best_arch_found(available_architectures().best)
, functor(f)
{
}

template <class... Tys>
auto operator()(Tys&&... args) noexcept -> decltype(functor(default_arch {}, std::forward<Tys>(args)...))
inline auto operator()(Tys&&... args) noexcept -> decltype(functor(default_arch {}, std::forward<Tys>(args)...))
{
return walk_archs(ArchList {}, std::forward<Tys>(args)...);
}
Expand Down
2 changes: 1 addition & 1 deletion include/xsimd/config/xsimd_cpuid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace xsimd
// version number of the best arch available
unsigned best;

supported_arch() noexcept
inline supported_arch() noexcept
{
memset(this, 0, sizeof(supported_arch));

Expand Down
38 changes: 19 additions & 19 deletions include/xsimd/memory/xsimd_aligned_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,43 +59,43 @@ namespace xsimd
using other = aligned_allocator<U, Align>;
};

aligned_allocator() noexcept;
aligned_allocator(const aligned_allocator& rhs) noexcept;
inline aligned_allocator() noexcept;
inline aligned_allocator(const aligned_allocator& rhs) noexcept;

template <class U>
aligned_allocator(const aligned_allocator<U, Align>& rhs) noexcept;
inline aligned_allocator(const aligned_allocator<U, Align>& rhs) noexcept;

~aligned_allocator();
inline ~aligned_allocator();

pointer address(reference) noexcept;
const_pointer address(const_reference) const noexcept;
inline pointer address(reference) noexcept;
inline const_pointer address(const_reference) const noexcept;

pointer allocate(size_type n, const void* hint = 0);
void deallocate(pointer p, size_type n);
inline pointer allocate(size_type n, const void* hint = 0);
inline void deallocate(pointer p, size_type n);

size_type max_size() const noexcept;
size_type size_max() const noexcept;
inline size_type max_size() const noexcept;
inline size_type size_max() const noexcept;

template <class U, class... Args>
void construct(U* p, Args&&... args);
inline void construct(U* p, Args&&... args);

template <class U>
void destroy(U* p);
inline void destroy(U* p);
};

template <class T1, size_t Align1, class T2, size_t Align2>
bool operator==(const aligned_allocator<T1, Align1>& lhs,
const aligned_allocator<T2, Align2>& rhs) noexcept;
inline bool operator==(const aligned_allocator<T1, Align1>& lhs,
const aligned_allocator<T2, Align2>& rhs) noexcept;

template <class T1, size_t Align1, class T2, size_t Align2>
bool operator!=(const aligned_allocator<T1, Align1>& lhs,
const aligned_allocator<T2, Align2>& rhs) noexcept;
inline bool operator!=(const aligned_allocator<T1, Align1>& lhs,
const aligned_allocator<T2, Align2>& rhs) noexcept;

void* aligned_malloc(size_t size, size_t alignment);
void aligned_free(void* ptr);
inline void* aligned_malloc(size_t size, size_t alignment);
inline void aligned_free(void* ptr);

template <class T>
size_t get_alignment_offset(const T* p, size_t size, size_t block_size);
inline size_t get_alignment_offset(const T* p, size_t size, size_t block_size);

/************************************
* aligned_allocator implementation *
Expand Down
2 changes: 1 addition & 1 deletion include/xsimd/types/xsimd_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ namespace xsimd
* @return a batch of positive infinity
*/
template <class B>
B infinity()
inline B infinity()
{
using T = typename B::value_type;
using A = typename B::arch_type;
Expand Down
Loading

0 comments on commit ac04b31

Please sign in to comment.