CHECK: fixes

GitOrigin-RevId: 5bccb4634a0c77e159ce3cdf80c37ff8a500bbd0
This commit is contained in:
Arseny Smirnov 2019-02-12 20:48:13 +03:00
parent 20bfcaa979
commit 61288bd8ab
4 changed files with 20 additions and 11 deletions

View File

@ -14,6 +14,7 @@
#include "td/telegram/files/FileDb.h" #include "td/telegram/files/FileDb.h"
#include "td/telegram/files/FileLoaderUtils.h" #include "td/telegram/files/FileLoaderUtils.h"
#include "td/telegram/files/FileLocation.h" #include "td/telegram/files/FileLocation.h"
#include "td/telegram/files/FileLocation.hpp"
#include "td/telegram/Global.h" #include "td/telegram/Global.h"
#include "td/telegram/misc.h" #include "td/telegram/misc.h"
#include "td/telegram/SecureStorage.h" #include "td/telegram/SecureStorage.h"

View File

@ -8,8 +8,11 @@
#include "td/utils/logging.h" #include "td/utils/logging.h"
namespace td { namespace td {
namespace detail { namespace detail {
void do_check(const char *message, const char *file, int line) { void process_check_error(const char *message, const char *file, int line) {
LOG(FATAL) << "TODO CHECK"; ::td::Logger(*log_interface, log_options, VERBOSITY_NAME(FATAL), Slice(file), line, Slice())
<< "Check `" << message << "` failed";
::td::process_fatal_error(PSLICE() << "Check `" << message << "` failed in " << file << " at " << line);
} }
} // namespace detail } // namespace detail
} // namespace td } // namespace td

View File

@ -5,13 +5,22 @@
// 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 CHECK(x) \ #define DUMMY_CHECK(condition) ((void)(condition))
if (!(x)) { \ #define CHECK(condition) \
::td::detail::do_check(#x, __FILE__, __LINE__); \ if (!(condition)) { \
::td::detail::process_check_error(#condition, __FILE__, __LINE__); \
} }
#define DCHECK(x) CHECK(x)
#ifdef TD_DEBUG
#define DCHECK CHECK
#else
#define DCHECK DUMMY_CHECK
#endif
#define UNREACHABLE(x) CHECK(false && "unreachable")
namespace td { namespace td {
namespace detail { namespace detail {
void do_check(const char *message, const char *file, int line); [[noreturn]] void process_check_error(const char *message, const char *file, int line);
} }
} // namespace td } // namespace td

View File

@ -100,10 +100,6 @@ inline bool no_return_func() {
#endif #endif
// clang-format on // clang-format on
#define UNREACHABLE() \
LOG(FATAL); \
::td::process_fatal_error("Unreachable in " __FILE__ " at " TD_DEFINE_STR(__LINE__))
constexpr int VERBOSITY_NAME(PLAIN) = -1; constexpr int VERBOSITY_NAME(PLAIN) = -1;
constexpr int VERBOSITY_NAME(FATAL) = 0; constexpr int VERBOSITY_NAME(FATAL) = 0;
constexpr int VERBOSITY_NAME(ERROR) = 1; constexpr int VERBOSITY_NAME(ERROR) = 1;