Skip to content

Commit

Permalink
FMT_NOEXCEPT -> noexcept; upgrade fmtlib to 9.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Rao Meng committed Sep 11, 2022
1 parent a8633d9 commit 51756c2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion bench/spdlog
Submodule spdlog updated 65 files
+9 −0 .gitignore
+24 −2 CMakeLists.txt
+2 −1 README.md
+2 −2 cmake/spdlog.pc.in
+3 −2 cmake/spdlogConfig.cmake.in
+19 −10 example/example.cpp
+4 −2 include/spdlog/async.h
+19 −17 include/spdlog/common.h
+5 −0 include/spdlog/details/circular_q.h
+4 −1 include/spdlog/details/file_helper-inl.h
+1 −1 include/spdlog/details/fmt_helper.h
+6 −0 include/spdlog/details/mpmc_blocking_q.h
+0 −4 include/spdlog/details/null_mutex.h
+2 −6 include/spdlog/details/os-inl.h
+0 −21 include/spdlog/details/periodic_worker-inl.h
+20 −1 include/spdlog/details/periodic_worker.h
+0 −7 include/spdlog/details/registry-inl.h
+8 −2 include/spdlog/details/registry.h
+9 −2 include/spdlog/details/thread_pool-inl.h
+1 −0 include/spdlog/details/thread_pool.h
+1 −1 include/spdlog/details/udp_client-windows.h
+9 −6 include/spdlog/fmt/bin_to_hex.h
+2 −0 include/spdlog/fmt/bundled/args.h
+970 −211 include/spdlog/fmt/bundled/chrono.h
+23 −12 include/spdlog/fmt/bundled/color.h
+14 −11 include/spdlog/fmt/bundled/compile.h
+490 −256 include/spdlog/fmt/bundled/core.h
+286 −263 include/spdlog/fmt/bundled/format-inl.h
+588 −314 include/spdlog/fmt/bundled/format.h
+30 −18 include/spdlog/fmt/bundled/os.h
+31 −77 include/spdlog/fmt/bundled/ostream.h
+12 −7 include/spdlog/fmt/bundled/printf.h
+436 −111 include/spdlog/fmt/bundled/ranges.h
+5 −5 include/spdlog/fmt/bundled/xchar.h
+22 −0 include/spdlog/fmt/ranges.h
+4 −0 include/spdlog/fwd.h
+13 −6 include/spdlog/logger.h
+47 −6 include/spdlog/pattern_formatter-inl.h
+3 −1 include/spdlog/pattern_formatter.h
+28 −5 include/spdlog/sinks/android_sink.h
+2 −2 include/spdlog/sinks/ansicolor_sink-inl.h
+3 −3 include/spdlog/sinks/daily_file_sink.h
+8 −0 include/spdlog/sinks/hourly_file_sink.h
+2 −5 include/spdlog/sinks/msvc_sink.h
+1 −5 include/spdlog/sinks/ringbuffer_sink.h
+24 −4 include/spdlog/sinks/rotating_file_sink-inl.h
+30 −14 include/spdlog/sinks/systemd_sink.h
+2 −2 include/spdlog/sinks/wincolor_sink-inl.h
+0 −5 include/spdlog/spdlog-inl.h
+9 −1 include/spdlog/spdlog.h
+1 −0 include/spdlog/stopwatch.h
+8 −2 include/spdlog/tweakme.h
+2 −2 include/spdlog/version.h
+0 −2 src/async.cpp
+42 −0 src/fmt.cpp
+1 −0 tests/includes.h
+18 −39 tests/test_daily_logger.cpp
+3 −15 tests/test_errors.cpp
+19 −8 tests/test_file_helper.cpp
+9 −0 tests/test_file_logging.cpp
+5 −21 tests/test_fmt_helper.cpp
+1 −2 tests/test_macros.cpp
+1 −1 tests/test_misc.cpp
+47 −58 tests/test_pattern_formatter.cpp
+16 −7 tests/test_stopwatch.cpp
2 changes: 1 addition & 1 deletion fmt
Submodule fmt updated 64 files
+6 −0 .github/issue_template.md
+3 −0 .github/workflows/doc.yml
+15 −0 .github/workflows/linux.yml
+3 −0 .github/workflows/macos.yml
+52 −20 .github/workflows/windows.yml
+4 −32 CMakeLists.txt
+519 −2 ChangeLog.rst
+13 −10 README.rst
+11 −2 doc/CMakeLists.txt
+113 −53 doc/api.rst
+5 −1 doc/build.py
+2 −2 doc/index.rst
+32 −5 doc/syntax.rst
+4 −4 include/fmt/args.h
+63 −61 include/fmt/chrono.h
+113 −100 include/fmt/color.h
+40 −71 include/fmt/compile.h
+481 −394 include/fmt/core.h
+807 −1,727 include/fmt/format-inl.h
+1,535 −422 include/fmt/format.h
+0 −2 include/fmt/locale.h
+26 −75 include/fmt/os.h
+124 −22 include/fmt/ostream.h
+7 −24 include/fmt/printf.h
+291 −362 include/fmt/ranges.h
+171 −0 include/fmt/std.h
+26 −33 include/fmt/xchar.h
+16 −93 src/format.cc
+21 −21 src/os.cc
+0 −43 support/appveyor-build.py
+0 −31 support/appveyor.yml
+1 −1 support/bazel/.bazelversion
+3 −4 support/bazel/BUILD.bazel
+16 −32 support/cmake/cxx14.cmake
+4 −1 support/cmake/fmt-config.cmake.in
+6 −0 support/manage.py
+1 −1 support/printable.py
+15 −14 test/CMakeLists.txt
+19 −1 test/chrono-test.cc
+6 −0 test/color-test.cc
+40 −2 test/compile-error-test/CMakeLists.txt
+1 −1 test/compile-fp-test.cc
+23 −7 test/compile-test.cc
+67 −12 test/core-test.cc
+18 −0 test/detect-stdfs.cc
+256 −86 test/format-impl-test.cc
+192 −71 test/format-test.cc
+2 −2 test/fuzzing/one-arg.cc
+2 −2 test/fuzzing/two-args.cc
+1 −1 test/gtest-extra-test.cc
+1 −1 test/gtest-extra.cc
+1 −1 test/gtest-extra.h
+1 −1 test/gtest/CMakeLists.txt
+1 −1 test/gtest/gmock-gtest-all.cc
+0 −8 test/module-test.cc
+9 −13 test/os-test.cc
+66 −45 test/ostream-test.cc
+2 −83 test/posix-mock-test.cc
+1 −5 test/printf-test.cc
+66 −5 test/ranges-test.cc
+79 −0 test/std-test.cc
+2 −3 test/test-main.cc
+4 −4 test/unicode-test.cc
+63 −44 test/xchar-test.cc
26 changes: 13 additions & 13 deletions fmtlog-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ fmtlogDetailT<> fmtlogDetailWrapper<_>::impl;

template<int _>
void fmtlogT<_>::registerLogInfo(uint32_t& logId, FormatToFn fn, const char* location,
LogLevel level, fmt::string_view fmtString) FMT_NOEXCEPT {
LogLevel level, fmt::string_view fmtString) noexcept {
auto& d = fmtlogDetailWrapper<>::impl;
std::lock_guard<std::mutex> lock(d.logInfoMutex);
if (logId) return;
Expand Down Expand Up @@ -522,7 +522,7 @@ void fmtlogT<_>::vformat_to(char* out, fmt::string_view fmt, fmt::format_args ar

template<int _>
typename fmtlogT<_>::SPSCVarQueueOPT::MsgHeader* fmtlogT<_>::allocMsg(uint32_t size,
bool q_full_cb) FMT_NOEXCEPT {
bool q_full_cb) noexcept {
auto& d = fmtlogDetailWrapper<>::impl;
if (threadBuffer == nullptr) preallocate();
auto ret = threadBuffer->varq.alloc(size);
Expand All @@ -532,12 +532,12 @@ typename fmtlogT<_>::SPSCVarQueueOPT::MsgHeader* fmtlogT<_>::allocMsg(uint32_t s

template<int _>
typename fmtlogT<_>::SPSCVarQueueOPT::MsgHeader*
fmtlogT<_>::SPSCVarQueueOPT::allocMsg(uint32_t size) FMT_NOEXCEPT {
fmtlogT<_>::SPSCVarQueueOPT::allocMsg(uint32_t size) noexcept {
return alloc(size);
}

template<int _>
void fmtlogT<_>::preallocate() FMT_NOEXCEPT {
void fmtlogT<_>::preallocate() noexcept {
fmtlogDetailWrapper<>::impl.preallocate();
}

Expand Down Expand Up @@ -572,22 +572,22 @@ void fmtlogT<_>::setLogFile(FILE* fp, bool manageFp) {
}

template<int _>
void fmtlogT<_>::setFlushDelay(int64_t ns) FMT_NOEXCEPT {
void fmtlogT<_>::setFlushDelay(int64_t ns) noexcept {
fmtlogDetailWrapper<>::impl.flushDelay = ns;
}

template<int _>
void fmtlogT<_>::flushOn(LogLevel flushLogLevel) FMT_NOEXCEPT {
void fmtlogT<_>::flushOn(LogLevel flushLogLevel) noexcept {
fmtlogDetailWrapper<>::impl.flushLogLevel = flushLogLevel;
}

template<int _>
void fmtlogT<_>::setFlushBufSize(uint32_t bytes) FMT_NOEXCEPT {
void fmtlogT<_>::setFlushBufSize(uint32_t bytes) noexcept {
fmtlogDetailWrapper<>::impl.flushBufSize = bytes;
}

template<int _>
void fmtlogT<_>::closeLogFile() FMT_NOEXCEPT {
void fmtlogT<_>::closeLogFile() noexcept {
fmtlogDetailWrapper<>::impl.closeLogFile();
}

Expand All @@ -597,20 +597,20 @@ void fmtlogT<_>::poll(bool forceFlush) {
}

template<int _>
void fmtlogT<_>::setThreadName(const char* name) FMT_NOEXCEPT {
void fmtlogT<_>::setThreadName(const char* name) noexcept {
preallocate();
threadBuffer->nameSize = fmt::format_to_n(threadBuffer->name, sizeof(fmtlog::threadBuffer->name), "{}", name).size;
}

template<int _>
void fmtlogT<_>::setLogCB(LogCBFn cb, LogLevel minCBLogLevel_) FMT_NOEXCEPT {
void fmtlogT<_>::setLogCB(LogCBFn cb, LogLevel minCBLogLevel_) noexcept {
auto& d = fmtlogDetailWrapper<>::impl;
d.logCB = cb;
d.minCBLogLevel = minCBLogLevel_;
}

template<int _>
void fmtlogT<_>::setLogQFullCB(LogQFullCBFn cb, void* userData) FMT_NOEXCEPT {
void fmtlogT<_>::setLogQFullCB(LogQFullCBFn cb, void* userData) noexcept {
auto& d = fmtlogDetailWrapper<>::impl;
d.logQFullCB = cb;
d.logQFullCBArg = userData;
Expand All @@ -622,12 +622,12 @@ void fmtlogT<_>::setHeaderPattern(const char* pattern) {
}

template<int _>
void fmtlogT<_>::startPollingThread(int64_t pollInterval) FMT_NOEXCEPT {
void fmtlogT<_>::startPollingThread(int64_t pollInterval) noexcept {
fmtlogDetailWrapper<>::impl.startPollingThread(pollInterval);
}

template<int _>
void fmtlogT<_>::stopPollingThread() FMT_NOEXCEPT {
void fmtlogT<_>::stopPollingThread() noexcept {
fmtlogDetailWrapper<>::impl.stopPollingThread();
}

Expand Down
40 changes: 20 additions & 20 deletions fmtlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class fmtlogT
};

// Preallocate thread queue for current thread
static void preallocate() FMT_NOEXCEPT;
static void preallocate() noexcept;

// Set the file for logging
static void setLogFile(const char* filename, bool truncate = false);
Expand All @@ -114,13 +114,13 @@ class fmtlogT

// Set flush delay in nanosecond
// If there's msg older than ns in the buffer, flush will be triggered
static void setFlushDelay(int64_t ns) FMT_NOEXCEPT;
static void setFlushDelay(int64_t ns) noexcept;

// If current msg has level >= flushLogLevel, flush will be triggered
static void flushOn(LogLevel flushLogLevel) FMT_NOEXCEPT;
static void flushOn(LogLevel flushLogLevel) noexcept;

// If file buffer has more than specified bytes, flush will be triggered
static void setFlushBufSize(uint32_t bytes) FMT_NOEXCEPT;
static void setFlushBufSize(uint32_t bytes) noexcept;

// callback signature user can register
// ns: nanosecond timestamp
Expand All @@ -136,36 +136,36 @@ class fmtlogT
size_t logFilePos);

// Set a callback function for all log msgs with a mininum log level
static void setLogCB(LogCBFn cb, LogLevel minCBLogLevel) FMT_NOEXCEPT;
static void setLogCB(LogCBFn cb, LogLevel minCBLogLevel) noexcept;

typedef void (*LogQFullCBFn)(void* userData);
static void setLogQFullCB(LogQFullCBFn cb, void* userData) FMT_NOEXCEPT;
static void setLogQFullCB(LogQFullCBFn cb, void* userData) noexcept;

// Close the log file and subsequent msgs will not be written into the file,
// but callback function can still be used
static void closeLogFile() FMT_NOEXCEPT;
static void closeLogFile() noexcept;

// Set log header pattern with fmt named arguments
static void setHeaderPattern(const char* pattern);

// Set a name for current thread, it'll be shown in {t} part in header pattern
static void setThreadName(const char* name) FMT_NOEXCEPT;
static void setThreadName(const char* name) noexcept;

// Set current log level, lower level log msgs will be discarded
static inline void setLogLevel(LogLevel logLevel) FMT_NOEXCEPT;
static inline void setLogLevel(LogLevel logLevel) noexcept;

// Get current log level
static inline LogLevel getLogLevel() FMT_NOEXCEPT;
static inline LogLevel getLogLevel() noexcept;

// return true if passed log level is not lower than current log level
static inline bool checkLogLevel(LogLevel logLevel) FMT_NOEXCEPT;
static inline bool checkLogLevel(LogLevel logLevel) noexcept;

// Run a polling thread in the background with a polling interval
// Note that user must not call poll() himself when the thread is running
static void startPollingThread(int64_t pollInterval = 1000000) FMT_NOEXCEPT;
static void startPollingThread(int64_t pollInterval = 1000000) noexcept;

// Stop the polling thread
static void stopPollingThread() FMT_NOEXCEPT;
static void stopPollingThread() noexcept;

// https://github.com/MengRao/SPSC_Queue
class SPSCVarQueueOPT
Expand All @@ -180,7 +180,7 @@ class fmtlogT
};
static constexpr uint32_t BLK_CNT = (1 << 20) / sizeof(MsgHeader);

MsgHeader* allocMsg(uint32_t size) FMT_NOEXCEPT;
MsgHeader* allocMsg(uint32_t size) noexcept;

MsgHeader* alloc(uint32_t size) {
size += sizeof(MsgHeader);
Expand Down Expand Up @@ -374,15 +374,15 @@ class fmtlogT
int& argIdx, std::vector<fmt::basic_format_arg<Context>>& args);

static void registerLogInfo(uint32_t& logId, FormatToFn fn, const char* location, LogLevel level,
fmt::string_view fmtString) FMT_NOEXCEPT;
fmt::string_view fmtString) noexcept;

static void vformat_to(MemoryBuffer& out, fmt::string_view fmt, fmt::format_args args);

static size_t formatted_size(fmt::string_view fmt, fmt::format_args args);

static void vformat_to(char* out, fmt::string_view fmt, fmt::format_args args);

static typename SPSCVarQueueOPT::MsgHeader* allocMsg(uint32_t size, bool logQFullCB) FMT_NOEXCEPT;
static typename SPSCVarQueueOPT::MsgHeader* allocMsg(uint32_t size, bool logQFullCB) noexcept;

TSCNS tscns;

Expand Down Expand Up @@ -668,7 +668,7 @@ class fmtlogT
inline void log(
uint32_t& logId, int64_t tsc, const char* location, LogLevel level,
fmt::format_string<typename fmtlogdetail::UnrefPtr<fmt::remove_cvref_t<Args>>::type...> format,
Args&&... args) FMT_NOEXCEPT {
Args&&... args) noexcept {
if (!logId) {
auto unnamed_format = unNameFormat<false>(fmt::string_view(format), nullptr, args...);
registerLogInfo(logId, formatTo<Args...>, location, level, unnamed_format);
Expand Down Expand Up @@ -729,17 +729,17 @@ template<int _>
fmtlog fmtlogWrapper<_>::impl;

template<int _>
inline void fmtlogT<_>::setLogLevel(LogLevel logLevel) FMT_NOEXCEPT {
inline void fmtlogT<_>::setLogLevel(LogLevel logLevel) noexcept {
fmtlogWrapper<>::impl.currentLogLevel = logLevel;
}

template<int _>
inline typename fmtlogT<_>::LogLevel fmtlogT<_>::getLogLevel() FMT_NOEXCEPT {
inline typename fmtlogT<_>::LogLevel fmtlogT<_>::getLogLevel() noexcept {
return fmtlogWrapper<>::impl.currentLogLevel;
}

template<int _>
inline bool fmtlogT<_>::checkLogLevel(LogLevel logLevel) FMT_NOEXCEPT {
inline bool fmtlogT<_>::checkLogLevel(LogLevel logLevel) noexcept {
#ifdef FMTLOG_NO_CHECK_LEVEL
return true;
#else
Expand Down
4 changes: 2 additions & 2 deletions test/enc_dec_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct fmt::formatter<MyType> : formatter<int>
{
// parse is inherited from formatter<string_view>.
template<typename FormatContext>
auto format(const MyType& val, FormatContext& ctx) {
auto format(const MyType& val, FormatContext& ctx) const {
return formatter<int>::format(val.v, ctx);
}
};
Expand All @@ -51,7 +51,7 @@ struct fmt::formatter<MovableType> : formatter<int>
template<typename S, typename... Args>
void test(const S& format, Args&&... args) {
fmt::detail::check_format_string<Args...>(format);
auto sv = fmt::to_string_view(format);
auto sv = fmt::detail::to_string_view(format);
size_t formatted_size = fmt::formatted_size(fmt::runtime(sv), std::forward<Args>(args)...);
string ans = fmt::format(fmt::runtime(sv), std::forward<Args>(args)...);
assert(ans.size() == formatted_size);
Expand Down

0 comments on commit 51756c2

Please sign in to comment.