Skip to content

Commit

Permalink
Corrected most clang related warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Moncada authored and Victor Moncada committed Jan 9, 2024
1 parent 10ee70b commit 22c72e0
Show file tree
Hide file tree
Showing 54 changed files with 567 additions and 322 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ option(HEADER_ONLY "Do not build library, use header-only version" OFF)
option(ENABLE_AVX2 "Enable AVX2 support" ON)
option(BUILD_TESTS "Build tests" OFF)
option(BUILD_BENCHS "Build benchmarks" OFF)
option(NO_WARNINGS "Treat warnings as errors" OFF)

set(PROJECT_HEADER_ONLY 1)

Expand Down Expand Up @@ -54,6 +55,16 @@ if(NOT HEADER_ONLY)
target_compile_options(seq PRIVATE -march=native)
endif()

if(NO_WARNINGS)
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(seq PRIVATE /WX /W3 )
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(seq PRIVATE -Werror -Wall -Wno-c++98-compat -Wno-c++98-compat-pedantic)
else()
target_compile_options(seq PRIVATE -Werror -Wall)
endif()
endif()

target_include_directories(seq PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/seq>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/seq/internal>"
Expand Down
2 changes: 2 additions & 0 deletions benchs/bench_concurrent_hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,13 @@ void test_concurrent_hash_maps(size_t count, const Gen & gen)

test_concurrent_map<K, libcuckoo::cuckoohash_map<K, size_t, seq::hasher<K>, std::equal_to<K>> >(count, "libcuckoo::cuckoohash_map", gen);

#ifdef NDEBUG
#ifdef TBB_FOUND
test_concurrent_map<K, tbb::concurrent_hash_map<K, size_t, my_tbb_hash_compare<K> > >(count, "tbb::concurrent_hash_map", gen); //safe erase

//test_concurrent_map<K, tbb::concurrent_unordered_map <K, size_t> >(count, "tbb::concurrent_unordered_map ", gen); //safe iteration
#endif
#endif

#ifdef SEQ_HAS_CPP_17
test_concurrent_map < K, gtl::parallel_flat_hash_map<K, size_t, seq::hasher<K>, std::equal_to<K>, std::allocator<std::pair<K, size_t>>, 5, std::shared_mutex > >(count, "gtl::parallel_flat_hash_map", gen);
Expand Down
7 changes: 3 additions & 4 deletions benchs/bench_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

int bench_format(int, char ** const)
{

using namespace seq;

// Generate 4M double values
Expand Down Expand Up @@ -37,7 +36,7 @@ int bench_format(int, char ** const)
}
size_t el = tock_ms();
std::cout << "Write table with streams: " << el << " ms" << std::endl;


// Build the same table with format module

Expand All @@ -50,7 +49,7 @@ int bench_format(int, char ** const)
el = tock_ms();
std::cout << "Write table with seq formatting module: " << el << " ms" << std::endl;


// Compare to std::format for C++20 compilers
#ifdef SEQ_HAS_CPP_20
tick();
Expand All @@ -71,7 +70,7 @@ int bench_format(int, char ** const)
oss << f2(vec_d[i]);
el = tock_ms();
std::cout << "Write left-aligned double with seq::fmt: " << el << " ms" << std::endl;



// use std::ostream::bad() to make sure the above tests are not simply ignored by the compiler
Expand Down
2 changes: 1 addition & 1 deletion benchs/bench_hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ struct LaunchTest
sum += to_size_t(*it);
}*/
if (set.count(failed[i])) {
SEQ_TEST(false)
SEQ_TEST(false);
}
else
++sum;
Expand Down
2 changes: 1 addition & 1 deletion benchs/bench_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ int bench_map(int , char ** const)
size_t idx = i & 3U;
switch (idx) {
case 0:return seq::r_any(i * UINT64_C(0xc4ceb9fe1a85ec53));
case 1:return seq::r_any((double)i * UINT64_C(0xc4ceb9fe1a85ec53));
case 1:return seq::r_any((double)i * (double)UINT64_C(0xc4ceb9fe1a85ec53));
default:return seq::r_any(generate_random_string<seq::tstring>(13, true));
}
}
Expand Down
4 changes: 4 additions & 0 deletions benchs/bench_tiered_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,22 @@ void test_tiered_vector_algorithms(size_t count = 5000000)

tick();
auto it1 = std::unique(vec.begin(), vec.end());
(void)it1;
vec_t = tock_ms();

tick();
auto it2 = std::unique(deq.begin(), deq.end());
(void)it2;
deq_t = tock_ms();

tick();
auto it3 = std::unique(tvec.begin(), tvec.end());
(void)it3;
tvec_t = tock_ms();

tick();
auto it4 = std::unique(cvec.begin(), cvec.end());
(void)it4;
cvec_t = tock_ms();

assert_equal(deq, tvec);
Expand Down
2 changes: 1 addition & 1 deletion benchs/bench_tiny_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct Convert
String wc;
wc.resize(cSize);

size_t cSize1;
//size_t cSize1;
//mbstowcs_s(&cSize1, (wchar_t*)&wc[0], cSize, value, cSize);
mbstowcs((wchar_t*)&wc[0], value, cSize);

Expand Down
4 changes: 2 additions & 2 deletions seq.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
#define SEQ_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define SEQ_VERSION "@PROJECT_VERSION@"

#define __SEQ_IS_HEADER_ONLY @PROJECT_HEADER_ONLY@
#define SEQ_DETECT_IS_HEADER_ONLY @PROJECT_HEADER_ONLY@

#if __SEQ_IS_HEADER_ONLY == 1
#if SEQ_DETECT_IS_HEADER_ONLY == 1
#ifndef SEQ_HEADER_ONLY
#define SEQ_HEADER_ONLY
#endif
Expand Down
59 changes: 54 additions & 5 deletions seq/any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,14 @@ namespace seq
/// @brief Stream object to std::ostream or throw std::bad_function_call
template<class T>
SEQ_ALWAYS_INLINE typename std::enable_if< is_ostreamable<T>::value,void>::type ostream_any(std::ostream& oss, const void* in){
#if defined( __clang__ ) && defined(_MSC_VER)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmicrosoft-cast"
#endif
oss << *static_cast<const T*>(in);
#if defined( __clang__ ) && defined(_MSC_VER)
#pragma clang diagnostic pop
#endif
}
template<class T>
SEQ_ALWAYS_INLINE typename std::enable_if< !is_ostreamable<T>::value, void>::type ostream_any(std::ostream& , const void* ){
Expand All @@ -575,7 +582,7 @@ namespace seq
/// @brief Compare equal 2 objects of same type
template<class T>
SEQ_ALWAYS_INLINE typename std::enable_if< is_equal_comparable<T>::value, bool>::type compare_equal_any(const void* a, const void* b) {
return *static_cast<const T*>(a) == *static_cast<const T*>(b);
SEQ_COMPARE_FLOAT(return *static_cast<const T*>(a) == *static_cast<const T*>(b);)
}
template<class T>
SEQ_ALWAYS_INLINE typename std::enable_if< !is_equal_comparable<T>::value, bool>::type compare_equal_any(const void* , const void* ) {
Expand Down Expand Up @@ -625,7 +632,7 @@ namespace seq

template<class T>
SEQ_ALWAYS_INLINE typename std::enable_if< std::is_arithmetic<T>::value, bool>::type compare_equal_arithmetic(long double a, const T& b) {
return a == static_cast<long double>(b);
SEQ_COMPARE_FLOAT( return a == static_cast<long double>(b);)
}
template<class T>
SEQ_ALWAYS_INLINE typename std::enable_if< !std::is_arithmetic<T>::value, bool>::type compare_equal_arithmetic(long double , const T& ) {
Expand Down Expand Up @@ -795,8 +802,15 @@ namespace seq
/// @brief Returns registered conversion functions
inline auto get_converters() -> std::vector < std::vector < std::function<void(const void*, void*)> > >&
{
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wexit-time-destructors"
#endif
// global converter functions
static std::vector < std::vector < std::function<void(const void*, void*)> > > inst;
#ifdef __clang__
#pragma clang diagnostic pop
#endif
return inst;
}
/// @brief Default conversion function, use explicit cast
Expand All @@ -817,8 +831,15 @@ namespace seq
/// @brief Returns registered less comparison functions
inline auto get_less_comparison() -> std::vector < std::vector < std::function<bool(const void*, const void*)> > >&
{
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wexit-time-destructors"
#endif
// global comparison functions for less than comparison
static std::vector < std::vector < std::function<bool(const void*, const void*)> > > inst;
#ifdef __clang__
#pragma clang diagnostic pop
#endif
return inst;
}
/// @brief Default less comparison
Expand All @@ -837,8 +858,15 @@ namespace seq
/// @brief Returns registered equal comparison functions
inline auto get_equal_comparison() -> std::vector < std::vector < std::function<bool(const void*, const void*)> > >&
{
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wexit-time-destructors"
#endif
// global comparison functions for equality comparison
static std::vector < std::vector < std::function<bool(const void*, const void*)> > > inst;
#ifdef __clang__
#pragma clang diagnostic pop
#endif
return inst;
}
/// @brief Default equal comparison
Expand Down Expand Up @@ -894,8 +922,8 @@ namespace seq
};
using pointer_type = tagged_pointer<TypeInfo, CustomAlignment, 32>;

pointer_type d_type_info;
storage_type d_storage;
pointer_type d_type_info{};
storage_type d_storage{};

/// @brief Allocate storage for given type, returns pointer to object in order to be constructed
template<class T>
Expand Down Expand Up @@ -940,7 +968,14 @@ namespace seq
auto convert(const TypeInfo* /*unused*/, const TypeInfo* /*unused*/, std::uintptr_t /*unused*/) const -> T
{
throw std::bad_cast();
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wexit-time-destructors"
#endif
static typename std::decay<T>::type ref;
#ifdef __clang__
#pragma clang diagnostic pop
#endif
return ref;
}

Expand Down Expand Up @@ -1688,7 +1723,14 @@ namespace seq
template<class T>
auto get_null_out() -> T* {
// Returns pointer to T*, never reached (just here to avoid compile warning)
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wexit-time-destructors"
#endif
static T t;
#ifdef __clang__
#pragma clang diagnostic pop
#endif
return &t;
}

Expand Down Expand Up @@ -1757,7 +1799,14 @@ namespace seq
instance.d_type_id = get_type_id<T>();
}
};
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wexit-time-destructors"
#endif
static Holder h;
#ifdef __clang__
#pragma clang diagnostic pop
#endif
return &h.instance;
}

Expand Down Expand Up @@ -2169,7 +2218,7 @@ namespace seq

// arithmetic comparison
if (is_arithmetic_type(a_id) && is_arithmetic_type(b_id)) {
return this->template cast<long double>() == other.template cast<long double>();
SEQ_COMPARE_FLOAT(return this->template cast<long double>() == other.template cast<long double>());
}

// string comparison
Expand Down
Loading

0 comments on commit 22c72e0

Please sign in to comment.