Introduce RTC_CHECK_NOTREACHED(), an always-checking RTC_NOTREACHED()

And use it in a few places that were using RTC_CHECK(false) or FATAL()
to do the exact same job. There should be no change in behavior.

Bug: none
Change-Id: I36d5e6bcf35fd41534e08a8c879fa0811b4f1967
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191963
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32567}
This commit is contained in:
Karl Wiberg
2020-11-08 00:49:37 +01:00
committed by Commit Bot
parent 9dfe2fce9a
commit c95b939667
42 changed files with 168 additions and 177 deletions

View File

@ -338,6 +338,22 @@ class FatalLogCall final {
const char* message_;
};
#if RTC_DCHECK_IS_ON
// Be helpful, and include file and line in the RTC_CHECK_NOTREACHED error
// message.
#define RTC_UNREACHABLE_FILE_AND_LINE_CALL_ARGS __FILE__, __LINE__
RTC_NORETURN RTC_EXPORT void UnreachableCodeReached(const char* file, int line);
#else
// Be mindful of binary size, and don't include file and line in the
// RTC_CHECK_NOTREACHED error message.
#define RTC_UNREACHABLE_FILE_AND_LINE_CALL_ARGS
RTC_NORETURN RTC_EXPORT void UnreachableCodeReached();
#endif
} // namespace webrtc_checks_impl
// The actual stream used isn't important. We reference |ignored| in the code
@ -430,6 +446,14 @@ class FatalLogCall final {
#define RTC_UNREACHABLE_CODE_HIT false
#define RTC_NOTREACHED() RTC_DCHECK(RTC_UNREACHABLE_CODE_HIT)
// Kills the process with an error message. Never returns. Use when you wish to
// assert that a point in the code is never reached.
#define RTC_CHECK_NOTREACHED() \
do { \
::rtc::webrtc_checks_impl::UnreachableCodeReached( \
RTC_UNREACHABLE_FILE_AND_LINE_CALL_ARGS); \
} while (0)
// TODO(bugs.webrtc.org/8454): Add an RTC_ prefix or rename differently.
#define FATAL() \
::rtc::webrtc_checks_impl::FatalLogCall<false>(__FILE__, __LINE__, \