Skip to content

Commit

Permalink
Remove clang-tidy checks in source code
Browse files Browse the repository at this point in the history
  • Loading branch information
VarunNagaraju committed Feb 28, 2024
1 parent 4db8add commit 7b26954
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 64 deletions.
14 changes: 7 additions & 7 deletions extra/robin-hood-hashing/robin_hood.h
Original file line number Diff line number Diff line change
Expand Up @@ -1608,13 +1608,13 @@ class Table

// Creates a copy of the given map. Copy constructor of each entry is used.
// Not sure why clang-tidy thinks this doesn't handle self assignment, it does
// NOLINTNEXTLINE(bugprone-unhandled-self-assignment,cert-oop54-cpp)
Table& operator=(Table const& o) {
ROBIN_HOOD_TRACE(this)
if (&o == this) {
// prevent assigning of itself
return *this;
}
Table& operator=(Table const& o)
{
ROBIN_HOOD_TRACE(this)
if (&o == this) {
// prevent assigning of itself
return *this;
}

// we keep using the old allocator and not assign the new one, because we want to keep
// the memory available. when it is the same size.
Expand Down
6 changes: 1 addition & 5 deletions libbinlogevents/include/buffer/managed_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ class Managed_buffer : public buffer::Rw_buffer<Char_tp> {
// Nolint: clang-tidy does not recognize that m_owns_default_buffer
// is initialized, despite it is initialized in the targed
// constructor.
// NOLINTBEGIN(cppcoreguidelines-pro-type-member-init)
explicit Managed_buffer(
const Memory_resource_t &memory_resource = Memory_resource_t())
: Managed_buffer(Size_t(0), memory_resource) {}
// NOLINTEND(cppcoreguidelines-pro-type-member-init)
explicit Managed_buffer(const Memory_resource_t &memory_resource = Memory_resource_t()) : Managed_buffer(Size_t(0), memory_resource) {}

/// Construct a new object that owns a default buffer.
///
Expand Down
15 changes: 4 additions & 11 deletions libbinlogevents/include/compression/payload_event_buffer_istream.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,9 @@ class Payload_event_buffer_istream {
// Nolint: clang-tidy does not recognize that m_default_buffer_size
// is initialized, despite it is initialized in the targed
// constructor.
// NOLINTBEGIN(cppcoreguidelines-pro-type-member-init)
template <class String_char_t>
Payload_event_buffer_istream(
const std::basic_string<String_char_t> &compressed_data,
type compression_algorithm, Size_t default_buffer_size = 0,
const Memory_resource_t &memory_resource = Memory_resource_t())
: Payload_event_buffer_istream(
compressed_data.data(), compressed_data.size(),
compression_algorithm, default_buffer_size, memory_resource) {}
// NOLINTEND(cppcoreguidelines-pro-type-member-init)
template <class String_char_t> Payload_event_buffer_istream(
const std::basic_string<String_char_t> &compressed_data, type compression_algorithm, Size_t default_buffer_size = 0, const Memory_resource_t &memory_resource = Memory_resource_t())
: Payload_event_buffer_istream(compressed_data.data(), compressed_data.size(), compression_algorithm, default_buffer_size, memory_resource) {}

/// Construct the stream from a (non-owned) Payload Event.
///
Expand Down Expand Up @@ -344,7 +337,7 @@ class Payload_event_buffer_istream {
/// Grow calculator for the Managed_buffer.
Grow_calculator_t m_grow_calculator;
/// Default buffer size for the Managed_buffer.
Size_t m_default_buffer_size;
Size_t m_default_buffer_size;
/// Shared pointer to Managed_buffer that holds the output. This
/// will be shared with API clients. Therefore, API clients can use
/// the returned buffer as long as they like. The next time this
Expand Down
17 changes: 6 additions & 11 deletions libbinlogevents/src/compression/payload_event_buffer_istream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,12 @@ void Payload_event_buffer_istream::update_buffer() {
#ifndef NDEBUG
// "nolint": clang-tidy reports an unnecessary warning since 'if'
// and 'else' branches may compile to the same. Suppressing that.
// NOLINTBEGIN(bugprone-branch-clone)
if (m_managed_buffer_ptr.use_count() == 0)
BAPI_LOG("info", "Allocating managed buffer for the first time.");
else
BAPI_LOG("info",
"Allocating new managed buffer. "
"The previous one cannot be reused since there are "
<< m_managed_buffer_ptr.use_count()
<< ">1 shared pointer references to "
"it.");
// NOLINTEND(bugprone-branch-clone)
if (m_managed_buffer_ptr.use_count() == 0) {
BAPI_LOG("info", "Allocating managed buffer for the first time. ");
}
else {
BAPI_LOG("info", "Allocating new managed buffer. The previous one cannot be reused since there are " << m_managed_buffer_ptr.use_count() << ">1 shared pointer references to it.");
}
#endif
try {
auto allocator = Allocator_t<Managed_buffer_t>(m_memory_resource);
Expand Down
14 changes: 5 additions & 9 deletions sql/raii/thread_stage_guard.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ class Thread_stage_guard {
const unsigned int m_line;
};

// NOLINTBEGIN(cppcoreguidelines-macro-usage)

/// Set the thread stage for the given thread, and make it restore the
/// previous stage at the end of the invoking scope, using the named
/// local RAII variable.
Expand All @@ -110,9 +108,9 @@ class Thread_stage_guard {
/// @param new_stage The new stage. `thd` will use this stage until
/// the end of the scope where the macro is invoked. At that point,
/// the stage is reverted to what it was before invoking this macro.
#define NAMED_THD_STAGE_GUARD(name, thd, new_stage) \
raii::Thread_stage_guard name { \
(thd), (new_stage), __func__, __FILE__, __LINE__ \
#define NAMED_THD_STAGE_GUARD(name, thd, new_stage) \
raii::Thread_stage_guard name { \
(thd),(new_stage), __func__, __FILE__, __LINE__ \
}

/// Set the thread stage for the given thread, and make it restore the
Expand All @@ -123,10 +121,8 @@ class Thread_stage_guard {
/// @param new_stage The new stage. `thd` will use this stage until
/// the end of the scope where the macro is invoked. At that point,
/// the stage is reverted to what it was before invoking this macro.
#define THD_STAGE_GUARD(thd, new_stage) \
NAMED_THD_STAGE_GUARD(_thread_stage_guard_##new_stage, (thd), (new_stage))

// NOLINTEND(cppcoreguidelines-macro-usage)
#define THD_STAGE_GUARD(thd,new_stage) \
NAMED_THD_STAGE_GUARD(_thread_stage_guard_##new_stage, (thd),(new_stage))

} // namespace raii

Expand Down
34 changes: 15 additions & 19 deletions unittest/gunit/binlogevents/managed_buffer_sequence-t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,19 @@ using Difference_t = mysqlns::buffer::Rw_buffer_sequence<>::Difference_t;
// make the program stop with assertion.
[[maybe_unused]] static int n_assertions = 0;
static bool _shall_stop_after_assertion = false;
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
#define ASSERTION_TAIL \
<< debug_output(fileline) << (_shall_stop_after_assertion = true, ""), \
assert(!_shall_stop_after_assertion)
#define AEQ(v1, v2) \
do { \
ASSERT_EQ(v1, v2) ASSERTION_TAIL; \
++n_assertions; \
} while (0)
#define ANE(v1, v2) \
do { \
ASSERT_NE(v1, v2) ASSERTION_TAIL; \
++n_assertions; \
} while (0)
// NOLINTEND(cppcoreguidelines-macro-usage)
#define ASSERTION_TAIL \
<< debug_output(fileline) << (_shall_stop_after_assertion = true,""), \
assert(!_shall_stop_after_assertion )
#define AEQ(v1,v2) \
do{ \
ASSERT_EQ(v1,v2) ASSERTION_TAIL; \
++n_assertions; \
} while(0)
#define ANE(v1,v2) \
do{ \
ASSERT_NE(v1,v2) ASSERTION_TAIL; \
++n_assertions; \
} while(0)

// Requirements:
//
Expand Down Expand Up @@ -251,10 +249,8 @@ class Grow_tester {
Size_t extra_container_capacity, Size_t position,
Size_t capacity, Size_t max_capacity,
Size_t requested_capacity, Size_t requested_position) {
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
#define CHECK_SIZES(POSITION, CAPACITY) \
check_sizes(FILELINE(), debug_output, mbs, buffer_size, POSITION, CAPACITY)
// NOLINTEND(cppcoreguidelines-macro-usage)
#define CHECK_SIZES(POSITION,CAPACITY) \
check_sizes(FILELINE(), debug_output, mbs, buffer_size, POSITION,CAPACITY)

// This does the following:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,7 @@ class PayloadEventBufferStreamTest {
// "nolint": as a general rule, malloc should not be used, so
// clang-tidy warns about it. But this is an allocator so it is
// appropriate to use malloc and therefore we suppress the check.
// NOLINTNEXTLINE(cppcoreguidelines-no-malloc)
return std::malloc(n);
return std::malloc(n);
};
Memory_resource_t failing_memory_resource(failing_allocator, std::free);
auto debug_func = [&] {
Expand Down

0 comments on commit 7b26954

Please sign in to comment.