From 064f0b712c783c8c1638c4be674e1a633a0a78e9 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 19 Jul 2019 17:03:58 -0700 Subject: [PATCH] ircd::log: Fixes for clang DCE. --- include/ircd/ctx/slice_usage_warning.h | 13 +++- include/ircd/logger.h | 101 +++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 4 deletions(-) diff --git a/include/ircd/ctx/slice_usage_warning.h b/include/ircd/ctx/slice_usage_warning.h index 22aac5b46..5b2eb6ecf 100644 --- a/include/ircd/ctx/slice_usage_warning.h +++ b/include/ircd/ctx/slice_usage_warning.h @@ -35,10 +35,15 @@ struct ircd::ctx::this_ctx::slice_usage_warning #else struct ircd::ctx::this_ctx::slice_usage_warning { + #if defined(__clang__) + template + slice_usage_warning(const string_view &fmt, args&&...) + {} + #else + // In at least gcc 6.3.0 20170519, template param packs are not DCE'ed + // so legacy varargs are used here. slice_usage_warning(const string_view &fmt, ...) - { - // In at least gcc 6.3.0 20170519, template param packs are not DCE'ed - // so legacy varargs are used here. - } + {} + #endif }; #endif diff --git a/include/ircd/logger.h b/include/ircd/logger.h index 4f1e228ef..4b98b0479 100644 --- a/include/ircd/logger.h +++ b/include/ircd/logger.h @@ -196,6 +196,19 @@ struct ircd::log::debug vlog(general, level::DEBUG, fmt, va_rtti{std::forward(a)...}); } }; +#elif defined(__clang__) +struct ircd::log::debug +{ + template + debug(const log &log, const string_view &fmt, args&&... a) + { + } + + template + debug(const string_view &fmt, args&&... a) + { + } +}; #else struct ircd::log::debug { @@ -226,6 +239,19 @@ struct ircd::log::dwarning vlog(general, level::DWARNING, fmt, va_rtti{std::forward(a)...}); } }; +#elif defined(__clang__) +struct ircd::log::dwarning +{ + template + dwarning(const log &log, const string_view &fmt, args&&... a) + { + } + + template + dwarning(const string_view &fmt, args&&... a) + { + } +}; #else struct ircd::log::dwarning { @@ -256,6 +282,19 @@ struct ircd::log::derror vlog(general, level::DERROR, fmt, va_rtti{std::forward(a)...}); } }; +#elif defined(__clang__) +struct ircd::log::derror +{ + template + derror(const log &log, const string_view &fmt, args&&... a) + { + } + + template + derror(const string_view &fmt, args&&... a) + { + } +}; #else struct ircd::log::derror { @@ -286,6 +325,19 @@ struct ircd::log::info vlog(general, level::INFO, fmt, va_rtti{std::forward(a)...}); } }; +#elif defined(__clang__) +struct ircd::log::info +{ + template + info(const log &log, const string_view &fmt, args&&... a) + { + } + + template + info(const string_view &fmt, args&&... a) + { + } +}; #else struct ircd::log::info { @@ -316,6 +368,16 @@ struct ircd::log::notice vlog(general, level::NOTICE, fmt, va_rtti{std::forward(a)...}); } }; +#elif defined(__clang__) + template + notice(const log &log, const string_view &fmt, args&&... a) + { + } + + template + notice(const string_view &fmt, args&&... a) + { + } #else struct ircd::log::notice { @@ -346,6 +408,19 @@ struct ircd::log::warning vlog(general, level::WARNING, fmt, va_rtti{std::forward(a)...}); } }; +#elif defined(__clang__) +struct ircd::log::warning +{ + template + warning(const log &log, const string_view &fmt, args&&... a) + { + } + + template + warning(const string_view &fmt, args&&... a) + { + } +}; #else struct ircd::log::warning { @@ -376,6 +451,19 @@ struct ircd::log::error vlog(general, level::ERROR, fmt, va_rtti{std::forward(a)...}); } }; +#elif defined(__clang__) +struct ircd::log::error +{ + template + error(const log &log, const string_view &fmt, args&&... a) + { + } + + template + error(const string_view &fmt, args&&... a) + { + } +}; #else struct ircd::log::error { @@ -435,6 +523,19 @@ struct ircd::log::critical vlog(general, level::CRITICAL, fmt, va_rtti{std::forward(a)...}); } }; +#elif defined(__clang__) +struct ircd::log::critical +{ + template + critical(const log &log, const string_view &fmt, args&&... a) + { + } + + template + critical(const string_view &fmt, args&&... a) + { + } +}; #else struct ircd::log::critical {