CHECK fixes.

GitOrigin-RevId: 7f82d11913592bb241ab69975278ee8be2ce9d23
This commit is contained in:
levlam 2019-02-12 23:19:11 +03:00
parent 61288bd8ab
commit ffe53dcd12
7 changed files with 18 additions and 14 deletions

View File

@ -8,8 +8,6 @@
#include "td/utils/Slice-decl.h" #include "td/utils/Slice-decl.h"
#include "td/utils/logging.h"
#include <cstring> #include <cstring>
#include <type_traits> #include <type_traits>

View File

@ -8,7 +8,7 @@
#include "td/utils/common.h" #include "td/utils/common.h"
#include "td/utils/MovableValue.h" #include "td/utils/MovableValue.h"
#include "td/utils/Slice-decl.h" #include "td/utils/Slice.h"
#include <array> #include <array>
#include <cstdlib> #include <cstdlib>

View File

@ -6,7 +6,6 @@
// //
#include "td/utils/StringBuilder.h" #include "td/utils/StringBuilder.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h" #include "td/utils/misc.h"
#include "td/utils/port/thread_local.h" #include "td/utils/port/thread_local.h"
#include "td/utils/Slice.h" #include "td/utils/Slice.h"

View File

@ -7,7 +7,7 @@
#pragma once #pragma once
#include "td/utils/common.h" #include "td/utils/common.h"
#include "td/utils/Slice-decl.h" #include "td/utils/Slice.h"
#include "td/utils/StackAllocator.h" #include "td/utils/StackAllocator.h"
#include <cstdlib> #include <cstdlib>

View File

@ -5,9 +5,12 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// //
#include "td/utils/check.h" #include "td/utils/check.h"
#include "td/utils/logging.h" #include "td/utils/logging.h"
namespace td { namespace td {
namespace detail { namespace detail {
void process_check_error(const char *message, const char *file, int line) { void process_check_error(const char *message, const char *file, int line) {
::td::Logger(*log_interface, log_options, VERBOSITY_NAME(FATAL), Slice(file), line, Slice()) ::td::Logger(*log_interface, log_options, VERBOSITY_NAME(FATAL), Slice(file), line, Slice())
<< "Check `" << message << "` failed"; << "Check `" << message << "` failed";

View File

@ -5,22 +5,28 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// //
#pragma once #pragma once
#define DUMMY_CHECK(condition) ((void)(condition))
#define TD_DUMMY_CHECK(condition) ((void)(condition))
#define CHECK(condition) \ #define CHECK(condition) \
if (!(condition)) { \ if (!(condition)) { \
::td::detail::process_check_error(#condition, __FILE__, __LINE__); \ ::td::detail::process_check_error(#condition, __FILE__, __LINE__); \
} }
#ifdef TD_DEBUG // clang-format off
#define DCHECK CHECK #ifdef NDEBUG
#define DCHECK CHECK
#else #else
#define DCHECK DUMMY_CHECK #define DCHECK TD_DUMMY_CHECK
#endif #endif
// clang-format on
#define UNREACHABLE(x) CHECK(false && "unreachable") #define UNREACHABLE() ::td::detail::process_check_error("Unreachable", __FILE__, __LINE__)
namespace td { namespace td {
namespace detail { namespace detail {
[[noreturn]] void process_check_error(const char *message, const char *file, int line); [[noreturn]] void process_check_error(const char *message, const char *file, int line);
}
} // namespace detail
} // namespace td } // namespace td

View File

@ -25,7 +25,7 @@
#include "td/utils/common.h" #include "td/utils/common.h"
#include "td/utils/port/thread_local.h" #include "td/utils/port/thread_local.h"
#include "td/utils/Slice-decl.h" #include "td/utils/Slice.h"
#include "td/utils/StackAllocator.h" #include "td/utils/StackAllocator.h"
#include "td/utils/StringBuilder.h" #include "td/utils/StringBuilder.h"
@ -308,5 +308,3 @@ class TsLog : public LogInterface {
}; };
} // namespace td } // namespace td
#include "td/utils/Slice.h"