Skip to content

Commit

Permalink
progress4...
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Artsishevsky <polter.rnd@gmail.com>
  • Loading branch information
polter-rnd committed Feb 24, 2025
1 parent bc77a24 commit c0be69d
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 27 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
cpp_compiler: g++
- os: ubuntu-24.04
c_compiler: clang
cpp_compiler: clang++
cpp_compiler: clang++-19
- os: macos-15
c_compiler: clang
cpp_compiler: clang++
Expand Down Expand Up @@ -73,7 +73,18 @@ 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
- name: Install IWYU (Linux)
run: |
cd ..
git clone https://github.com/include-what-you-use/include-what-you-use.git -b clang_19
cd include-what-you-use
mkdir build && cd build
cmake -DCMAKE_PREFIX_PATH=/usr/lib/llvm-19 -DIWYU_RESOURCE_RELATIVE_TO=iwyu -DIWYU_RESOURCE_DIR=../share -DCMAKE_INSTALL_PREFIX=/opt/iwyu ..
make -j && sudo make install
- name: Install dependencies (Windows)
if: runner.os == 'Windows' && matrix.format_lib == 'fmtlib'
Expand All @@ -99,8 +110,9 @@ jobs:
-DENABLE_ANALYZERS=ON
-DENABLE_FORMATTERS=ON
-DENABLE_SANITIZERS=ON
${{ matrix.os == 'ubuntu-24.04' && '-DIwyu_EXECUTABLE=/opt/iwyu/bin/include-what-you-use' || '' }}
${{ matrix.format_lib == 'std' && '-DENABLE_FMTLIB_HO=OFF' || '' }}
${{ matrix.cpp_compiler == 'clang++' && '-DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-lc++abi"' || '' }}
${{ matrix.c_compiler == 'clang' && '-DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-lc++abi"' || '' }}
-S ${{ github.workspace }}
- name: Check formatting
Expand Down
13 changes: 9 additions & 4 deletions .iwyu-mappings
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@
{ include: [ "@<__mutex/.*>", "private", "<mutex>", "public" ] },
{ include: [ "@<__exception/.*>", "private", "<exception>", "public" ] },
{ include: [ "@<__system_error/.*>", "private", "<system_error>", "public" ] },
{ include: [ "@<__ostream/.*>", "private", "<ostream>", "public" ] },
{ include: [ "<__fwd/string_view.h>", "private", "<string_view>", "public" ] },
{ include: [ "<__hash_table>", "private", "<unordered_map>", "public" ] },
{ include: [ "<__hash_table>", "private", "<unordered_set>", "public" ] },
{ include: [ "<__locale>", "private", "<locale>", "public" ] },
# Bug on stdlibc++: std::tm is not from <cwchar>
{ symbol: [ "std::tm", "private", "<ctime>", "public" ] },
# Bug on stdlibc++ w/o fmtlib: std::pair is not from <iterator>
#{ symbol: [ "std::tm", "private", "<ctime>", "public" ] },
# Bug on stdlibc++: std::nullptr_t is not from <version>
{ symbol: [ "std::nullptr_t", "private", "<cstddef>", "public" ] },
# Bug on stdlibc++: std::pair is not from <iterator>
{ symbol: [ "std::pair", "private", "<utility>", "public" ] },
# Bug on stdlibc++ with fmtlib: std::vector is not from <format>
{ symbol: [ "std::vector", "private", "<vector>", "public" ] },
# Bug on libc++ w/o fmtlib: std::reference_wrapper is not from <type_traits>
{ symbol: [ "std::reference_wrapper", "private", "<functional>", "public" ] },
{ symbol: [ "std::copy", "private", "<algorithm>", "public" ] },
#{ symbol: [ "std::reference_wrapper", "private", "<functional>", "public" ] },
#{ symbol: [ "std::copy", "private", "<algorithm>", "public" ] },
# Bug on fmtlib: format_error::~format_error is not from "format.h"
{ include: [ "\"format.h\"", "private", "\"slimlog/format.h\"", "public" ] },
]
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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=.*
Expand Down
1 change: 1 addition & 0 deletions include/slimlog/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#else
#include <fmt/core.h>
#endif
#include <chrono>
#else
#include <array>
#endif
Expand Down
1 change: 0 additions & 1 deletion include/slimlog/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <format>
#endif

#include <chrono>
#include <concepts>
#include <cstring>
#include <iterator>
Expand Down
2 changes: 1 addition & 1 deletion include/slimlog/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class Logger {
* @return Shared pointer to the created sink.
*/
template<
template<typename, typename, std::size_t, typename>
template<typename, typename, std::size_t, typename> // For clang-format < 19
typename T,
std::size_t SinkBufferSize = DefaultBufferSize,
typename SinkAllocator = Allocator,
Expand Down
13 changes: 9 additions & 4 deletions include/slimlog/pattern-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <functional>
#include <iterator>
#include <limits>
#include <variant>

namespace SlimLog {

Expand Down Expand Up @@ -262,8 +263,10 @@ void Pattern<Char>::format_generic(auto& out, const auto& item, T data)
}

template<typename Char>
constexpr auto Pattern<Char>::parse_nonnegative_int(
const Char*& begin, const Char* end, int error_value) noexcept -> int
constexpr auto Pattern<Char>::parse_nonnegative_int( // For clang-format < 19
const Char*& begin,
const Char* end,
int error_value) noexcept -> int
{
unsigned value = 0;
unsigned prev = 0;
Expand Down Expand Up @@ -291,8 +294,10 @@ constexpr auto Pattern<Char>::parse_nonnegative_int(
}

template<typename Char>
constexpr auto Pattern<Char>::parse_align(
const Char* begin, const Char* end, Placeholder::StringSpecs& specs) -> const Char*
constexpr auto Pattern<Char>::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));
Expand Down
6 changes: 1 addition & 5 deletions include/slimlog/sink-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <algorithm> // IWYU pragma: keep
#include <algorithm>
#include <iterator>
#include <tuple>

Expand Down
7 changes: 4 additions & 3 deletions include/slimlog/sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -169,7 +168,9 @@ class FormattableSink : public Sink<String, Char> {
template<class T>
concept IsFormattableSink = requires(const T& arg) {
[]<typename String, typename Char, std::size_t BufferSize, typename Allocator>(
const FormattableSink<String, Char, BufferSize, Allocator>&) {}(arg);
const FormattableSink<String, Char, BufferSize, Allocator>&) {
/* For clang-format < 19 */
}(arg);
};

/**
Expand Down Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion include/slimlog/sinks/null_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "slimlog/sink.h"
#include "slimlog/util/types.h"

#include <string_view>
#include <utility>

namespace SlimLog {
Expand Down
1 change: 0 additions & 1 deletion include/slimlog/sinks/ostream_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <cstddef>
#include <memory>
#include <ostream>
#include <string_view>
#include <utility>

namespace SlimLog {
Expand Down
3 changes: 2 additions & 1 deletion include/slimlog/util/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

#pragma once

#include <algorithm> // IWYU pragma: keep
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <memory>
#include <type_traits>
#include <utility>

#ifdef SLIMLOG_FMTLIB
#if __has_include(<fmt/base.h>)
Expand Down
4 changes: 3 additions & 1 deletion include/slimlog/util/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@

#include <chrono>
#include <ctime>
#include <ratio>
#include <tuple>
#include <utility>

// Used by <chrono> in C++20
// IWYU pragma: no_include <ratio>

#ifdef _WIN32
#ifndef NOMINMAX
#define NOMINMAX
Expand Down
1 change: 1 addition & 0 deletions include/slimlog/util/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#pragma once

#include <cassert>
#include <string_view>
#include <type_traits>

namespace SlimLog::Util::Types {
Expand Down
1 change: 1 addition & 0 deletions include/slimlog/util/unicode.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <iterator>
#include <limits>
#include <stdexcept>
#include <type_traits>

namespace SlimLog::Util::Unicode {

Expand Down

0 comments on commit c0be69d

Please sign in to comment.