Skip to content

Commit

Permalink
Merge pull request #334 from DARMA-tasking/333-add-more-warnings-and-…
Browse files Browse the repository at this point in the history
…then-eliminate-their-sources

333 add more warnings and then eliminate their sources
  • Loading branch information
nlslatt authored Apr 9, 2024
2 parents ce0c149 + a749a69 commit 5480204
Show file tree
Hide file tree
Showing 26 changed files with 57 additions and 51 deletions.
4 changes: 4 additions & 0 deletions cmake/turn_on_warnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ if(NOT hasParent)
enable_cxx_compiler_flag_if_supported("-Wall")
enable_cxx_compiler_flag_if_supported("-pedantic")
enable_cxx_compiler_flag_if_supported("-Wno-unknown-pragmas")
enable_cxx_compiler_flag_if_supported("-Wextra")
enable_cxx_compiler_flag_if_supported("-Wshadow")
enable_cxx_compiler_flag_if_supported("-Wnon-virtual-dtor")
enable_cxx_compiler_flag_if_supported("-Wsuggest-override")
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand Down
4 changes: 2 additions & 2 deletions examples/checkpoint_example_polymorphic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct MyObj : ::checkpoint::SerializableDerived<MyObj, MyBase> {
explicit MyObj(::checkpoint::SERIALIZE_CONSTRUCT_TAG){}

template <typename SerializerT>
void serialize(SerializerT& s) {
void serialize(SerializerT&) {
printf("MyObj: serialize\n");
}

Expand All @@ -85,7 +85,7 @@ struct MyObj2 : ::checkpoint::SerializableDerived<MyObj2, MyBase> {
explicit MyObj2(::checkpoint::SERIALIZE_CONSTRUCT_TAG) {}

template <typename SerializerT>
void serialize(SerializerT& s) {
void serialize(SerializerT&) {
printf("MyObj2: serialize\n");
}
void test() override {
Expand Down
4 changes: 2 additions & 2 deletions examples/checkpoint_example_polymorphic_macro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct MyObj : public MyBase {
checkpoint_virtual_serialize_derived_from(MyBase)

template <typename SerializerT>
void serialize(SerializerT& s) {
void serialize(SerializerT&) {
printf("MyObj: serialize\n");
}

Expand All @@ -97,7 +97,7 @@ struct MyObj2 : public MyBase {
checkpoint_virtual_serialize_derived_from(MyBase)

template <typename SerializerT>
void serialize(SerializerT& s) {
void serialize(SerializerT&) {
printf("MyObj2: serialize\n");
}
void test() override {
Expand Down
4 changes: 2 additions & 2 deletions examples/checkpoint_example_polymorphic_macro_nonintrusive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ void serialize(S& s, MyBase& obj) {
}

template <typename SerializerT>
void serialize(SerializerT& s, MyObj& obj) {
void serialize(SerializerT&, MyObj&) {
printf("MyObj: serialize\n");
}

template <typename SerializerT>
void serialize(SerializerT& s, MyObj2& obj) {
void serialize(SerializerT&, MyObj2&) {
printf("MyObj2: serialize\n");
}

Expand Down
4 changes: 2 additions & 2 deletions examples/checkpoint_example_polymorphic_nonintrusive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ void serialize(S& s, MyBase& obj) {
}

template <typename SerializerT>
void serialize(SerializerT& s, MyObj& obj) {
void serialize(SerializerT&, MyObj&) {
printf("MyObj: serialize\n");
}

template <typename SerializerT>
void serialize(SerializerT& s, MyObj2& obj) {
void serialize(SerializerT&, MyObj2&) {
printf("MyObj2: serialize\n");
}

Expand Down
4 changes: 2 additions & 2 deletions examples/checkpoint_example_traversal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct TestObject {
struct PrintBytesTraverse : checkpoint::BaseSerializer {
PrintBytesTraverse() : checkpoint::BaseSerializer(checkpoint::eSerializationMode::None) { }

void contiguousBytes(void* ptr, std::size_t size, std::size_t num_elms) {
void contiguousBytes(void*, std::size_t size, std::size_t num_elms) {
printf("PrintBytesTraverse: size=%zu, num_elms=%zu\n", size, num_elms);
}
};
Expand Down Expand Up @@ -114,7 +114,7 @@ struct CustomDispatch {
// skip that overload
template <typename SerializerT, typename U>
struct CustomDispatch<SerializerT, std::vector<U>> {
static void serializeNonIntrusive(SerializerT& s, std::vector<U>& t) {
static void serializeNonIntrusive(SerializerT&, std::vector<U>& t) {
// Do something special here: e.g., an RDMA for the vector during packing
printf("Traversing vector: size=%zu\n", t.size());
for (std::size_t i = 0; i < t.size(); i++) {
Expand Down
4 changes: 2 additions & 2 deletions examples/checkpoint_example_traversal_nonintrusive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void serialize(Serializer& s, TestObject& obj) {
struct PrintBytesTraverse : checkpoint::BaseSerializer {
PrintBytesTraverse() : checkpoint::BaseSerializer(checkpoint::eSerializationMode::None) { }

void contiguousBytes(void* ptr, std::size_t size, std::size_t num_elms) {
void contiguousBytes(void*, std::size_t size, std::size_t num_elms) {
printf("PrintBytesTraverse: size=%zu, num_elms=%zu\n", size, num_elms);
}
};
Expand Down Expand Up @@ -126,7 +126,7 @@ struct CustomDispatch {
// skip that overload
template <typename SerializerT, typename U>
struct CustomDispatch<SerializerT, std::vector<U>> {
static void serializeNonIntrusive(SerializerT& s, std::vector<U>& t) {
static void serializeNonIntrusive(SerializerT&, std::vector<U>& t) {
// Do something special here: e.g., an RDMA for the vector during packing
printf("Traversing vector: size=%zu\n", t.size());
for (std::size_t i = 0; i < t.size(); i++) {
Expand Down
4 changes: 2 additions & 2 deletions src/checkpoint/buffer/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ namespace checkpoint { namespace buffer {
using SerializedInfo = ::checkpoint::SerializedInfo;

struct Buffer : SerializedInfo {
virtual SerialByteType* getBuffer() const = 0;
virtual SerialSizeType getSize() const = 0;
virtual SerialByteType* getBuffer() const override = 0;
virtual SerialSizeType getSize() const override = 0;
virtual ~Buffer() { }
};

Expand Down
2 changes: 1 addition & 1 deletion src/checkpoint/container/list_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ inline typename std::enable_if_t<
std::is_same<Serializer, checkpoint::Footprinter>::value, void
>
deserializeOrderedElems(
Serializer& s, ContainerT& cont, typename ContainerT::size_type size
Serializer&, ContainerT&, typename ContainerT::size_type
) { }

template <typename Serializer, typename ContainerT>
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoint/container/map_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ inline typename std::enable_if_t<
std::is_same<Serializer, checkpoint::Footprinter>::value,
void
> deserializeEmplaceElems(
Serializer& s, ContainerT& cont, typename ContainerT::size_type size
Serializer&, ContainerT&, typename ContainerT::size_type
) { }

template <typename Serializer, typename ContainerT>
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoint/container/variant_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ template <>
struct SerializeEntry<> {
template <typename SerializerT, typename VariantT>
static void serialize(
SerializerT& s, VariantT& v, std::size_t entry, std::size_t cur
SerializerT&, VariantT&, std::size_t, std::size_t
) {
// base case
}
Expand Down
6 changes: 3 additions & 3 deletions src/checkpoint/container/view_equality.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,21 @@ struct ViewEqualityStatic {
}

template <typename AnyT, typename... Args>
bool operator()(Kokkos::View<AnyT,Args...> const& v, Callable eq) {
bool operator()(Kokkos::View<AnyT,Args...> const&, Callable) {
// No static dimension to check against dynamic dimension, return true
return true;
}

template <typename AnyT, typename... Args>
bool operator()(
Kokkos::Experimental::DynamicView<AnyT,Args...> const& v, Callable eq
Kokkos::Experimental::DynamicView<AnyT,Args...> const&, Callable
) {
// No static dimension to check against dynamic dimension, return true
return true;
}

template <typename AnyT, typename... Args>
bool operator()(Kokkos::DynRankView<AnyT,Args...> const& v, Callable eq) {
bool operator()(Kokkos::DynRankView<AnyT,Args...> const&, Callable) {
// No static dimension to check against dynamic dimension, return true
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoint/container/view_traits_extract.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ template <
struct CountDims {
using BaseT = typename std::decay<T>::type;
static constexpr size_t dynamic = 0;
static int numDims(ViewType const& view) { return 0; }
static int numDims(ViewType const&) { return 0; }
};

template <typename ViewType, typename T>
Expand Down
10 changes: 5 additions & 5 deletions src/checkpoint/container/view_traverse_ndim.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ struct TraverseRecurImplBase {
template <typename U = ViewT>
static CountType applyImpl(
ViewT const& view, unsigned nd, TupleT idx, Callable call,
ViewIsTuple<U>* x_ = nullptr
ViewIsTuple<U>* = nullptr
) {
auto const ex1 = std::get<0>(view).extent(nd-d);
auto const ex2 = std::get<1>(view).extent(nd-d);
Expand All @@ -149,7 +149,7 @@ struct TraverseRecurImplBase {
template <typename U = ViewT>
static CountType applyImpl(
ViewT const& view, unsigned nd, TupleT idx, Callable call,
ViewNotTuple<U>* x_ = nullptr
ViewNotTuple<U>* = nullptr
) {
CountType neq = 0;
for (SizeType i = 0; i < view.extent(nd-d); i++) {
Expand Down Expand Up @@ -204,7 +204,7 @@ struct TraverseRecurImpl {
// Unwind the inner tuple for operator()(...)
template <typename ViewU, std::size_t... I>
static GetBaseType<ViewU>& expandTupleToOp(
ViewU const& view, TupleT tup, std::index_sequence<I...> idx
ViewU const& view, TupleT tup, std::index_sequence<I...>
) {
return view.operator()(std::get<I>(tup)...);
}
Expand All @@ -228,15 +228,15 @@ struct TraverseRecurImpl {
// Test whether the ViewT is actually a std::tuple<Kokkos::View<T>...>
template <typename U = ViewT>
static bool dispatchViewType(
ViewT const& view, Callable call, TupleT tup, ViewIsTuple<U>* x_ = nullptr
ViewT const& view, Callable call, TupleT tup, ViewIsTuple<U>* = nullptr
) {
constexpr auto size = std::tuple_size<ViewT>::value;
return dispatchViewTuple(view,call,tup,std::make_index_sequence<size>{});
}

template <typename U = ViewT>
static bool dispatchViewType(
ViewT const& view, Callable call, TupleT tup, ViewNotTuple<U>* x_ = nullptr
ViewT const& view, Callable call, TupleT tup, ViewNotTuple<U>* = nullptr
) {
call(expandTupleToOp(view,tup));
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/checkpoint/dispatch/clean_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ struct CleanType {
}

template <typename U = T>
static NonConstRefT* apply1(T* val, isConst<U>* x = nullptr) {
static NonConstRefT* apply1(T* val, isConst<U>* = nullptr) {
return reinterpret_cast<NonConstRefT*>(const_cast<NonConstT*>(val));
}

template <typename U = T>
static NonConstRefT* apply1(T* val, isNotConst<U>* x = nullptr) {
static NonConstRefT* apply1(T* val, isNotConst<U>* = nullptr) {
return reinterpret_cast<NonConstRefT*>(val);
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/checkpoint/dispatch/dispatch_serializer_byte.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ struct SerializerDispatchByte {

template <typename U = T>
void operator()(
SerializerT& s, T* val, SerialSizeType num, isByteCopyType<U>* x = nullptr
SerializerT& s, T* val, SerialSizeType num, isByteCopyType<U>* = nullptr
) {
s.contiguousTyped(s, val, num);
}

template <typename U = T>
void operator()(
SerializerT& s, T* val, SerialSizeType num, isNotByteCopyType<U>* x = nullptr
SerializerT& s, T* val, SerialSizeType num, isNotByteCopyType<U>* = nullptr
) {
SerializerDispatchNonByte<SerializerT, T, Dispatcher> dispatch;
dispatch(s, val, num);
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoint/dispatch/dispatch_serializer_nonbyte.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct SerializerDispatchNonByte {

template <typename U = T>
void applyElm(
SerializerT& s, T* val, hasNotSplitSerialize<U>* = nullptr
SerializerT&, T*, hasNotSplitSerialize<U>* = nullptr
) { }

template <typename U = T>
Expand Down
4 changes: 2 additions & 2 deletions src/checkpoint/dispatch/reconstructor.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct Reconstructor {

// Fail, no valid option to constructing T
template <typename U = T>
static T* constructDefault(void* buf, isNotDefaultConsType<U>* = nullptr) {
static T* constructDefault(void*, isNotDefaultConsType<U>* = nullptr) {
static_assert(
SerializableTraits<U, void>::is_tagged_constructible or
SerializableTraits<U, void>::is_reconstructible or
Expand Down Expand Up @@ -152,7 +152,7 @@ struct Reconstructor {
}

template <typename U = T>
static T* constructAllowFailImpl(void* buf, isNotConstructible<U>* = nullptr) {
static T* constructAllowFailImpl(void*, isNotConstructible<U>* = nullptr) {
constexpr int max_buffer_length = 32768;
std::unique_ptr<char[]> msg = std::make_unique<char[]>(max_buffer_length);
snprintf(
Expand Down
2 changes: 2 additions & 0 deletions src/checkpoint/dispatch/vrt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ namespace checkpoint { namespace dispatch { namespace vrt {
template <typename BaseT>
struct SerializableBase {
checkpoint_virtual_serialize_root()

virtual ~SerializableBase() {}
};

}}} /* end namespace checkpoint::dispatch::vrt */
Expand Down
8 changes: 4 additions & 4 deletions src/checkpoint/dispatch/vrt/virtual_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct SerializeVirtualTypeIfNeeded<
>
>
{
static dispatch::vrt::TypeIdx apply(SerializerT& s, T* target) {
static dispatch::vrt::TypeIdx apply(SerializerT&, T*) {
// no type idx needed in this case
return dispatch::vrt::no_type_idx;
}
Expand Down Expand Up @@ -149,7 +149,7 @@ struct ReconstructAsVirtualIfNeeded<
not std::is_same<SerializerT, checkpoint::Footprinter>::value
>
> {
static T* apply(SerializerT& s, dispatch::vrt::TypeIdx entry) {
static T* apply(SerializerT&, dispatch::vrt::TypeIdx) {
// no type idx needed in this case, static construction in default case
auto t = std::allocator<T>{}.allocate(1);
return dispatch::Reconstructor<T>::construct(t);
Expand All @@ -165,7 +165,7 @@ struct ReconstructAsVirtualIfNeeded<
std::is_same<SerializerT, checkpoint::Footprinter>::value
>
> {
static T* apply(SerializerT& s, dispatch::vrt::TypeIdx entry) { return nullptr; }
static T* apply(SerializerT&, dispatch::vrt::TypeIdx) { return nullptr; }
};

template <typename T, typename SerializerT>
Expand All @@ -176,7 +176,7 @@ struct ReconstructAsVirtualIfNeeded<
dispatch::vrt::VirtualSerializeTraits<T>::has_virtual_serialize
>
> {
static T* apply(SerializerT& s, dispatch::vrt::TypeIdx entry) {
static T* apply(SerializerT&, dispatch::vrt::TypeIdx entry) {
using BaseT = ::checkpoint::dispatch::vrt::checkpoint_base_type_t<T>;

// use type idx here, registration needed for proper type re-construction
Expand Down
10 changes: 5 additions & 5 deletions src/checkpoint/serializers/base_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ struct BaseSerializer {
* \param[in] t an element
*/
template<typename T>
void countBytes(const T& t) {}
void countBytes(T const&) {}

/**
* \brief Add bytes for footprinting---default empty implementation
*
* \param[in] s the amount of bytes to add
*/
void addBytes(std::size_t s) {}
void addBytes(std::size_t) {}

/**
* \brief Add contiguous bytes to the sizer
Expand All @@ -142,7 +142,7 @@ struct BaseSerializer {
* \param[in] size the number of bytes for each element
* \param[in] num_elms the number of elements
*/
void contiguousBytes(void* ptr, SerialSizeType size, SerialSizeType num_elms) {}
void contiguousBytes(void*, SerialSizeType, SerialSizeType) {}

/**
* \brief Returns size of buffer (in bytes) used during given serialization
Expand Down Expand Up @@ -170,7 +170,7 @@ struct BaseSerializer {
* \note Used/implemented in serialization sanitizer.
*/
template <typename... Args>
void skip(Args&&... args) { }
void skip(Args&&...) { }

/**
* \brief Get a buffer if it is associated with the serializer
Expand All @@ -187,7 +187,7 @@ struct BaseSerializer {
*
* \return the current spot
*/
SerialByteType* getSpotIncrement(SerialSizeType const inc) { return nullptr; }
SerialByteType* getSpotIncrement(SerialSizeType const) { return nullptr; }

/**
* \brief Check if virtual serialization is disabled
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoint/serializers/stream_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace checkpoint {

template<typename StreamT = std::ostream>
struct StreamPacker : BaseSerializer {
StreamPacker(SerialSizeType size, StreamT& m_stream)
StreamPacker(SerialSizeType, StreamT& m_stream)
: BaseSerializer(ModeType::Packing), stream(m_stream) {
//Nothing to do with the size.
//Pre-allocating a buffer for the stream has more problems than solutions.
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_footprinter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct TestBase {
};

struct TestDerived2 : TestBase {
explicit TestDerived2(int i) {}
explicit TestDerived2(int) {}
explicit TestDerived2(SERIALIZE_CONSTRUCT_TAG) {}

checkpoint_virtual_serialize_derived_from(TestBase)
Expand Down
Loading

0 comments on commit 5480204

Please sign in to comment.