Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warnings options #90

Merged
merged 15 commits into from
May 28, 2024
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ IncludeCategories:
- Regex: '".+"'
Priority: 5
IndentCaseLabels: true
IndentPPDirectives: AfterHash
IndentWidth: '4'
IndentWrappedFunctionNames: false
InsertBraces: true
Expand Down
7 changes: 7 additions & 0 deletions include/sparrow/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,14 @@ namespace sparrow
return visit_storage(
[n, p](auto& allocator)
{
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmismatched-new-delete"
#endif
return allocator.deallocate(p, n);
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
}
);
}
Expand Down
3 changes: 2 additions & 1 deletion include/sparrow/array_data.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Man Group Operations Limited

Check notice on line 1 in include/sparrow/array_data.hpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on include/sparrow/array_data.hpp

File include/sparrow/array_data.hpp does not conform to Custom style guidelines. (lines 25)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -18,12 +18,13 @@
#include <optional>
#include <vector>

#include "sparrow/contracts.hpp"
#include "sparrow/buffer.hpp"
#include "sparrow/contracts.hpp"
#include "sparrow/data_type.hpp"
#include "sparrow/dynamic_bitset.hpp"
#include "sparrow/memory.hpp"


namespace sparrow
{
/**
Expand Down
16 changes: 10 additions & 6 deletions include/sparrow/buffer.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Man Group Operations Limited

Check notice on line 1 in include/sparrow/buffer.hpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on include/sparrow/buffer.hpp

File include/sparrow/buffer.hpp does not conform to Custom style guidelines. (lines 26)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -20,11 +20,12 @@
#include <iterator>
#include <stdexcept>

#include "sparrow/contracts.hpp"
#include "sparrow/allocator.hpp"
#include "sparrow/contracts.hpp"
#include "sparrow/iterator.hpp"
#include "sparrow/mp_utils.hpp"


namespace sparrow
{

Expand Down Expand Up @@ -312,7 +313,7 @@
template <class T>
buffer_base<T>::~buffer_base()
{
deallocate(m_data.p_begin, (m_data.p_storage_end - m_data.p_begin));
deallocate(m_data.p_begin, static_cast<size_type>(m_data.p_storage_end - m_data.p_begin));
}

template <class T>
Expand Down Expand Up @@ -414,7 +415,7 @@
template <class T>
template <class It, allocator A>
constexpr buffer<T>::buffer(It first, It last, const A& a)
: base_type(check_init_length(std::distance(first, last), a), a)
: base_type(check_init_length(static_cast<size_type>(std::distance(first, last)), a), a)
{
get_data().p_end = copy_initialize(first, last, get_data().p_begin, get_allocator());
}
Expand Down Expand Up @@ -666,7 +667,10 @@
std::make_move_iterator(get_data().p_end)
);
destroy(get_data().p_begin, get_data().p_end, get_allocator());
this->deallocate(get_data().p_begin, get_data().p_storage_end - get_data().p_begin);
this->deallocate(
get_data().p_begin,
static_cast<size_type>(get_data().p_storage_end - get_data().p_begin)
);
this->assign_storage(tmp, old_size, new_cap);
}
}
Expand Down Expand Up @@ -744,7 +748,7 @@
constexpr void buffer<T>::assign_range_impl(It first, It last, std::forward_iterator_tag)
{
const size_type sz = size();
const size_type len = std::distance(first, last);
const size_type len = static_cast<size_type>(std::distance(first, last));
if (len > capacity())
{
check_init_length(len, get_allocator());
Expand Down Expand Up @@ -804,7 +808,7 @@
template <class T>
constexpr auto buffer<T>::max_size_impl(const allocator_type& a) noexcept -> size_type
{
const size_type diff_max = std::numeric_limits<difference_type>::max();
const size_type diff_max = static_cast<size_type>(std::numeric_limits<difference_type>::max());
const size_type alloc_max = std::allocator_traits<allocator_type>::max_size(a);
return (std::min)(diff_max, alloc_max);
}
Expand Down
15 changes: 8 additions & 7 deletions include/sparrow/buffer_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include "sparrow/buffer.hpp"
#include "sparrow/contracts.hpp"

namespace sparrow
{
Expand All @@ -23,7 +24,7 @@ namespace sparrow
*
* Although this class looks very similar to std::span, it provides
* methods that are missing in C++20 std::span (like cbegin / cend),
* and additional std::vector-like APIs.
* and additional std::vector-like APIs.
*/
template <class T>
class buffer_view
Expand Down Expand Up @@ -130,42 +131,42 @@ namespace sparrow
template <class T>
auto buffer_view<T>::operator[](size_type pos) -> reference
{
assert(pos < size());
SPARROW_ASSERT_TRUE(pos < size());
return data()[pos];
}

template <class T>
auto buffer_view<T>::operator[](size_type pos) const -> const_reference
{
assert(pos < size());
SPARROW_ASSERT_TRUE(pos < size());
return data()[pos];
}

template <class T>
auto buffer_view<T>::front() -> reference
{
assert(!empty());
SPARROW_ASSERT_TRUE(!empty());
return data()[0];
}

template <class T>
auto buffer_view<T>::front() const -> const_reference
{
assert(!empty());
SPARROW_ASSERT_TRUE(!empty());
return data()[0];
}

template <class T>
auto buffer_view<T>::back() -> reference
{
assert(!empty());
SPARROW_ASSERT_TRUE(!empty());
return data()[m_size - 1];
}

template <class T>
auto buffer_view<T>::back() const -> const_reference
{
assert(!empty());
SPARROW_ASSERT_TRUE(!empty());
return data()[m_size - 1];
}

Expand Down
Loading
Loading