From 1ced0193186892e7c871d7c2fed301924d3dc76d Mon Sep 17 00:00:00 2001 From: Varun Nagaraju Date: Tue, 16 Jan 2024 13:57:14 +0530 Subject: [PATCH] Remove clang-tidy checks in source code --- extra/robin-hood-hashing/robin_hood.h | 14 ++++---- .../include/buffer/managed_buffer.h | 6 +--- .../payload_event_buffer_istream.h | 15 +++----- .../payload_event_buffer_istream.cpp | 17 ++++------ sql/raii/thread_stage_guard.h | 14 +++----- .../binlogevents/managed_buffer_sequence-t.cc | 34 ++++++++----------- .../payload_event_buffer_istream-t.cc | 3 +- 7 files changed, 39 insertions(+), 64 deletions(-) diff --git a/extra/robin-hood-hashing/robin_hood.h b/extra/robin-hood-hashing/robin_hood.h index b4e0fbc56aec..e60fcd83f3bb 100644 --- a/extra/robin-hood-hashing/robin_hood.h +++ b/extra/robin-hood-hashing/robin_hood.h @@ -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. diff --git a/libbinlogevents/include/buffer/managed_buffer.h b/libbinlogevents/include/buffer/managed_buffer.h index 76a9ab8724af..149556d5fdb8 100644 --- a/libbinlogevents/include/buffer/managed_buffer.h +++ b/libbinlogevents/include/buffer/managed_buffer.h @@ -125,11 +125,7 @@ class Managed_buffer : public buffer::Rw_buffer { // 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. /// diff --git a/libbinlogevents/include/compression/payload_event_buffer_istream.h b/libbinlogevents/include/compression/payload_event_buffer_istream.h index b1c98456b7ab..85a9262b9147 100644 --- a/libbinlogevents/include/compression/payload_event_buffer_istream.h +++ b/libbinlogevents/include/compression/payload_event_buffer_istream.h @@ -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 - Payload_event_buffer_istream( - const std::basic_string &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 Payload_event_buffer_istream( + const std::basic_string &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. /// @@ -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 diff --git a/libbinlogevents/src/compression/payload_event_buffer_istream.cpp b/libbinlogevents/src/compression/payload_event_buffer_istream.cpp index a81584c9de11..511bc7eb1df7 100644 --- a/libbinlogevents/src/compression/payload_event_buffer_istream.cpp +++ b/libbinlogevents/src/compression/payload_event_buffer_istream.cpp @@ -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(m_memory_resource); diff --git a/sql/raii/thread_stage_guard.h b/sql/raii/thread_stage_guard.h index bc364576d477..21c059a540c4 100644 --- a/sql/raii/thread_stage_guard.h +++ b/sql/raii/thread_stage_guard.h @@ -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. @@ -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 @@ -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 diff --git a/unittest/gunit/binlogevents/managed_buffer_sequence-t.cc b/unittest/gunit/binlogevents/managed_buffer_sequence-t.cc index 4d463e498a3c..bf988b8a7a91 100644 --- a/unittest/gunit/binlogevents/managed_buffer_sequence-t.cc +++ b/unittest/gunit/binlogevents/managed_buffer_sequence-t.cc @@ -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: // @@ -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: // diff --git a/unittest/gunit/binlogevents/payload_event_buffer_istream-t.cc b/unittest/gunit/binlogevents/payload_event_buffer_istream-t.cc index c89f684ff1cd..25a30dd625a7 100644 --- a/unittest/gunit/binlogevents/payload_event_buffer_istream-t.cc +++ b/unittest/gunit/binlogevents/payload_event_buffer_istream-t.cc @@ -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 = [&] {