diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 2bbe9ec..2fffdc1 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -35,8 +35,8 @@ jobs: c_compiler: gcc cpp_compiler: g++ - os: ubuntu-24.04 - c_compiler: clang - cpp_compiler: clang++ + c_compiler: clang-19 + cpp_compiler: clang++-19 - os: macos-15 c_compiler: clang cpp_compiler: clang++ @@ -73,7 +73,15 @@ jobs: - name: Install dependencies (Linux) if: runner.os == 'Linux' - run: sudo apt-get install -y libfmt-dev clang-tidy clang-format cmake-format cppcheck iwyu libc++-dev libc++abi-dev + run: | + sudo apt-get install -y clang-tidy-19 clang-format-19 libclang-19-dev \ + libc++-dev libc++abi-dev libfmt-dev cmake-format cppcheck + cd .. + git clone https://github.com/include-what-you-use/include-what-you-use.git + cd include-what-you-use + mkdir build && cd build + cmake -DCMAKE_PREFIX_PATH=/usr/lib/llvm-19 .. + make -j install - name: Install dependencies (Windows) if: runner.os == 'Windows' && matrix.format_lib == 'fmtlib' diff --git a/.iwyu-mappings b/.iwyu-mappings index 074f5b4..62ebdf4 100644 --- a/.iwyu-mappings +++ b/.iwyu-mappings @@ -8,17 +8,22 @@ { include: [ "@<__mutex/.*>", "private", "", "public" ] }, { include: [ "@<__exception/.*>", "private", "", "public" ] }, { include: [ "@<__system_error/.*>", "private", "", "public" ] }, + { include: [ "@<__ostream/.*>", "private", "", "public" ] }, { include: [ "<__fwd/string_view.h>", "private", "", "public" ] }, { include: [ "<__hash_table>", "private", "", "public" ] }, { include: [ "<__hash_table>", "private", "", "public" ] }, { include: [ "<__locale>", "private", "", "public" ] }, # Bug on stdlibc++: std::tm is not from - { symbol: [ "std::tm", "private", "", "public" ] }, - # Bug on stdlibc++ w/o fmtlib: std::pair is not from + #{ symbol: [ "std::tm", "private", "", "public" ] }, + # Bug on stdlibc++: std::nullptr_t is not from + { symbol: [ "std::nullptr_t", "private", "", "public" ] }, + # Bug on stdlibc++: std::pair is not from { symbol: [ "std::pair", "private", "", "public" ] }, + # Bug on stdlibc++ with fmtlib: std::vector is not from + { symbol: [ "std::vector", "private", "", "public" ] }, # Bug on libc++ w/o fmtlib: std::reference_wrapper is not from - { symbol: [ "std::reference_wrapper", "private", "", "public" ] }, - { symbol: [ "std::copy", "private", "", "public" ] }, + #{ symbol: [ "std::reference_wrapper", "private", "", "public" ] }, + #{ symbol: [ "std::copy", "private", "", "public" ] }, # Bug on fmtlib: format_error::~format_error is not from "format.h" - { include: [ "\"format.h\"", "private", "\"slimlog/format.h\"", "public" ] }, + #{ include: [ "\"format.h\"", "private", "\"slimlog/format.h\"", "public" ] }, ] diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fe2d89..c9e1a03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,7 @@ if(ENABLE_FORMATTERS) add_code_format_targets( CHECK_TARGET formatcheck FORMAT_TARGET format - SOURCE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} + SOURCE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src EXCLUDE_DIRS ${CMAKE_BINARY_DIR} ) endif() @@ -80,7 +80,7 @@ if(ENABLE_ANALYZERS) set(CPPCHECK_MIN_VERSION 2.10) set(CLANG_TIDY_MIN_VERSION 17.0) set(CLANG_FORMAT_MIN_VERSION 17.0) - set(IWYU_MIN_VERSION 0.21) + set(IWYU_MIN_VERSION 0.23) include(StaticCodeAnalysis) enable_static_code_analysis( CLANG_TIDY_EXTRA_ARGS -header-filter=.* diff --git a/include/slimlog/format-inl.h b/include/slimlog/format-inl.h index c413978..3b6d9c5 100644 --- a/include/slimlog/format-inl.h +++ b/include/slimlog/format-inl.h @@ -15,6 +15,7 @@ #else #include #endif +#include #else #include #endif diff --git a/include/slimlog/format.h b/include/slimlog/format.h index 3074694..7e0ba19 100644 --- a/include/slimlog/format.h +++ b/include/slimlog/format.h @@ -22,7 +22,6 @@ #include #endif -#include #include #include #include diff --git a/include/slimlog/logger.h b/include/slimlog/logger.h index 6e6fd0b..28c71e9 100644 --- a/include/slimlog/logger.h +++ b/include/slimlog/logger.h @@ -139,7 +139,7 @@ class Logger { * @return Shared pointer to the created sink. */ template< - template + template // For clang-format < 19 typename T, std::size_t SinkBufferSize = DefaultBufferSize, typename SinkAllocator = Allocator, diff --git a/include/slimlog/pattern-inl.h b/include/slimlog/pattern-inl.h index a86c492..c8ed5cf 100644 --- a/include/slimlog/pattern-inl.h +++ b/include/slimlog/pattern-inl.h @@ -16,6 +16,7 @@ #include #include #include +#include namespace SlimLog { @@ -262,8 +263,10 @@ void Pattern::format_generic(auto& out, const auto& item, T data) } template -constexpr auto Pattern::parse_nonnegative_int( - const Char*& begin, const Char* end, int error_value) noexcept -> int +constexpr auto Pattern::parse_nonnegative_int( // For clang-format < 19 + const Char*& begin, + const Char* end, + int error_value) noexcept -> int { unsigned value = 0; unsigned prev = 0; @@ -291,8 +294,10 @@ constexpr auto Pattern::parse_nonnegative_int( } template -constexpr auto Pattern::parse_align( - const Char* begin, const Char* end, Placeholder::StringSpecs& specs) -> const Char* +constexpr auto Pattern::parse_align( // For clang-format < 19 + const Char* begin, + const Char* end, + Placeholder::StringSpecs& specs) -> const Char* { auto align = Placeholder::StringSpecs::Align::None; auto* ptr = std::next(begin, Util::Unicode::code_point_length(begin)); diff --git a/include/slimlog/sink-inl.h b/include/slimlog/sink-inl.h index d515893..5d308bd 100644 --- a/include/slimlog/sink-inl.h +++ b/include/slimlog/sink-inl.h @@ -10,11 +10,7 @@ #include "slimlog/sink.h" // IWYU pragma: associated #include "slimlog/util/os.h" -#ifndef SLIMLOG_HEADER_ONLY -#include "slimlog/logger.h" -#endif - -#include // IWYU pragma: keep +#include #include #include diff --git a/include/slimlog/sink.h b/include/slimlog/sink.h index 7b3a8d2..635b5a4 100644 --- a/include/slimlog/sink.h +++ b/include/slimlog/sink.h @@ -9,7 +9,6 @@ #include "slimlog/level.h" #include "slimlog/location.h" #include "slimlog/pattern.h" -#include "slimlog/policy.h" #include "slimlog/record.h" #include "slimlog/util/types.h" @@ -169,7 +168,9 @@ class FormattableSink : public Sink { template concept IsFormattableSink = requires(const T& arg) { []( - const FormattableSink&) {}(arg); + const FormattableSink&) { + /* For clang-format < 19 */ + }(arg); }; /** @@ -375,7 +376,7 @@ class SinkDriver final { * @param location The source code location where the log record is created. * @return A new log record of type `RecordType`. */ - static auto + static auto // For clang-format < 19 create_record(Level level, StringViewType category, Location location) -> RecordType; private: diff --git a/include/slimlog/sinks/null_sink.h b/include/slimlog/sinks/null_sink.h index cc6a305..be777cf 100644 --- a/include/slimlog/sinks/null_sink.h +++ b/include/slimlog/sinks/null_sink.h @@ -8,7 +8,6 @@ #include "slimlog/sink.h" #include "slimlog/util/types.h" -#include #include namespace SlimLog { diff --git a/include/slimlog/sinks/ostream_sink.h b/include/slimlog/sinks/ostream_sink.h index 356e26c..6b25818 100644 --- a/include/slimlog/sinks/ostream_sink.h +++ b/include/slimlog/sinks/ostream_sink.h @@ -12,7 +12,6 @@ #include #include #include -#include #include namespace SlimLog { diff --git a/include/slimlog/util/buffer.h b/include/slimlog/util/buffer.h index 7816f61..54d314f 100644 --- a/include/slimlog/util/buffer.h +++ b/include/slimlog/util/buffer.h @@ -5,11 +5,12 @@ #pragma once -#include // IWYU pragma: keep +#include #include #include #include #include +#include #ifdef SLIMLOG_FMTLIB #if __has_include() diff --git a/include/slimlog/util/os.h b/include/slimlog/util/os.h index bc2d608..6386511 100644 --- a/include/slimlog/util/os.h +++ b/include/slimlog/util/os.h @@ -12,10 +12,12 @@ #include #include -#include #include #include +// Used by in C++20 +// IWYU pragma: no_include + #ifdef _WIN32 #ifndef NOMINMAX #define NOMINMAX diff --git a/include/slimlog/util/types.h b/include/slimlog/util/types.h index c57b767..0758806 100644 --- a/include/slimlog/util/types.h +++ b/include/slimlog/util/types.h @@ -6,6 +6,7 @@ #pragma once #include +#include #include namespace SlimLog::Util::Types { diff --git a/include/slimlog/util/unicode.h b/include/slimlog/util/unicode.h index 60731bc..41ef6b6 100644 --- a/include/slimlog/util/unicode.h +++ b/include/slimlog/util/unicode.h @@ -18,6 +18,7 @@ #include #include #include +#include namespace SlimLog::Util::Unicode {