Skip to content
Merged
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
35 changes: 30 additions & 5 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,47 +1,72 @@
Checks: >
*,-clang-analyzer-alpha.*,-hicpp-*,
*,
-clang-analyzer-*,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it multiple lines and skip all of clang-analyzer-*.

-hicpp-*,
-clang-diagnostic-ignored-optimization-argument,
-clang-diagnostic-elaborated-enum-base,
-altera-*,
-abseil-*,
-boost-*,
-bugprone-crtp-constructor-accessibility,
-bugprone-derived-method-shadowing-base-method,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-macro-parentheses,
-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,
-fuchsia-multiple-inheritance,-misc-multiple-inheritance,
-llvmlibc-*,
-modernize-concat-nested-namespaces,
-modernize-loop-convert,
-modernize-return-braced-init-list,
-modernize-use-constraints,
-modernize-use-integer-sign-comparison,
-modernize-use-nodiscard,
-modernize-use-ranges,
-modernize-use-trailing-return-type,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-goto, -hicpp-avoid-goto,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-init-variables,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-macro-usage,
-fuchsia-overloaded-operator,-fuchsia-default-arguments*,
hicpp-avoid-goto,hicpp-exception-baseclass,hicpp-multiway-paths-covered,
hicpp-no-assembler,hicpp-signed-bitwise,
-cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-use-default-member-init,-modernize-use-default-member-init,
-cppcoreguidelines-use-enum-class,
-google-readability-casting,
-google-readability-todo,
-google-runtime-references,
-hicpp-signed-bitwise,
-llvm-else-after-return,
-llvm-header-guard,
-llvm-include-order,
-llvm-use-ranges,
-performance-noexcept-move-constructor,
-performance-avoid-endl,
-portability-avoid-pragma-once,
-readability-container-contains,
-readability-else-after-return,
-readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-inconsistent-declaration-parameter-name,
-readability-isolate-declaration,
-readability-named-parameter,
-readability-magic-numbers,
-readability-math-missing-parentheses,
-readability-redundant-access-specifiers,
-readability-redundant-inline-specifier,
-readability-redundant-typename,
-misc-non-private-member-variables-in-classes,
-misc-confusable-identifiers,
-misc-include-cleaner,
-misc-unused-alias-decls,
-misc-use-internal-linkage
WarningsAsErrors: ''
HeaderFilterRegex: 'modmesh.*'
AnalyzeTemporaryDtors: false
FormatStyle: google
CheckOptions:
- key: cppcoreguidelines-macro-usage.AllowedRegexp
Expand Down
8 changes: 4 additions & 4 deletions .github/actions/setup_linux/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ runs:
if: ${{ inputs.workflow == 'lint' }}
shell: bash
run: |
# Install clang-tidy-21 from LLVM repository for full C++23 support
# Install clang-tidy-22 from LLVM repository for full C++23 support
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-21 main" | sudo tee /etc/apt/sources.list.d/llvm.list
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-22 main" | sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt-get -qqy update
sudo apt-get -qy install clang-tidy-21
sudo ln -fs "$(which clang-tidy-21)" "/usr/local/bin/clang-tidy"
sudo apt-get -qy install clang-tidy-22
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrade to clang-tidy 22 for Linux.

sudo ln -fs "$(which clang-tidy-22)" "/usr/local/bin/clang-tidy"

- name: Install and configure gcc-14
shell: bash
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/setup_macos/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ runs:
# This has been replaced by the 'install qt' section below to manage
# qt6 versioning independently from the OS.
# brew install llvm@21 qt6
brew install llvm@21
brew install llvm@22
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrade to clang-tidy 22 for macos.

# The macos-26 runner ships with Homebrew llvm@20 linked into
# /usr/local/bin/ (clang, clang++, clang-format, clang-tidy, etc.).
# Use -sf to overwrite the existing clang-tidy with our llvm@21
# Use -sf to overwrite the existing clang-tidy with our llvm@22
# version, and remove clang/clang++ so that ccache-action
# (create-symlink: true) can create its own symlinks.
# clang-format is installed separately via pip (see below) so that
# both CI platforms use the version pinned by
# CLANG_FORMAT_CI_VERSION in the Makefile.
# Ref: https://github.com/actions/runner-images/blob/main/images/macos/macos-26-Readme.md
ln -sf "$(brew --prefix llvm@21)/bin/clang-tidy" "/usr/local/bin/clang-tidy"
ln -sf "$(brew --prefix llvm@22)/bin/clang-tidy" "/usr/local/bin/clang-tidy"
rm -f /usr/local/bin/clang /usr/local/bin/clang++ /usr/local/bin/clang-format

- name: install qt
Expand Down
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ find_program(
)
if(USE_CLANG_TIDY)
if(CLANG_TIDY_EXE)
set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-header-filter=/cpp/.\*/modmesh/.\*" "--extra-arg=-std=c++2b")
set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}"
"-header-filter=/cpp/.\*"
"--extra-arg=-std=c++23"
# FIXME: Remove --allow-no-checks in the future after figuring out
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is strange to have the Error: no checks enabled. with the clang-tidy v22 upgrade. I have to add --allow-no-checks to have tidy run through. We should revisit this in the future.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are using --allow-no-checks, it might be useful to add a CI step to print the enabled checks for visibility

# why the error message "Error: no checks enabled." appears with
# some files, after upgrading to clang-tidy-22.
# Related information (but not what we see in modmesh):
# https://github.com/llvm/llvm-project/issues/192713
"--allow-no-checks")
if(LINT_AS_ERRORS)
set(DO_CLANG_TIDY "${DO_CLANG_TIDY}" "-warnings-as-errors=*")
endif()
Expand Down
1 change: 1 addition & 0 deletions cpp/modmesh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ else () # MSVC
${COMMON_COMPILER_OPTIONS}
-Wno-unused-value # for PYBIND11_EXPAND_SIDE_EFFECTS in pybind11.h
-Wno-noexcept-type # GCC
-Wno-elaborated-enum-base # for apple accelerate/veclib
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to piggyback for another enhancement I am doing. -Welaborated-enum-base will be noisy.

)
endif () # MSVC

Expand Down
4 changes: 2 additions & 2 deletions cpp/modmesh/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <optional>
#include <sstream>

#if defined(_MSC_VER)
#ifdef _MSC_VER
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif
Expand Down Expand Up @@ -156,7 +156,7 @@ class [[deprecated("Use std::format instead")]] Formatter
// NOLINTNEXTLINE(google-explicit-constructor)
operator std::string() const { return m_stream.str(); }

enum ConvertToString
enum ConvertToString : std::uint8_t
{
to_str
};
Expand Down
4 changes: 3 additions & 1 deletion cpp/modmesh/buffer/BufferBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class BufferBase
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;

explicit operator bool() const { return bool(m_begin); }
explicit operator bool() const { return static_cast<bool>(m_begin); }
size_type size() const
{
return static_cast<size_type>(this->m_end - this->m_begin);
Expand Down Expand Up @@ -128,12 +128,14 @@ class BufferBase
{
}

public:
BufferBase(BufferBase const &) = delete;
BufferBase(BufferBase &&) = delete;
BufferBase & operator=(BufferBase const &) = delete;
BufferBase & operator=(BufferBase &&) = delete;
~BufferBase() = default;

protected:
void validate_range(size_t it) const
{
if (it >= size())
Expand Down
14 changes: 7 additions & 7 deletions cpp/modmesh/buffer/BufferExpander.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class BufferExpander
{
m_begin = m_concrete_buffer->data();
m_end = m_begin + m_concrete_buffer->size();
m_end_cap = m_begin + m_concrete_buffer->size();
m_end_cap = m_begin + m_concrete_buffer->size(); // NOLINT(cppcoreguidelines-prefer-member-initializer)
}

BufferExpander(std::shared_ptr<ConcreteBuffer> const & buf, bool clone, ctor_passkey const &)
Expand All @@ -98,9 +98,9 @@ class BufferExpander
{
}

BufferExpander(ctor_passkey const &)
explicit BufferExpander(ctor_passkey const &)
: BufferBase<BufferExpander>(nullptr, nullptr)
, m_alignment(0)
, m_alignment(0) // NOLINT(cppcoreguidelines-use-default-member-init,modernize-use-default-member-init)
{
}

Expand Down Expand Up @@ -151,7 +151,7 @@ class BufferExpander

std::shared_ptr<ConcreteBuffer> copy_concrete(size_type cap = 0) const;
std::shared_ptr<ConcreteBuffer> const & as_concrete(size_type cap = 0);
bool is_concrete() const { return bool(m_concrete_buffer); }
bool is_concrete() const { return static_cast<bool>(m_concrete_buffer); }

size_type alignment() const noexcept { return m_alignment; }

Expand All @@ -178,7 +178,7 @@ class BufferExpander
std::free(ptr);
}
#else
std::free(ptr);
std::free(ptr); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc)
#endif
}
};
Expand All @@ -197,13 +197,13 @@ class BufferExpander
#ifdef _WIN32
ptr = _aligned_malloc(nbytes, alignment);
#else
ptr = std::aligned_alloc(alignment, nbytes);
ptr = std::aligned_alloc(alignment, nbytes); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc)
#endif
}
else
{
// Use malloc instead of new[] so we can consistently use free in the deleter
ptr = std::malloc(nbytes);
ptr = std::malloc(nbytes); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc)
}
if (!ptr)
{
Expand Down
16 changes: 8 additions & 8 deletions cpp/modmesh/buffer/ConcreteBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ struct ConcreteBufferRemover

static void deallocate_memory(int8_t * p, size_t alignment)
{
if (alignment > 0)
if (alignment > 0) // NOLINT(bugprone-branch-clone)
{
#ifdef _WIN32
_aligned_free(p);
_aligned_free(p); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc)
#else
std::free(p);
std::free(p); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc)
#endif
}
else
{
std::free(p);
std::free(p); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc)
}
}

Expand Down Expand Up @@ -264,7 +264,7 @@ class ConcreteBuffer
return *this;
}

bool has_remover() const noexcept { return bool(m_data.get_deleter().remover); }
bool has_remover() const noexcept { return static_cast<bool>(m_data.get_deleter().remover); }
remover_type const & get_remover() const { return *m_data.get_deleter().remover; }
remover_type & get_remover() { return *m_data.get_deleter().remover; }

Expand All @@ -286,14 +286,14 @@ class ConcreteBuffer
{
validate_size_alignment(nbytes, alignment, "ConcreteBuffer::allocate");
#ifdef _WIN32
ptr = _aligned_malloc(nbytes, alignment);
ptr = _aligned_malloc(nbytes, alignment); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc)
#else
ptr = std::aligned_alloc(alignment, nbytes);
ptr = std::aligned_alloc(alignment, nbytes); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc)
#endif
}
else
{
ptr = std::malloc(nbytes);
ptr = std::malloc(nbytes); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc)
}
if (!ptr)
{
Expand Down
2 changes: 1 addition & 1 deletion cpp/modmesh/buffer/SimpleArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct DataTypeHasher
}
}; /* end struct DataTypeHasher */

// NOLINTNEXTLINE(misc-use-anonymous-namespace, cert-err58-cpp, cppcoreguidelines-avoid-non-const-global-variables, fuchsia-statically-constructed-objects)
// NOLINTNEXTLINE(misc-use-anonymous-namespace, cert-err58-cpp, bugprone-throwing-static-initialization, cppcoreguidelines-avoid-non-const-global-variables, fuchsia-statically-constructed-objects)
static std::unordered_map<std::string, DataType, DataTypeHasher> string_data_type_map = {
{"bool", DataType::Bool},
{"int8", DataType::Int8},
Expand Down
Loading
Loading