Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
Fix warnings (#551)
Browse files Browse the repository at this point in the history
* Fix unused/unreachable code

* Fix other warnings
  • Loading branch information
MBkkt committed Dec 19, 2023
1 parent 5d6061d commit f2dcbb3
Show file tree
Hide file tree
Showing 88 changed files with 268 additions and 516 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Checks: '*,
-mpi-*,
-objc-*,
-openmp-*,
-fuchsia-trailing-return,
-fuchsia-default-arguments-*,
-fuchsia-overloaded-operator,
-readability-identifier-length,
Expand Down
6 changes: 1 addition & 5 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,7 @@ set(IRESEARCH_EXTERNAL_INCLUDES
${Fasttext_INCLUDE_DIR}
${FROZEN_INCLUDE_DIR})

if (SUPPRESS_EXTERNAL_WARNINGS)
include_directories(SYSTEM ${IRESEARCH_EXTERNAL_INCLUDES})
else ()
include_directories(${IRESEARCH_EXTERNAL_INCLUDES})
endif ()
include_directories(SYSTEM ${IRESEARCH_EXTERNAL_INCLUDES})

add_library(iresearch-static
STATIC
Expand Down
5 changes: 3 additions & 2 deletions core/analysis/delimited_token_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ bool parse_vpack_options(const VPackSlice slice, std::string& delimiter) {
delimiter = delim_type_slice.stringView();
return true;
}
default: {
} // fall through
break;
default:
break;
}

IRS_LOG_ERROR(absl::StrCat(
Expand Down
2 changes: 1 addition & 1 deletion core/analysis/minhash_token_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static uint64_t HashLen0to16(const char* s, size_t len) {
uint8_t b = s[len >> 1];
uint8_t c = s[len - 1];
uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
uint32_t z = len + (static_cast<uint32_t>(c) << 2);
uint32_t z = static_cast<uint32_t>(len) + (static_cast<uint32_t>(c) << 2);
return ShiftMix(y * k2 ^ z * k0) * k2;
}
return k2;
Expand Down
2 changes: 1 addition & 1 deletion core/analysis/nearest_neighbors_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ bool nearest_neighbors_stream::reset(std::string_view data) {
std::istream ss{&buf};

model_dict_->getLine(ss, line_token_ids_, line_token_label_ids_);
n_tokens_ = line_token_ids_.size();
n_tokens_ = static_cast<int32_t>(line_token_ids_.size());
current_token_ind_ = 0;

neighbors_.clear();
Expand Down
4 changes: 2 additions & 2 deletions core/analysis/ngram_token_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ void ngram_token_stream_base::emit_original() noexcept {
: EmitOriginal::WithEndMarker;
inc.value = next_inc_val_;
break;
default:
IRS_ASSERT(false); // should not be called when None
case EmitOriginal::None:
IRS_ASSERT(false);
break;
}
next_inc_val_ = 0;
Expand Down
3 changes: 0 additions & 3 deletions core/analysis/segmentation_token_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,6 @@ bool accept_token(Iterator begin, Iterator end, word_break_t wb) {
return std::find_if_not(begin, end, utf8_utils::CharIsWhiteSpace) != end;
case word_break_t::ALPHA:
return std::find_if(begin, end, utf8_utils::CharIsAlphanumeric) != end;
default:
IRS_ASSERT(false);
return false;
}
}

Expand Down
6 changes: 3 additions & 3 deletions core/analysis/text_token_normalizing_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,9 @@ bool normalizing_token_stream::reset(std::string_view data) {
case UPPER:
state_->token.toUpper(state_->options.locale); // inplace case-conversion
break;
default: {
} // NOOP
};
case NONE:
break;
}

// collate value, e.g. remove accents
if (state_->transliterator) {
Expand Down
9 changes: 5 additions & 4 deletions core/analysis/text_token_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ bool process_term(analysis::text_token_stream::state_t& state,
case analysis::text_token_stream::UPPER:
state.token.toUpper(state.options.locale); // inplace case-conversion
break;
default: {
} // NOOP
};
case analysis::text_token_stream::NONE:
break;
}

// collate value, e.g. remove accents
if (state.transliterator) {
Expand All @@ -399,7 +399,8 @@ bool process_term(analysis::text_token_stream::state_t& state,
const sb_symbol* value =
reinterpret_cast<const sb_symbol*>(word_utf8.c_str());

value = sb_stemmer_stem(state.stemmer.get(), value, (int)word_utf8.size());
value = sb_stemmer_stem(state.stemmer.get(), value,
static_cast<int>(word_utf8.size()));

if (value) {
static_assert(sizeof(byte_type) == sizeof(sb_symbol));
Expand Down
1 change: 0 additions & 1 deletion core/analysis/token_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class token_stream : public attribute_provider {
public:
using ptr = std::unique_ptr<token_stream>;

virtual ~token_stream() = default;
virtual bool next() = 0;
};

Expand Down
6 changes: 3 additions & 3 deletions core/error/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ enum class ErrorCode : uint32_t {
undefined_error
};

#define DECLARE_ERROR_CODE(class_name) \
static constexpr ErrorCode CODE = ErrorCode::class_name; \
::irs::ErrorCode code() const noexcept final { return CODE; }
#define DECLARE_ERROR_CODE(class_name) \
::irs::ErrorCode code() const noexcept final { return CODE; } \
static constexpr ErrorCode CODE = ErrorCode::class_name

//////////////////////////////////////////////////////////////////////////////
/// @struct error_base
Expand Down
43 changes: 6 additions & 37 deletions core/formats/columnstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,16 @@ irs::bytes_view kDummy; // placeholder for visiting logic in columnstore
struct column_meta {
public:
column_meta() = default;
column_meta(column_meta&& rhs) noexcept
: name(std::move(rhs.name)), id(rhs.id) {
rhs.id = field_limits::invalid();
}

column_meta(column_meta&&) = delete;
column_meta(const column_meta&) = delete;
column_meta& operator=(column_meta&&) = delete;
column_meta& operator=(const column_meta&) = delete;
column_meta& operator=(column_meta&& rhs) noexcept = delete;

bool operator==(const column_meta& rhs) const noexcept {
return name == rhs.name;
}

std::string name;
field_id id{field_limits::invalid()};
};

static_assert(std::is_nothrow_move_constructible_v<column_meta>,
"default move constructor expected");

struct format_traits {
IRS_FORCE_INLINE static void pack32(const uint32_t* IRS_RESTRICT decoded,
uint32_t* IRS_RESTRICT encoded,
Expand Down Expand Up @@ -256,23 +246,6 @@ void read_compact(irs::index_input& in, irs::encryption::stream* cipher,
}
}

struct ColumnMetaEq : ValueRefEq<column_meta*> {
using is_transparent = void;
using Self::operator();

bool operator()(const Ref& lhs,
const hashed_string_view& rhs) const noexcept {
return lhs.ref->name == rhs;
}

bool operator()(const hashed_string_view& lhs,
const Ref& rhs) const noexcept {
return this->operator()(rhs, lhs);
}
};

using name_to_column_map = flat_hash_set<ColumnMetaEq>;

class meta_writer final {
public:
static constexpr std::string_view FORMAT_NAME = "iresearch_10_columnmeta";
Expand Down Expand Up @@ -686,7 +659,7 @@ class writer final : public irs::columnstore_writer {
// do not take into account last block
const auto blocks_count = std::max(1U, column_index_.total());
avg_block_count_ = block_index_.flushed() / blocks_count;
avg_block_size_ = length_ / blocks_count;
avg_block_size_ = static_cast<uint32_t>(length_ / blocks_count);

// we don't care of tail block size
prev_block_size_ = block_buf_.size();
Expand Down Expand Up @@ -1131,7 +1104,7 @@ class dense_block : util::noncopyable {
return false;
}

value_ = base_ + std::distance(begin_, it_);
value_ = base_ + static_cast<uint32_t>(std::distance(begin_, it_));
next_value();

return true;
Expand Down Expand Up @@ -1200,7 +1173,7 @@ class dense_block : util::noncopyable {
encode::avg::visit_block_packed_tail(
in, size, reinterpret_cast<uint64_t*>(buf.data()),
[begin](uint64_t offset) mutable {
*begin = offset;
*begin = static_cast<uint32_t>(offset);
++begin;
});

Expand Down Expand Up @@ -1669,9 +1642,7 @@ class column : public irs::column_reader, private util::noncopyable {
using ptr = std::unique_ptr<column>;

explicit column(field_id id, ColumnProperty props) noexcept
: props_(props), id_{id}, encrypted_(0 != (props & CP_COLUMN_ENCRYPT)) {}

virtual ~column() = default;
: id_{id}, encrypted_(0 != (props & CP_COLUMN_ENCRYPT)) {}

field_id id() const final { return id_; }

Expand Down Expand Up @@ -1704,7 +1675,6 @@ class column : public irs::column_reader, private util::noncopyable {
bool empty() const noexcept { return 0 == size(); }
uint32_t avg_block_size() const noexcept { return avg_block_size_; }
uint32_t avg_block_count() const noexcept { return avg_block_count_; }
ColumnProperty props() const noexcept { return props_; }
compression::decompressor* decompressor() const noexcept {
return decomp_.get();
}
Expand All @@ -1719,7 +1689,6 @@ class column : public irs::column_reader, private util::noncopyable {
uint32_t count_{};
uint32_t avg_block_size_{};
uint32_t avg_block_count_{};
ColumnProperty props_{CP_SPARSE};
field_id id_;
std::optional<std::string> name_;
bool encrypted_{false}; // cached encryption mark
Expand Down
14 changes: 7 additions & 7 deletions core/formats/columnstore2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ doc_iterator::ptr dense_fixed_length_column::iterator(ColumnHint hint) const {
payload_reader<encrypted_value_reader<false>> operator()(
index_input::ptr&& stream, encryption::stream& cipher) const {
return {ctx->data_, ctx->len_, std::move(stream), &cipher, ctx->data_};
};
}

payload_reader<value_reader<false>> operator()(
index_input::ptr&& stream) const {
Expand Down Expand Up @@ -966,7 +966,7 @@ doc_iterator::ptr fixed_length_column::iterator(ColumnHint hint) const {
index_input::ptr&& stream, encryption::stream& cipher) const {
return {ctx->blocks_.data(), ctx->len_, std::move(stream), &cipher,
ctx->len_};
};
}

payload_reader<value_reader<false>> operator()(
index_input::ptr&& stream) const {
Expand Down Expand Up @@ -1263,7 +1263,7 @@ doc_iterator::ptr sparse_column::iterator(ColumnHint hint) const {
payload_reader<encrypted_value_reader<true>> operator()(
index_input::ptr&& stream, encryption::stream& cipher) const {
return {ctx->blocks_.data(), std::move(stream), &cipher, size_t{0}};
};
}

payload_reader<value_reader<true>> operator()(
index_input::ptr&& stream) const {
Expand Down Expand Up @@ -1291,14 +1291,14 @@ constexpr column_factory_f kFactories[]{
&dense_fixed_length_column::read};

bool less(std::string_view lhs, std::string_view rhs) noexcept {
if (IsNull(lhs)) {
return !IsNull(rhs);
}

if (IsNull(rhs)) {
return false;
}

if (IsNull(lhs)) {
return true;
}

return lhs < rhs;
}

Expand Down
2 changes: 0 additions & 2 deletions core/formats/formats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,6 @@ enum class ColumnHint : uint32_t {
ENABLE_BITMASK_ENUM(ColumnHint);

struct column_reader : public memory::Managed {
virtual ~column_reader() = default;

// Returns column id.
virtual field_id id() const = 0;

Expand Down
15 changes: 4 additions & 11 deletions core/formats/formats_10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,6 @@ struct doc_buffer : skip_buffer {
last = doc;
}

void reset() noexcept {
skip_buffer::reset();
doc = docs.begin();
freq = freqs.begin();
last = doc_limits::invalid();
block_last = doc_limits::min();
}

std::span<doc_id_t> docs;
std::span<uint32_t> freqs;
uint32_t* skip_doc;
Expand Down Expand Up @@ -1586,7 +1578,7 @@ class position final : public irs::position,
value_t seek(value_t target) final {
const uint32_t freq = *this->freq_;
if (this->pend_pos_ > freq) {
skip(this->pend_pos_ - freq);
skip(static_cast<uint32_t>(this->pend_pos_ - freq));
this->pend_pos_ = freq;
}
while (value_ < target && this->pend_pos_) {
Expand Down Expand Up @@ -1620,7 +1612,7 @@ class position final : public irs::position,
const uint32_t freq = *this->freq_;

if (this->pend_pos_ > freq) {
skip(this->pend_pos_ - freq);
skip(static_cast<uint32_t>(this->pend_pos_ - freq));
this->pend_pos_ = freq;
}

Expand Down Expand Up @@ -1956,6 +1948,7 @@ auto ResolveExtent(uint8_t extent, Func&& func) {
if constexpr (PossibleMin <= 0) {
return std::forward<Func>(func)(Extent<0>{});
}
[[fallthrough]];
default:
return std::forward<Func>(func)(DynamicExtent{extent});
}
Expand Down Expand Up @@ -4130,7 +4123,7 @@ template<bool Wand, uint32_t PosMin>
struct format_traits_sse4 {
using align_type = __m128i;

static constexpr bool wand() noexcept { return Wand; };
static constexpr bool wand() noexcept { return Wand; }
static constexpr uint32_t pos_min() noexcept { return PosMin; }
static constexpr uint32_t block_size() noexcept { return SIMDBlockSize; }
static_assert(block_size() <= doc_limits::eof());
Expand Down
Loading

0 comments on commit f2dcbb3

Please sign in to comment.