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

Fix clang-tidy warnings for a batch of files #3239

Merged
merged 8 commits into from
Oct 20, 2021
Merged
17 changes: 9 additions & 8 deletions dbms/src/Common/COWPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class COWPtr : public boost::intrusive_ref_counter<Derived>

protected:
template <typename T>
class mutable_ptr : public IntrusivePtr<T>
class mutable_ptr : public IntrusivePtr<T> // NOLINT(readability-identifier-naming)
{
private:
using Base = IntrusivePtr<T>;
Expand All @@ -114,22 +114,23 @@ class COWPtr : public boost::intrusive_ref_counter<Derived>
mutable_ptr & operator=(mutable_ptr &&) = default;

/// Initializing from temporary of compatible type.
// The single-argument constructors are kept non-explicit for life saving, because POWPtr is basically ubiquitous
template <typename U>
mutable_ptr(mutable_ptr<U> && other)
mutable_ptr(mutable_ptr<U> && other) // NOLINT(google-explicit-constructor)
: Base(std::move(other))
{}

mutable_ptr() = default;

mutable_ptr(const std::nullptr_t *) {}
mutable_ptr(const std::nullptr_t *) {} // NOLINT(google-explicit-constructor)
};

public:
using MutablePtr = mutable_ptr<Derived>;

protected:
template <typename T>
class immutable_ptr : public IntrusivePtr<const T>
class immutable_ptr : public IntrusivePtr<const T> // NOLINT(readability-identifier-naming)
{
private:
using Base = IntrusivePtr<const T>;
Expand All @@ -149,7 +150,7 @@ class COWPtr : public boost::intrusive_ref_counter<Derived>
immutable_ptr & operator=(const immutable_ptr &) = default;

template <typename U>
immutable_ptr(const immutable_ptr<U> & other)
immutable_ptr(const immutable_ptr<U> & other) // NOLINT(google-explicit-constructor)
: Base(other)
{}

Expand All @@ -159,13 +160,13 @@ class COWPtr : public boost::intrusive_ref_counter<Derived>

/// Initializing from temporary of compatible type.
template <typename U>
immutable_ptr(immutable_ptr<U> && other)
immutable_ptr(immutable_ptr<U> && other) // NOLINT(google-explicit-constructor)
: Base(std::move(other))
{}

/// Move from mutable ptr: ok.
template <typename U>
immutable_ptr(mutable_ptr<U> && other)
immutable_ptr(mutable_ptr<U> && other) // NOLINT(google-explicit-constructor)
: Base(std::move(other))
{}

Expand All @@ -175,7 +176,7 @@ class COWPtr : public boost::intrusive_ref_counter<Derived>

immutable_ptr() = default;

immutable_ptr(const std::nullptr_t *) {}
immutable_ptr(const std::nullptr_t *) {} // NOLINT(google-explicit-constructor)
};

public:
Expand Down
10 changes: 5 additions & 5 deletions dbms/src/Common/Checksum.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class None
using HashType = std::byte;
static constexpr size_t hash_size = sizeof(HashType);
static constexpr auto algorithm = ::DB::ChecksumAlgo::None;
void update(const void *, size_t length) { ProfileEvents::increment(ProfileEvents::ChecksumDigestBytes, length); }
[[nodiscard]] HashType checksum() const { return std::byte{0}; }
static void update(const void *, size_t length) { ProfileEvents::increment(ProfileEvents::ChecksumDigestBytes, length); }
[[nodiscard]] static HashType checksum() { return std::byte{0}; }
};

class CRC32
Expand Down Expand Up @@ -114,7 +114,7 @@ struct ChecksumFrame
{
size_t bytes;
typename Algorithm::HashType checksum;
uint8_t _pad[alignof(size_t) > alignof(typename Algorithm::HashType) ? alignof(size_t) - sizeof(typename Algorithm::HashType) : 0];
uint8_t pad[alignof(size_t) > alignof(typename Algorithm::HashType) ? alignof(size_t) - sizeof(typename Algorithm::HashType) : 0];
uint8_t data[0];
};

Expand Down Expand Up @@ -189,8 +189,8 @@ class UnifiedDigest : public UnifiedDigestBase
bool compareFrame(const FrameUnion & frame) override
{
auto checksum = backend.checksum();
auto realFrame = reinterpret_cast<const ChecksumFrame<Backend> &>(frame);
return checksum == realFrame.checksum;
auto real_frame = reinterpret_cast<const ChecksumFrame<Backend> &>(frame);
return checksum == real_frame.checksum;
}

[[nodiscard]] std::string raw() const override
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Common/ColumnsHashing.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct HashMethodOneNumber
vec = &static_cast<const ColumnVector<FieldType> *>(key_columns[0])->getData()[0];
}

HashMethodOneNumber(const IColumn * column)
explicit HashMethodOneNumber(const IColumn * column)
{
vec = &static_cast<const ColumnVector<FieldType> *>(column)->getData()[0];
}
Expand Down
6 changes: 3 additions & 3 deletions dbms/src/Common/ColumnsHashingImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,14 @@ template <typename Key>
class BaseStateKeysFixed<Key, true>
{
protected:
BaseStateKeysFixed(const ColumnRawPtrs & key_columns)
explicit BaseStateKeysFixed(const ColumnRawPtrs & key_columns)
{
null_maps.reserve(key_columns.size());
actual_columns.reserve(key_columns.size());

for (const auto & col : key_columns)
{
if (auto * nullable_col = checkAndGetColumn<ColumnNullable>(col))
if (const auto * nullable_col = checkAndGetColumn<ColumnNullable>(col))
{
actual_columns.push_back(&nullable_col->getNestedColumn());
null_maps.push_back(&nullable_col->getNullMapColumn());
Expand Down Expand Up @@ -331,7 +331,7 @@ template <typename Key>
class BaseStateKeysFixed<Key, false>
{
protected:
BaseStateKeysFixed(const ColumnRawPtrs & columns)
explicit BaseStateKeysFixed(const ColumnRawPtrs & columns)
: actual_columns(columns)
{}

Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Flash/Coprocessor/DAGDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ try
{
// Under some test cases, there may be dag response whose size is bigger than INT_MAX, and GRPC can not limit it.
// Throw exception to prevent receiver from getting wrong response.
if (p_stream->getProfileInfo().bytes > std::numeric_limits<int>::max())
if (accurate::greaterOp(p_stream->getProfileInfo().bytes, std::numeric_limits<int>::max()))
throw TiFlashException("DAG response is too big, please check config about region size or region merge scheduler",
Errors::Coprocessor::Internal);
}
Expand Down