Support absl::string_view in RTC_CHECK.
Bug: None Change-Id: I8d4c296f1ac16a96adb88401f78ee9f65911bfc0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/126482 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27052}
This commit is contained in:

committed by
Commit Bot

parent
8cc711a7e1
commit
d4a37a6ee6
@ -341,6 +341,7 @@ rtc_source_set("checks") {
|
|||||||
deps = [
|
deps = [
|
||||||
":safe_compare",
|
":safe_compare",
|
||||||
"system:inline",
|
"system:inline",
|
||||||
|
"//third_party/abseil-cpp/absl/strings",
|
||||||
]
|
]
|
||||||
if (is_android) {
|
if (is_android) {
|
||||||
libs += [ "log" ]
|
libs += [ "log" ]
|
||||||
|
@ -54,7 +54,7 @@ __attribute__((__format__(__printf__, 2, 3)))
|
|||||||
}
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
namespace rtc {
|
namespace rtc {
|
||||||
namespace webrtc_checks_impl {
|
namespace webrtc_checks_impl {
|
||||||
@ -96,6 +96,11 @@ bool ParseArg(va_list* args, const CheckArgType** fmt, std::string* s) {
|
|||||||
case CheckArgType::kStdString:
|
case CheckArgType::kStdString:
|
||||||
s->append(*va_arg(*args, const std::string*));
|
s->append(*va_arg(*args, const std::string*));
|
||||||
break;
|
break;
|
||||||
|
case CheckArgType::kStringView: {
|
||||||
|
const absl::string_view sv = *va_arg(*args, const absl::string_view*);
|
||||||
|
s->append(sv.data(), sv.size());
|
||||||
|
break;
|
||||||
|
}
|
||||||
case CheckArgType::kVoidP:
|
case CheckArgType::kVoidP:
|
||||||
AppendFormat(s, "%p", va_arg(*args, const void*));
|
AppendFormat(s, "%p", va_arg(*args, const void*));
|
||||||
break;
|
break;
|
||||||
|
@ -42,6 +42,7 @@ RTC_NORETURN void rtc_FatalMessage(const char* file, int line, const char* msg);
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "rtc_base/numerics/safe_compare.h"
|
#include "rtc_base/numerics/safe_compare.h"
|
||||||
#include "rtc_base/system/inline.h"
|
#include "rtc_base/system/inline.h"
|
||||||
|
|
||||||
@ -99,6 +100,7 @@ enum class CheckArgType : int8_t {
|
|||||||
kLongDouble,
|
kLongDouble,
|
||||||
kCharP,
|
kCharP,
|
||||||
kStdString,
|
kStdString,
|
||||||
|
kStringView,
|
||||||
kVoidP,
|
kVoidP,
|
||||||
|
|
||||||
// kCheckOp doesn't represent an argument type. Instead, it is sent as the
|
// kCheckOp doesn't represent an argument type. Instead, it is sent as the
|
||||||
@ -157,6 +159,10 @@ inline Val<CheckArgType::kStdString, const std::string*> MakeVal(
|
|||||||
const std::string& x) {
|
const std::string& x) {
|
||||||
return {&x};
|
return {&x};
|
||||||
}
|
}
|
||||||
|
inline Val<CheckArgType::kStringView, const absl::string_view*> MakeVal(
|
||||||
|
const absl::string_view& x) {
|
||||||
|
return {&x};
|
||||||
|
}
|
||||||
|
|
||||||
inline Val<CheckArgType::kVoidP, const void*> MakeVal(const void* x) {
|
inline Val<CheckArgType::kVoidP, const void*> MakeVal(const void* x) {
|
||||||
return {x};
|
return {x};
|
||||||
|
Reference in New Issue
Block a user