Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,49 @@ version: 2
jobs:
build:
docker:
- image: circleci/buildpack-deps:bionic
- image: cimg/base:24.04
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_PASSWORD
steps:
- checkout
- run:
name: Clang-format test
name: Ensure all submodules are updated recursively
command: git submodule update --init --recursive
- run:
name: Clang-format and Clang-tidy test
command: |
set -o xtrace
curl -sSL "http://apt.llvm.org/llvm-snapshot.gpg.key" | sudo -E apt-key add -
echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-15 main" | sudo tee -a /etc/apt/sources.list > /dev/null
UBUNTU_CODE_NAME="noble"
BASE_BRANCH="8.4"
COMPILER_VERSION="19"

sudo -E apt-get -yq update >> ~/apt-get-update.log 2>&1
sudo -E apt-get -yq --no-install-suggests --no-install-recommends install clang-format-15
git diff -U0 --no-color HEAD^1 *.c *.cc *.cpp *.h *.hpp *.i *.ic *.ih | clang-format-diff-15 -style=file -p1 >_GIT_DIFF
sudo apt-get install -yq --no-install-suggests --allow-unauthenticated --no-install-recommends clang-${COMPILER_VERSION} clang-tidy-${COMPILER_VERSION} clang-format-${COMPILER_VERSION} clang-tools-${COMPILER_VERSION} libc++-${COMPILER_VERSION}-dev libc++abi-${COMPILER_VERSION}-dev libldap2-dev curl libcurl4-openssl-dev bison libudev-dev libkrb5-dev libreadline-dev zlib1g-dev liblz4-dev libedit-dev libevent-dev protobuf-compiler libprotobuf-dev libprotoc-dev libldap2-dev libsasl2-dev libsasl2-modules-gssapi-mit cmake libicu-dev libtirpc-dev

# Prepare compile_commands.json
cd ~/project
cmake -B /home/circleci/debug-build -DCMAKE_BUILD_TYPE=Debug -DWITH_SSL=system -DWITH_AUTHENTICATION_LDAP=ON -DWITH_ROCKSDB=ON -DCMAKE_C_COMPILER=clang-${COMPILER_VERSION} -DCMAKE_CXX_COMPILER=clang++-${COMPILER_VERSION} -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DWITH_SYSTEM_LIBS=ON -DWITH_FIDO=bundled -DWITH_ZSTD=bundled -DWITH_LZ4=bundled -DWITH_PROTOBUF=bundled ~/project

git remote add target "https://github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
git fetch --no-tags --no-recurse-submodules target $BASE_BRANCH

echo "Checking clang-format results"
git diff -U0 "$(git merge-base HEAD target/$BASE_BRANCH)" *.c *.cc *.cpp *.h *.hpp *.i *.ic *.ih | clang-format-diff-$COMPILER_VERSION -style=file -p1 >_GIT_DIFF || true
if [ ! -s _GIT_DIFF ]; then
echo The last git commit is clang-formatted;
echo The last git commit is clang-formatted;
else
cat _GIT_DIFF;
# false;
fi

echo "Checking clang-tidy static code analysis results"
git diff -U0 "$(git merge-base HEAD target/$BASE_BRANCH)" *.c *.cc *.cpp *.h *.hpp *.i *.ic *.ih | clang-tidy-diff-${COMPILER_VERSION}.py -clang-tidy-binary clang-tidy-${COMPILER_VERSION} -p1 -path /home/circleci/debug-build -export-fixes=fixes.yaml || true
clang-apply-replacements-${COMPILER_VERSION} .
git diff > _GIT_DIFF_TIDY
if [ ! -s _GIT_DIFF_TIDY ]; then
echo The last git commit is clang-tidy clean;
else
cat _GIT_DIFF;
false;
echo The last git commit has clang-tidy warnings;
cat _GIT_DIFF_TIDY;
fi
6 changes: 1 addition & 5 deletions libs/mysql/binlog/event/compression/buffer/managed_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,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
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,10 @@ 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)
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
16 changes: 3 additions & 13 deletions libs/mysql/binlog/event/compression/payload_event_buffer_istream.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,8 @@ class Payload_event_buffer_istream {
/// @param memory_resource @c Memory_resource object used to
/// allocate memory.
template <class String_char_t>
Payload_event_buffer_istream(
const String_char_t *compressed_buffer, Size_t compressed_buffer_size,
type compression_algorithm, Size_t default_buffer_size = 0,
const Memory_resource_t &memory_resource = Memory_resource_t())
: m_memory_resource(memory_resource),
m_compressed_buffer(
reinterpret_cast<const Char_t *>(compressed_buffer)),
m_compressed_buffer_size(compressed_buffer_size),
m_compression_algorithm(compression_algorithm),
m_default_buffer_size(default_buffer_size) {
Payload_event_buffer_istream(const String_char_t *compressed_buffer, Size_t compressed_buffer_size, type compression_algorithm, Size_t default_buffer_size = 0, const Memory_resource_t &memory_resource = Memory_resource_t())
: m_memory_resource(memory_resource), m_compressed_buffer(reinterpret_cast<const Char_t *>(compressed_buffer)), m_compressed_buffer_size(compressed_buffer_size), m_compression_algorithm(compression_algorithm), m_default_buffer_size(default_buffer_size) {
initialize();
}

Expand All @@ -130,7 +122,6 @@ 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,
Expand All @@ -139,7 +130,6 @@ class Payload_event_buffer_istream {
: Payload_event_buffer_istream(
compressed_data.data(), compressed_data.size(),
compression_algorithm, default_buffer_size, memory_resource) {}
// NOLINTEND(cppcoreguidelines-pro-type-member-init)

/// Construct the stream from a (non-owned) Payload Event.
///
Expand Down Expand Up @@ -346,7 +336,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
8 changes: 3 additions & 5 deletions sql/raii/thread_stage_guard.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,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 @@ -127,8 +127,6 @@ class Thread_stage_guard {
#define THD_STAGE_GUARD(thd, new_stage) \
NAMED_THD_STAGE_GUARD(_thread_stage_guard_##new_stage, (thd), (new_stage))

// NOLINTEND(cppcoreguidelines-macro-usage)

} // namespace raii

#endif /// THREAD_STAGE_GUARD_H_INCLUDED
4 changes: 0 additions & 4 deletions unittest/gunit/binlogevents/managed_buffer_sequence-t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ using Difference_t = mysql::binlog::event::compression::buffer::
// 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)
Expand All @@ -94,7 +93,6 @@ static bool _shall_stop_after_assertion = false;
ASSERT_NE(v1, v2) ASSERTION_TAIL; \
++n_assertions; \
} while (0)
// NOLINTEND(cppcoreguidelines-macro-usage)

// 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)

// This does the following:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ class PayloadEventBufferStreamTest {
// 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