From 2451fbd02dbe80c6b2436b331c02631e2266249d Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 9 Sep 2024 10:31:23 +0000 Subject: [PATCH] apparently i was barking up the wrong tree, try something simpler --- common/check_internal.h | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/common/check_internal.h b/common/check_internal.h index 07d5a73099e13..1ce973d7d3de2 100644 --- a/common/check_internal.h +++ b/common/check_internal.h @@ -5,11 +5,8 @@ #ifndef CARBON_COMMON_CHECK_INTERNAL_H_ #define CARBON_COMMON_CHECK_INTERNAL_H_ -#include "llvm/Support/FormatVariadic.h" - -#ifdef NDEBUG #include "common/template_string.h" -#endif +#include "llvm/Support/FormatVariadic.h" namespace Carbon::Internal { @@ -26,29 +23,6 @@ namespace Carbon::Internal { // // The format string and values are directly passed to `llvm::formatv` which // handles all of the formatting of output. -// -// We have different forms of this in debug builds and normal builds to minimize -// the code size cost. -#ifndef NDEBUG -// Uses a runtime format string in debug builds to avoid encoding the format -// string into the mangle name and having a duplicate function for every single -// check function. -template -[[noreturn, gnu::cold]] auto CheckFail(const char* kind, const char* file, - int line, const char* condition_str, - const char* format_str, Ts&&... values) - -> void { - if constexpr (sizeof...(values) == 0) { - CheckFailImpl(kind, file, line, condition_str, format_str); - } else { - CheckFailImpl(kind, file, line, condition_str, - llvm::formatv(format_str, std::forward(values)...).str()); - } -} -#else -// Use a template parameter for the format string in optimized builds. This will -// result in essentially every check generating a separate function, but makes -// the impact on the caller slightly smaller. template [[noreturn, gnu::cold, clang::noinline, clang::preserve_most]] auto CheckFail( @@ -62,19 +36,9 @@ template (values)...).str()); } } -#endif } // namespace Carbon::Internal -// Dispatch helper between debug and optimized builds for the different -// formulation of the actual check function. -#ifndef NDEBUG -// Pass the format string as a runtime parameter in debug builds. -#define CARBON_INTERNAL_CHECK_IMPL_CALL(kind, file, line, condition_str, \ - format_str, ...) \ - Carbon::Internal::CheckFail(kind, file, line, condition_str, \ - format_str __VA_OPT__(, ) __VA_ARGS__) -#else // Pass the format string as a template parameter in optimized builds. Note that // the template arguments include commas and so require extra parentheses to use // within a macro. @@ -82,7 +46,6 @@ template ( \ __VA_ARGS__)) -#endif // Calls `CheckFail` with the provided message plus a newline and with no // parameters. This implements check messages without any formatted values.