From acb7cd50072e4e19685519d9a32743c6651ba5a5 Mon Sep 17 00:00:00 2001 From: Cristian Ferretti <37232625+jcferretti@users.noreply.github.com> Date: Sat, 8 Jul 2023 19:46:15 -0400 Subject: [PATCH] Allow building the C++ client with clang. (#4153) --- cpp-client/.clang-format | 5 +++++ .../deephaven/dhcore/immerutil/immer_column_source.h | 8 ++++++++ .../private/deephaven/dhcore/ticking/index_decoder.h | 5 ++--- .../dhcore/include/public/deephaven/dhcore/types.h | 6 ++---- cpp-client/deephaven/dhcore/src/ticking/space_mapper.cc | 4 ---- cpp-client/deephaven/dhcore/src/types.cc | 8 ++++++-- 6 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 cpp-client/.clang-format diff --git a/cpp-client/.clang-format b/cpp-client/.clang-format new file mode 100644 index 00000000000..f98f35d4ea8 --- /dev/null +++ b/cpp-client/.clang-format @@ -0,0 +1,5 @@ +BasedOnStyle: Google +IndentWidth: 2 + +--- +Language: Cpp diff --git a/cpp-client/deephaven/dhcore/include/private/deephaven/dhcore/immerutil/immer_column_source.h b/cpp-client/deephaven/dhcore/include/private/deephaven/dhcore/immerutil/immer_column_source.h index 4f37064b728..30ad0b42dc0 100644 --- a/cpp-client/deephaven/dhcore/include/private/deephaven/dhcore/immerutil/immer_column_source.h +++ b/cpp-client/deephaven/dhcore/include/private/deephaven/dhcore/immerutil/immer_column_source.h @@ -61,6 +61,9 @@ struct ImmerColumnSourceImpls { if (destNullp != nullptr) { *destNullp++ = value == deephaven::dhcore::DeephavenTraits::NULL_VALUE; } + } else { + // avoid clang complaining about unused variables + (void)destNullp; } } }; @@ -83,6 +86,11 @@ struct ImmerColumnSourceImpls { auto nullsEndp = srcNullFlags->begin() + srcEnd; immer::for_each_chunk(nullsBeginp, nullsEndp, copyNullsInner); } + } else { + // avoid clang complaining about unused variables. + (void)srcNullFlags; + (void)destNullp; + (void)copyNullsInner; } }; rows.forEachInterval(copyOuter); diff --git a/cpp-client/deephaven/dhcore/include/private/deephaven/dhcore/ticking/index_decoder.h b/cpp-client/deephaven/dhcore/include/private/deephaven/dhcore/ticking/index_decoder.h index df2b76c7cc6..e06de361717 100644 --- a/cpp-client/deephaven/dhcore/include/private/deephaven/dhcore/ticking/index_decoder.h +++ b/cpp-client/deephaven/dhcore/include/private/deephaven/dhcore/ticking/index_decoder.h @@ -12,8 +12,8 @@ class DataInput { public: explicit DataInput(const flatbuffers::Vector &vec) : DataInput(vec.data(), vec.size()) {} - DataInput(const void *start, size_t size) : data_(static_cast(start)), - size_(size) {} + DataInput(const void *start, size_t size) : data_(static_cast(start)) + {} int64_t readValue(int command); @@ -24,7 +24,6 @@ class DataInput { private: const char *data_ = nullptr; - size_t size_ = 0; }; struct IndexDecoder { diff --git a/cpp-client/deephaven/dhcore/include/public/deephaven/dhcore/types.h b/cpp-client/deephaven/dhcore/include/public/deephaven/dhcore/types.h index 58c786bd591..8d42206fbe9 100644 --- a/cpp-client/deephaven/dhcore/include/public/deephaven/dhcore/types.h +++ b/cpp-client/deephaven/dhcore/include/public/deephaven/dhcore/types.h @@ -117,8 +117,7 @@ class DeephavenConstants { /** * The minimum finite value for the Deephaven float type. */ - static constexpr const float MIN_FINITE_FLOAT = std::nextafter(-std::numeric_limits::max(), - 0.0f); + static /* constexpr clang dislikes */ const float MIN_FINITE_FLOAT; /** * The maximum finite value for the Deephaven float type. */ @@ -155,8 +154,7 @@ class DeephavenConstants { /** * The minimum finite value for the Deephaven double type. */ - static constexpr const double MIN_FINITE_DOUBLE = std::nextafter( - -std::numeric_limits::max(), 0.0f); + static /* constexpr clang dislikes */ const double MIN_FINITE_DOUBLE; /** * The maximum finite value for the Deephaven double type. */ diff --git a/cpp-client/deephaven/dhcore/src/ticking/space_mapper.cc b/cpp-client/deephaven/dhcore/src/ticking/space_mapper.cc index 1ff916e6eaf..4daa3182235 100644 --- a/cpp-client/deephaven/dhcore/src/ticking/space_mapper.cc +++ b/cpp-client/deephaven/dhcore/src/ticking/space_mapper.cc @@ -28,10 +28,6 @@ struct SimpleRangeIterator { return *this; } - friend bool operator!=(const SimpleRangeIterator &lhs, const SimpleRangeIterator &rhs) { - return lhs.value_ != rhs.value_; - } - uint64_t value_; }; } diff --git a/cpp-client/deephaven/dhcore/src/types.cc b/cpp-client/deephaven/dhcore/src/types.cc index 6129dbb5e1d..61d3b80cf33 100644 --- a/cpp-client/deephaven/dhcore/src/types.cc +++ b/cpp-client/deephaven/dhcore/src/types.cc @@ -3,6 +3,8 @@ */ #include "deephaven/dhcore/types.h" +#include + namespace deephaven::dhcore { const char16_t DeephavenConstants::NULL_CHAR; @@ -12,7 +14,8 @@ const float DeephavenConstants::NEG_INFINITY_FLOAT; const float DeephavenConstants::POS_INFINITY_FLOAT; const float DeephavenConstants::MIN_FLOAT; const float DeephavenConstants::MAX_FLOAT; -const float DeephavenConstants::MIN_FINITE_FLOAT; +const float DeephavenConstants::MIN_FINITE_FLOAT = + std::nextafter(-std::numeric_limits::max(), 0.0f); const float DeephavenConstants::MAX_FINITE_FLOAT; const float DeephavenConstants::MIN_POS_FLOAT; @@ -22,7 +25,8 @@ const double DeephavenConstants::NEG_INFINITY_DOUBLE; const double DeephavenConstants::POS_INFINITY_DOUBLE; const double DeephavenConstants::MIN_DOUBLE; const double DeephavenConstants::MAX_DOUBLE; -const double DeephavenConstants::MIN_FINITE_DOUBLE; +const double DeephavenConstants::MIN_FINITE_DOUBLE = + std::nextafter(-std::numeric_limits::max(), 0.0); const double DeephavenConstants::MAX_FINITE_DOUBLE; const double DeephavenConstants::MIN_POS_DOUBLE;