From e341175300e0447f34547abfe287b3fae3fb599e Mon Sep 17 00:00:00 2001 From: fghzxm Date: Sun, 27 Mar 2022 20:29:27 +0800 Subject: [PATCH] Suppress clang-tidy warnings in format-inl.h In non-header-only mode, format.cc includes format-inl.h which defines a number of functions without the `inline` keyword. This triggers a clang-tidy warning (misc-definitions-in-headers) about non-inline functions defined in a header file. This commit adds a directive to stop clang-tidy 14+ from emitting those warnings in format-inl.h. --- include/fmt/format-inl.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 9a99b7a1..567ba963 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -28,6 +28,14 @@ #include "format.h" +// In non-header-only mode, functions in this file are compiled by format.cc +// once and exclusively, so we define functions without `inline`; +// this triggers a clang-tidy warning (misc-definitions-in-headers). +// If the user is using clang-tidy 14+, we can suppress it. +#ifndef FMT_HEADER_ONLY +// NOLINTBEGIN(misc-definitions-in-headers) +#endif + FMT_BEGIN_NAMESPACE namespace detail { @@ -2590,4 +2598,8 @@ FMT_FUNC auto is_printable(uint32_t cp) -> bool { FMT_END_NAMESPACE +#ifndef FMT_HEADER_ONLY +// NOLINTEND(misc-definitions-in-headers) +#endif + #endif // FMT_FORMAT_INL_H_