From c30a6232df03e1efbd9f3b226777b07e087a1122 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 12 Oct 2020 14:27:29 +0200 Subject: BASELINE: Update Chromium to 85.0.4183.140 Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen --- chromium/base/check_op.h | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'chromium/base/check_op.h') diff --git a/chromium/base/check_op.h b/chromium/base/check_op.h index 4816df4e8b0..1acfa614e95 100644 --- a/chromium/base/check_op.h +++ b/chromium/base/check_op.h @@ -48,8 +48,10 @@ BASE_EXPORT char* StreamValToStr(const void* v, void (*stream_func)(std::ostream&, const void*)); -#ifndef __has_builtin -#define __has_builtin(x) 0 // Compatibility with non-clang compilers. +#ifdef __has_builtin +#define SUPPORTS_BUILTIN_ADDRESSOF (__has_builtin(__builtin_addressof)) +#else +#define SUPPORTS_BUILTIN_ADDRESSOF 0 #endif template @@ -65,7 +67,7 @@ CheckOpValueStr(const T& v) { // operator& might be overloaded, so do the std::addressof dance. // __builtin_addressof is preferred since it also handles Obj-C ARC pointers. // Some casting is still needed, because T might be volatile. -#if __has_builtin(__builtin_addressof) +#if SUPPORTS_BUILTIN_ADDRESSOF const void* vp = const_cast( reinterpret_cast(__builtin_addressof(v))); #else @@ -75,6 +77,8 @@ CheckOpValueStr(const T& v) { return StreamValToStr(vp, f); } +#undef SUPPORTS_BUILTIN_ADDRESSOF + // Overload for types that have no operator<< but do have .ToString() defined. template inline typename std::enable_if< @@ -115,7 +119,7 @@ CheckOpValueStr(const T& v) { class CheckOpResult { public: // An empty result signals success. - constexpr CheckOpResult() = default; + constexpr CheckOpResult() {} // A non-success result. expr_str is something like "foo != bar". v1_str and // v2_str are the stringified run-time values of foo and bar. Takes ownership @@ -157,9 +161,13 @@ class CheckOpResult { #endif -// The int-int overload avoids address-taking static int members. +// The second overload avoids address-taking of static members for +// fundamental types. #define DEFINE_CHECK_OP_IMPL(name, op) \ - template \ + template ::value || \ + !std::is_fundamental::value, \ + int> = 0> \ constexpr ::logging::CheckOpResult Check##name##Impl( \ const T& v1, const U& v2, const char* expr_str) { \ if (ANALYZER_ASSUME_TRUE(v1 op v2)) \ @@ -167,7 +175,11 @@ class CheckOpResult { return ::logging::CheckOpResult(expr_str, CheckOpValueStr(v1), \ CheckOpValueStr(v2)); \ } \ - constexpr ::logging::CheckOpResult Check##name##Impl(int v1, int v2, \ + template ::value && \ + std::is_fundamental::value, \ + int> = 0> \ + constexpr ::logging::CheckOpResult Check##name##Impl(T v1, U v2, \ const char* expr_str) { \ if (ANALYZER_ASSUME_TRUE(v1 op v2)) \ return ::logging::CheckOpResult(); \ -- cgit v1.2.1