Update RTC_CHECK and RTC_LOG macros so they work when called from xxxxx::rtc namespaces
Adding :: before rtc allow us to use the macro in nested rtc namespace for external components like
namespace xxxxxxx {
namespace rtc {
RTC_CHECK(true);
}
}
Bug: webrtc:11400
Change-Id: I79349b847c3fce8197c82aec31b672a1a16e5388
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/169683
Commit-Queue: Jiawei Ou <ouj@fb.com>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30684}
This commit is contained in:
parent
43d8e93fa7
commit
14e5f0b2cb
@ -345,17 +345,17 @@ class FatalLogCall final {
|
||||
// in a particularly convoluted way with an extra ?: because that appears to be
|
||||
// the simplest construct that keeps Visual Studio from complaining about
|
||||
// condition being unused).
|
||||
#define RTC_EAT_STREAM_PARAMETERS(ignored) \
|
||||
(true ? true : ((void)(ignored), true)) \
|
||||
? static_cast<void>(0) \
|
||||
: rtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
|
||||
rtc::webrtc_checks_impl::LogStreamer<>()
|
||||
#define RTC_EAT_STREAM_PARAMETERS(ignored) \
|
||||
(true ? true : ((void)(ignored), true)) \
|
||||
? static_cast<void>(0) \
|
||||
: ::rtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>()
|
||||
|
||||
// Call RTC_EAT_STREAM_PARAMETERS with an argument that fails to compile if
|
||||
// values of the same types as |a| and |b| can't be compared with the given
|
||||
// operation, and that would evaluate |a| and |b| if evaluated.
|
||||
#define RTC_EAT_STREAM_PARAMETERS_OP(op, a, b) \
|
||||
RTC_EAT_STREAM_PARAMETERS(((void)rtc::Safe##op(a, b)))
|
||||
RTC_EAT_STREAM_PARAMETERS(((void)::rtc::Safe##op(a, b)))
|
||||
|
||||
// RTC_CHECK dies with a fatal error if condition is not true. It is *not*
|
||||
// controlled by NDEBUG or anything else, so the check will be executed
|
||||
@ -367,36 +367,36 @@ class FatalLogCall final {
|
||||
// RTC_CHECK_OP is a helper macro for binary operators.
|
||||
// Don't use this macro directly in your code, use RTC_CHECK_EQ et al below.
|
||||
#if RTC_CHECK_MSG_ENABLED
|
||||
#define RTC_CHECK(condition) \
|
||||
(condition) ? static_cast<void>(0) \
|
||||
: rtc::webrtc_checks_impl::FatalLogCall<false>( \
|
||||
__FILE__, __LINE__, #condition) & \
|
||||
rtc::webrtc_checks_impl::LogStreamer<>()
|
||||
#define RTC_CHECK(condition) \
|
||||
(condition) ? static_cast<void>(0) \
|
||||
: ::rtc::webrtc_checks_impl::FatalLogCall<false>( \
|
||||
__FILE__, __LINE__, #condition) & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>()
|
||||
|
||||
#define RTC_CHECK_OP(name, op, val1, val2) \
|
||||
rtc::Safe##name((val1), (val2)) \
|
||||
? static_cast<void>(0) \
|
||||
: rtc::webrtc_checks_impl::FatalLogCall<true>(__FILE__, __LINE__, \
|
||||
#val1 " " #op " " #val2) & \
|
||||
rtc::webrtc_checks_impl::LogStreamer<>() << (val1) << (val2)
|
||||
#define RTC_CHECK_OP(name, op, val1, val2) \
|
||||
::rtc::Safe##name((val1), (val2)) \
|
||||
? static_cast<void>(0) \
|
||||
: ::rtc::webrtc_checks_impl::FatalLogCall<true>( \
|
||||
__FILE__, __LINE__, #val1 " " #op " " #val2) & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>() << (val1) << (val2)
|
||||
#else
|
||||
#define RTC_CHECK(condition) \
|
||||
(condition) \
|
||||
? static_cast<void>(0) \
|
||||
: true ? rtc::webrtc_checks_impl::FatalLogCall<false>(__FILE__, \
|
||||
__LINE__, "") & \
|
||||
rtc::webrtc_checks_impl::LogStreamer<>() \
|
||||
: rtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
|
||||
rtc::webrtc_checks_impl::LogStreamer<>()
|
||||
#define RTC_CHECK(condition) \
|
||||
(condition) \
|
||||
? static_cast<void>(0) \
|
||||
: true ? ::rtc::webrtc_checks_impl::FatalLogCall<false>(__FILE__, \
|
||||
__LINE__, "") & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>() \
|
||||
: ::rtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>()
|
||||
|
||||
#define RTC_CHECK_OP(name, op, val1, val2) \
|
||||
rtc::Safe##name((val1), (val2)) \
|
||||
? static_cast<void>(0) \
|
||||
: true ? rtc::webrtc_checks_impl::FatalLogCall<true>(__FILE__, __LINE__, \
|
||||
"") & \
|
||||
rtc::webrtc_checks_impl::LogStreamer<>() \
|
||||
: rtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
|
||||
rtc::webrtc_checks_impl::LogStreamer<>()
|
||||
#define RTC_CHECK_OP(name, op, val1, val2) \
|
||||
::rtc::Safe##name((val1), (val2)) \
|
||||
? static_cast<void>(0) \
|
||||
: true ? ::rtc::webrtc_checks_impl::FatalLogCall<true>(__FILE__, \
|
||||
__LINE__, "") & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>() \
|
||||
: ::rtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>()
|
||||
#endif
|
||||
|
||||
#define RTC_CHECK_EQ(val1, val2) RTC_CHECK_OP(Eq, ==, val1, val2)
|
||||
@ -431,10 +431,10 @@ class FatalLogCall final {
|
||||
#define RTC_NOTREACHED() RTC_DCHECK(RTC_UNREACHABLE_CODE_HIT)
|
||||
|
||||
// TODO(bugs.webrtc.org/8454): Add an RTC_ prefix or rename differently.
|
||||
#define FATAL() \
|
||||
rtc::webrtc_checks_impl::FatalLogCall<false>(__FILE__, __LINE__, \
|
||||
"FATAL()") & \
|
||||
rtc::webrtc_checks_impl::LogStreamer<>()
|
||||
#define FATAL() \
|
||||
::rtc::webrtc_checks_impl::FatalLogCall<false>(__FILE__, __LINE__, \
|
||||
"FATAL()") & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>()
|
||||
|
||||
// Performs the integer division a/b and returns the result. CHECKs that the
|
||||
// remainder is zero.
|
||||
|
||||
@ -574,13 +574,13 @@ class LogMessage {
|
||||
// Logging Helpers
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define RTC_LOG_FILE_LINE(sev, file, line) \
|
||||
RTC_LOG_ENABLED() && \
|
||||
rtc::webrtc_logging_impl::LogCall() & \
|
||||
rtc::webrtc_logging_impl::LogStreamer<>() \
|
||||
<< rtc::webrtc_logging_impl::LogMetadata(file, line, sev)
|
||||
#define RTC_LOG_FILE_LINE(sev, file, line) \
|
||||
RTC_LOG_ENABLED() && \
|
||||
::rtc::webrtc_logging_impl::LogCall() & \
|
||||
::rtc::webrtc_logging_impl::LogStreamer<>() \
|
||||
<< ::rtc::webrtc_logging_impl::LogMetadata(file, line, sev)
|
||||
|
||||
#define RTC_LOG(sev) RTC_LOG_FILE_LINE(rtc::sev, __FILE__, __LINE__)
|
||||
#define RTC_LOG(sev) RTC_LOG_FILE_LINE(::rtc::sev, __FILE__, __LINE__)
|
||||
|
||||
// The _V version is for when a variable is passed in.
|
||||
#define RTC_LOG_V(sev) RTC_LOG_FILE_LINE(sev, __FILE__, __LINE__)
|
||||
@ -595,18 +595,18 @@ class LogMessage {
|
||||
#define RTC_LOG_T_F(sev) RTC_LOG(sev) << this << ": " << __FUNCTION__ << ": "
|
||||
#endif
|
||||
|
||||
#define RTC_LOG_CHECK_LEVEL(sev) rtc::LogCheckLevel(rtc::sev)
|
||||
#define RTC_LOG_CHECK_LEVEL_V(sev) rtc::LogCheckLevel(sev)
|
||||
#define RTC_LOG_CHECK_LEVEL(sev) ::rtc::LogCheckLevel(::rtc::sev)
|
||||
#define RTC_LOG_CHECK_LEVEL_V(sev) ::rtc::LogCheckLevel(sev)
|
||||
|
||||
inline bool LogCheckLevel(LoggingSeverity sev) {
|
||||
return (LogMessage::GetMinLogSeverity() <= sev);
|
||||
}
|
||||
|
||||
#define RTC_LOG_E(sev, ctx, err) \
|
||||
RTC_LOG_ENABLED() && rtc::webrtc_logging_impl::LogCall() & \
|
||||
rtc::webrtc_logging_impl::LogStreamer<>() \
|
||||
<< rtc::webrtc_logging_impl::LogMetadataErr { \
|
||||
{__FILE__, __LINE__, rtc::sev}, rtc::ERRCTX_##ctx, (err) \
|
||||
#define RTC_LOG_E(sev, ctx, err) \
|
||||
RTC_LOG_ENABLED() && ::rtc::webrtc_logging_impl::LogCall() & \
|
||||
::rtc::webrtc_logging_impl::LogStreamer<>() \
|
||||
<< ::rtc::webrtc_logging_impl::LogMetadataErr { \
|
||||
{__FILE__, __LINE__, ::rtc::sev}, ::rtc::ERRCTX_##ctx, (err) \
|
||||
}
|
||||
|
||||
#define RTC_LOG_T(sev) RTC_LOG(sev) << this << ": "
|
||||
@ -639,11 +639,11 @@ inline const char* AdaptString(const std::string& str) {
|
||||
}
|
||||
} // namespace webrtc_logging_impl
|
||||
|
||||
#define RTC_LOG_TAG(sev, tag) \
|
||||
RTC_LOG_ENABLED() && rtc::webrtc_logging_impl::LogCall() & \
|
||||
rtc::webrtc_logging_impl::LogStreamer<>() \
|
||||
<< rtc::webrtc_logging_impl::LogMetadataTag { \
|
||||
sev, rtc::webrtc_logging_impl::AdaptString(tag) \
|
||||
#define RTC_LOG_TAG(sev, tag) \
|
||||
RTC_LOG_ENABLED() && ::rtc::webrtc_logging_impl::LogCall() & \
|
||||
::rtc::webrtc_logging_impl::LogStreamer<>() \
|
||||
<< ::rtc::webrtc_logging_impl::LogMetadataTag { \
|
||||
sev, ::rtc::webrtc_logging_impl::AdaptString(tag) \
|
||||
}
|
||||
|
||||
#else
|
||||
@ -662,7 +662,7 @@ inline const char* AdaptString(const std::string& str) {
|
||||
#else
|
||||
#define RTC_DLOG_EAT_STREAM_PARAMS() \
|
||||
while (false) \
|
||||
rtc::webrtc_logging_impl::LogStreamer<>()
|
||||
::rtc::webrtc_logging_impl::LogStreamer<>()
|
||||
#define RTC_DLOG(sev) RTC_DLOG_EAT_STREAM_PARAMS()
|
||||
#define RTC_DLOG_V(sev) RTC_DLOG_EAT_STREAM_PARAMS()
|
||||
#define RTC_DLOG_F(sev) RTC_DLOG_EAT_STREAM_PARAMS()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user