Skip to content

Commit 54c01e3

Browse files
committed
Fix clang-tidy
1 parent 691703a commit 54c01e3

File tree

7 files changed

+71
-72
lines changed

7 files changed

+71
-72
lines changed

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# FIXME: all performance-* reports
33
# FIXME: all cert-* reports
44
Checks: -*,bugprone-*,cppcoreguidelines-slicing,mpi-*
5-
HeaderFilterRegex: '((^(?!\/share\/openPMD\/).*)*include\/openPMD\/.+\.hpp|src\/^(?!binding).+\.cpp$)'
5+
HeaderFilterRegex: '((^(?!.*share\/openPMD\/thirdParty).*)*include\/openPMD\/.+\.hpp|src\/^(?!binding).+\.cpp$)'

include/openPMD/auxiliary/Logging.hpp

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,36 +43,35 @@ enum class Level
4343
}; // Level
4444

4545
#if openPMD_HAVE_LOGGING
46-
static void
47-
set_level(Level level)
48-
{
49-
switch( level ) {
50-
case Level::TRACE:
51-
spdlog::set_level(spdlog::level::trace);
52-
return;
53-
case Level::DEBUG:
54-
spdlog::set_level(spdlog::level::debug);
55-
return;
56-
case Level::INFO:
57-
spdlog::set_level(spdlog::level::info);
58-
return;
59-
case Level::WARN:
60-
spdlog::set_level(spdlog::level::warn);
61-
return;
62-
case Level::ERROR:
63-
spdlog::set_level(spdlog::level::err);
64-
return;
65-
case Level::CRITICAL:
66-
spdlog::set_level(spdlog::level::critical);
67-
return;
68-
case Level::OFF:
69-
spdlog::set_level(spdlog::level::off);
70-
return;
71-
default:
72-
throw std::runtime_error("Logging level not supported!");
73-
}
46+
# define LOG_SET_LEVEL(LEVEL) { \
47+
[](openPMD::auxiliary::log::Level level) { \
48+
switch( level ) { \
49+
case openPMD::auxiliary::log::Level::TRACE: \
50+
spdlog::set_level(spdlog::level::trace); \
51+
return; \
52+
case openPMD::auxiliary::log::Level::DEBUG: \
53+
spdlog::set_level(spdlog::level::debug); \
54+
return; \
55+
case openPMD::auxiliary::log::Level::INFO: \
56+
spdlog::set_level(spdlog::level::info); \
57+
return; \
58+
case openPMD::auxiliary::log::Level::WARN: \
59+
spdlog::set_level(spdlog::level::warn); \
60+
return; \
61+
case openPMD::auxiliary::log::Level::ERROR: \
62+
spdlog::set_level(spdlog::level::err); \
63+
return; \
64+
case openPMD::auxiliary::log::Level::CRITICAL: \
65+
spdlog::set_level(spdlog::level::critical); \
66+
return; \
67+
case openPMD::auxiliary::log::Level::OFF: \
68+
spdlog::set_level(spdlog::level::off); \
69+
return; \
70+
default: \
71+
throw std::runtime_error("Logging level not supported!"); \
72+
} \
73+
}((LEVEL)); \
7474
}
75-
# define LOG_SET_LEVEL(LEVEL) { set_level((LEVEL)); }
7675
# define LOG_TRACE(...) { spdlog::trace(__VA_ARGS__); }
7776
# define LOG_DEBUG(...) { spdlog::debug(__VA_ARGS__); }
7877
# define LOG_INFO(...) { spdlog::info(__VA_ARGS__); }

share/openPMD/thirdParty/spdlog/include/spdlog/common.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ struct source_loc
210210
, funcname{""}
211211
{
212212
}
213-
SPDLOG_CONSTEXPR source_loc(const char *filename, int line, const char *funcname)
214-
: filename{filename}
215-
, line{static_cast<uint32_t>(line)}
216-
, funcname{funcname}
213+
SPDLOG_CONSTEXPR source_loc(const char *filename_, int line_, const char *funcname_)
214+
: filename{filename_}
215+
, line{static_cast<uint32_t>(line_)}
216+
, funcname{funcname_}
217217
{
218218
}
219219

share/openPMD/thirdParty/spdlog/include/spdlog/details/logger_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ inline spdlog::level::level_enum spdlog::logger::flush_level() const
352352

353353
inline bool spdlog::logger::should_flush_(const details::log_msg &msg)
354354
{
355-
auto flush_level = flush_level_.load(std::memory_order_relaxed);
356-
return (msg.level >= flush_level) && (msg.level != level::off);
355+
auto flush_level__ = flush_level_.load(std::memory_order_relaxed);
356+
return (msg.level >= flush_level__) && (msg.level != level::off);
357357
}
358358

359359
inline spdlog::level::level_enum spdlog::logger::default_level()

share/openPMD/thirdParty/spdlog/include/spdlog/fmt/bundled/core.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -999,17 +999,17 @@ class context_base {
999999
typedef Char char_type;
10001000
typedef basic_format_arg<Context> format_arg;
10011001

1002-
context_base(OutputIt out, basic_string_view<char_type> format_str,
1002+
context_base(OutputIt out_it, basic_string_view<char_type> format_str,
10031003
basic_format_args<Context> ctx_args,
10041004
locale_ref loc = locale_ref())
1005-
: parse_context_(format_str), out_(out), args_(ctx_args), loc_(loc) {}
1005+
: parse_context_(format_str), out_(out_it), args_(ctx_args), loc_(loc) {}
10061006

10071007
// Returns the argument with specified index.
10081008
format_arg do_get_arg(unsigned arg_id) {
1009-
format_arg arg = args_.get(arg_id);
1010-
if (!arg)
1009+
format_arg arg_ = args_.get(arg_id);
1010+
if (!arg_)
10111011
parse_context_.on_error("argument index out of range");
1012-
return arg;
1012+
return arg_;
10131013
}
10141014

10151015
// Checks if manual indexing is used and returns the argument with
@@ -1106,10 +1106,10 @@ class basic_format_context :
11061106
Constructs a ``basic_format_context`` object. References to the arguments are
11071107
stored in the object so make sure they have appropriate lifetimes.
11081108
*/
1109-
basic_format_context(OutputIt out, basic_string_view<char_type> format_str,
1109+
basic_format_context(OutputIt out_it, basic_string_view<char_type> format_str,
11101110
basic_format_args<basic_format_context> ctx_args,
11111111
internal::locale_ref loc = internal::locale_ref())
1112-
: base(out, format_str, ctx_args, loc) {}
1112+
: base(out_it, format_str, ctx_args, loc) {}
11131113

11141114
format_arg next_arg() {
11151115
return this->do_get_arg(this->parse_context().next_arg_id());

share/openPMD/thirdParty/spdlog/include/spdlog/fmt/bundled/format.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -927,12 +927,12 @@ class add_thousands_sep {
927927
explicit add_thousands_sep(basic_string_view<Char> sep)
928928
: sep_(sep), digit_index_(0) {}
929929

930-
void operator()(Char *&buffer) {
930+
void operator()(Char *&buf) {
931931
if (++digit_index_ % 3 != 0)
932932
return;
933-
buffer -= sep_.size();
933+
buf -= sep_.size();
934934
std::uninitialized_copy(sep_.data(), sep_.data() + sep_.size(),
935-
internal::make_checked(buffer, sep_.size()));
935+
internal::make_checked(buf, sep_.size()));
936936
}
937937

938938
enum { size = 1 };
@@ -955,74 +955,74 @@ inline wchar_t thousands_sep(locale_ref loc) {
955955
// thousands_sep is a functor that is called after writing each char to
956956
// add a thousands separator if necessary.
957957
template <typename UInt, typename Char, typename ThousandsSep>
958-
inline Char *format_decimal(Char *buffer, UInt value, int num_digits,
958+
inline Char *format_decimal(Char *buf, UInt value, int num_digits,
959959
ThousandsSep thousands_sep) {
960960
FMT_ASSERT(num_digits >= 0, "invalid digit count");
961-
buffer += num_digits;
962-
Char *end = buffer;
961+
buf += num_digits;
962+
Char *end = buf;
963963
while (value >= 100) {
964964
// Integer division is slow so do it for a group of two digits instead
965965
// of for every digit. The idea comes from the talk by Alexandrescu
966966
// "Three Optimization Tips for C++". See speed-test for a comparison.
967967
unsigned index = static_cast<unsigned>((value % 100) * 2);
968968
value /= 100;
969-
*--buffer = static_cast<Char>(data::DIGITS[index + 1]);
970-
thousands_sep(buffer);
971-
*--buffer = static_cast<Char>(data::DIGITS[index]);
972-
thousands_sep(buffer);
969+
*--buf = static_cast<Char>(data::DIGITS[index + 1]);
970+
thousands_sep(buf);
971+
*--buf = static_cast<Char>(data::DIGITS[index]);
972+
thousands_sep(buf);
973973
}
974974
if (value < 10) {
975-
*--buffer = static_cast<Char>('0' + value);
975+
*--buf = static_cast<Char>('0' + value);
976976
return end;
977977
}
978978
unsigned index = static_cast<unsigned>(value * 2);
979-
*--buffer = static_cast<Char>(data::DIGITS[index + 1]);
980-
thousands_sep(buffer);
981-
*--buffer = static_cast<Char>(data::DIGITS[index]);
979+
*--buf = static_cast<Char>(data::DIGITS[index + 1]);
980+
thousands_sep(buf);
981+
*--buf = static_cast<Char>(data::DIGITS[index]);
982982
return end;
983983
}
984984

985985
template <typename OutChar, typename UInt, typename Iterator,
986986
typename ThousandsSep>
987987
inline Iterator format_decimal(
988-
Iterator out, UInt value, int num_digits, ThousandsSep sep) {
988+
Iterator out_it, UInt value, int num_digits, ThousandsSep sep) {
989989
FMT_ASSERT(num_digits >= 0, "invalid digit count");
990990
typedef typename ThousandsSep::char_type char_type;
991991
// Buffer should be large enough to hold all digits (<= digits10 + 1).
992992
enum { max_size = std::numeric_limits<UInt>::digits10 + 1 };
993993
FMT_ASSERT(ThousandsSep::size <= 1, "invalid separator");
994-
char_type buffer[max_size + max_size / 3];
995-
auto end = format_decimal(buffer, value, num_digits, sep);
996-
return internal::copy_str<OutChar>(buffer, end, out);
994+
char_type buf[max_size + max_size / 3];
995+
auto end = format_decimal(buf, value, num_digits, sep);
996+
return internal::copy_str<OutChar>(buf, end, out_it);
997997
}
998998

999999
template <typename OutChar, typename It, typename UInt>
1000-
inline It format_decimal(It out, UInt value, int num_digits) {
1001-
return format_decimal<OutChar>(out, value, num_digits, no_thousands_sep());
1000+
inline It format_decimal(It out_it, UInt value, int num_digits) {
1001+
return format_decimal<OutChar>(out_it, value, num_digits, no_thousands_sep());
10021002
}
10031003

10041004
template <unsigned BASE_BITS, typename Char, typename UInt>
1005-
inline Char *format_uint(Char *buffer, UInt value, int num_digits,
1005+
inline Char *format_uint(Char *buf, UInt value, int num_digits,
10061006
bool upper = false) {
1007-
buffer += num_digits;
1008-
Char *end = buffer;
1007+
buf += num_digits;
1008+
Char *end = buf;
10091009
do {
10101010
const char *digits = upper ? "0123456789ABCDEF" : "0123456789abcdef";
10111011
unsigned digit = (value & ((1 << BASE_BITS) - 1));
1012-
*--buffer = static_cast<Char>(BASE_BITS < 4 ? static_cast<char>('0' + digit)
1012+
*--buf = static_cast<Char>(BASE_BITS < 4 ? static_cast<char>('0' + digit)
10131013
: digits[digit]);
10141014
} while ((value >>= BASE_BITS) != 0);
10151015
return end;
10161016
}
10171017

10181018
template <unsigned BASE_BITS, typename Char, typename It, typename UInt>
1019-
inline It format_uint(It out, UInt value, int num_digits,
1019+
inline It format_uint(It out_it, UInt value, int num_digits,
10201020
bool upper = false) {
10211021
// Buffer should be large enough to hold all digits (digits / BASE_BITS + 1)
10221022
// and null.
1023-
char buffer[std::numeric_limits<UInt>::digits / BASE_BITS + 2];
1024-
format_uint<BASE_BITS>(buffer, value, num_digits, upper);
1025-
return internal::copy_str<Char>(buffer, buffer + num_digits, out);
1023+
char buf[std::numeric_limits<UInt>::digits / BASE_BITS + 2];
1024+
format_uint<BASE_BITS>(buf, value, num_digits, upper);
1025+
return internal::copy_str<Char>(buf, buf + num_digits, out_it);
10261026
}
10271027

10281028
#ifndef _WIN32

src/IO/HDF5/HDF5IOHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,9 +817,9 @@ HDF5IOHandlerImpl::writeAttribute(Writable* writable,
817817
}
818818

819819
using DT = Datatype;
820+
LOG_TRACE("Writing HDF5 attribute value \"{}{}\" (dtype {})", concrete_h5_file_position(writable), name, datatypeToString(dtype));
820821
switch( dtype )
821822
{
822-
LOG_TRACE("Writing HDF5 attribute value \"{}{}\" (dtype {})", concrete_h5_file_position(writable), name, datatypeToString(dtype));
823823
case DT::CHAR:
824824
{
825825
char c = att.get< char >();

0 commit comments

Comments
 (0)