| Index: third_party/WebKit/Source/wtf/Assertions.h
|
| diff --git a/third_party/WebKit/Source/wtf/Assertions.h b/third_party/WebKit/Source/wtf/Assertions.h
|
| index a84096afa5c1a40f5e51855362138d476fdac3f8..ca6445e981f16d8047794c68411ae333b642083e 100644
|
| --- a/third_party/WebKit/Source/wtf/Assertions.h
|
| +++ b/third_party/WebKit/Source/wtf/Assertions.h
|
| @@ -92,10 +92,11 @@
|
|
|
| /* These helper functions are always declared, but not necessarily always defined if the corresponding function is disabled. */
|
|
|
| -typedef enum { WTFLogChannelOff, WTFLogChannelOn } WTFLogChannelState;
|
| +typedef enum { WTFLogChannelOff,
|
| + WTFLogChannelOn } WTFLogChannelState;
|
|
|
| typedef struct {
|
| - WTFLogChannelState state;
|
| + WTFLogChannelState state;
|
| } WTFLogChannel;
|
|
|
| WTF_EXPORT void WTFReportAssertionFailure(const char* file, int line, const char* function, const char* assertion);
|
| @@ -114,56 +115,57 @@ WTF_EXPORT void WTFPrintBacktrace(void** stack, int size);
|
| namespace WTF {
|
|
|
| class WTF_EXPORT FrameToNameScope {
|
| -public:
|
| - explicit FrameToNameScope(void*);
|
| - ~FrameToNameScope();
|
| - const char* nullableName() { return m_name; }
|
| -
|
| -private:
|
| - const char* m_name;
|
| - char* m_cxaDemangled;
|
| + public:
|
| + explicit FrameToNameScope(void*);
|
| + ~FrameToNameScope();
|
| + const char* nullableName() { return m_name; }
|
| +
|
| + private:
|
| + const char* m_name;
|
| + char* m_cxaDemangled;
|
| };
|
|
|
| // ScopedLogger wraps log messages in parentheses, with indentation proportional
|
| // to the number of instances. This makes it easy to see the flow of control in
|
| // the output, particularly when instrumenting recursive functions.
|
| class WTF_EXPORT ScopedLogger {
|
| - WTF_MAKE_NONCOPYABLE(ScopedLogger);
|
| -public:
|
| - // The first message is passed to the constructor. Additional messages for
|
| - // the same scope can be added with log(). If condition is false, produce no
|
| - // output and do not create a scope.
|
| - ScopedLogger(bool condition, const char* format, ...) WTF_ATTRIBUTE_PRINTF(3, 4);
|
| - ~ScopedLogger();
|
| - void log(const char* format, ...) WTF_ATTRIBUTE_PRINTF(2, 3);
|
| -
|
| -private:
|
| - friend class AssertionsTest;
|
| - using PrintFunctionPtr = void (*)(const char* format, va_list args);
|
| - static void setPrintFuncForTests(PrintFunctionPtr p) { m_printFunc = p; } // Note: not thread safe.
|
| -
|
| - void init(const char* format, va_list args);
|
| - void writeNewlineIfNeeded();
|
| - void indent();
|
| - void print(const char* format, ...);
|
| - static ScopedLogger*& current();
|
| -
|
| - ScopedLogger* const m_parent;
|
| - bool m_multiline; // The ')' will go on the same line if there is only one entry.
|
| - static PrintFunctionPtr m_printFunc;
|
| + WTF_MAKE_NONCOPYABLE(ScopedLogger);
|
| +
|
| + public:
|
| + // The first message is passed to the constructor. Additional messages for
|
| + // the same scope can be added with log(). If condition is false, produce no
|
| + // output and do not create a scope.
|
| + ScopedLogger(bool condition, const char* format, ...) WTF_ATTRIBUTE_PRINTF(3, 4);
|
| + ~ScopedLogger();
|
| + void log(const char* format, ...) WTF_ATTRIBUTE_PRINTF(2, 3);
|
| +
|
| + private:
|
| + friend class AssertionsTest;
|
| + using PrintFunctionPtr = void (*)(const char* format, va_list args);
|
| + static void setPrintFuncForTests(PrintFunctionPtr p) { m_printFunc = p; } // Note: not thread safe.
|
| +
|
| + void init(const char* format, va_list args);
|
| + void writeNewlineIfNeeded();
|
| + void indent();
|
| + void print(const char* format, ...);
|
| + static ScopedLogger*& current();
|
| +
|
| + ScopedLogger* const m_parent;
|
| + bool m_multiline; // The ')' will go on the same line if there is only one entry.
|
| + static PrintFunctionPtr m_printFunc;
|
| };
|
|
|
| #if LOG_DISABLED
|
| -#define WTF_CREATE_SCOPED_LOGGER(...) ((void) 0)
|
| -#define WTF_CREATE_SCOPED_LOGGER_IF(...) ((void) 0)
|
| -#define WTF_APPEND_SCOPED_LOGGER(...) ((void) 0)
|
| +#define WTF_CREATE_SCOPED_LOGGER(...) ((void)0)
|
| +#define WTF_CREATE_SCOPED_LOGGER_IF(...) ((void)0)
|
| +#define WTF_APPEND_SCOPED_LOGGER(...) ((void)0)
|
| #else
|
| #define WTF_CREATE_SCOPED_LOGGER(name, ...) ScopedLogger name(true, __VA_ARGS__)
|
| #define WTF_CREATE_SCOPED_LOGGER_IF(name, condition, ...) ScopedLogger name(condition, __VA_ARGS__)
|
| #define WTF_APPEND_SCOPED_LOGGER(name, ...) (name.log(__VA_ARGS__))
|
| #endif
|
|
|
| -} // namespace WTF
|
| +} // namespace WTF
|
|
|
| using WTF::FrameToNameScope;
|
| using WTF::ScopedLogger;
|
| @@ -190,7 +192,7 @@ using WTF::ScopedLogger;
|
| #define CRASH() (__debugbreak(), IMMEDIATE_CRASH())
|
| #else
|
| #define CRASH() \
|
| - (WTFReportBacktrace(), (*(int*)0xfbadbeef = 0), IMMEDIATE_CRASH())
|
| + (WTFReportBacktrace(), (*(int*)0xfbadbeef = 0), IMMEDIATE_CRASH())
|
| #endif
|
| #endif
|
|
|
| @@ -210,9 +212,10 @@ using WTF::ScopedLogger;
|
|
|
| #else
|
|
|
| -#define BACKTRACE() do { \
|
| +#define BACKTRACE() \
|
| + do { \
|
| WTFReportBacktrace(); \
|
| -} while (false)
|
| + } while (false)
|
|
|
| #endif
|
|
|
| @@ -228,21 +231,19 @@ using WTF::ScopedLogger;
|
|
|
| #if ENABLE(ASSERT)
|
|
|
| -#define ASSERT(assertion) \
|
| - (!(assertion) ? \
|
| - (WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion), \
|
| - CRASH()) : \
|
| - (void)0)
|
| +#define ASSERT(assertion) \
|
| + (!(assertion) ? (WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion), \
|
| + CRASH()) \
|
| + : (void)0)
|
|
|
| #define ASSERT_AT(assertion, file, line, function) \
|
| - (!(assertion) ? \
|
| - (WTFReportAssertionFailure(file, line, function, #assertion), CRASH()) : \
|
| - (void)0)
|
| + (!(assertion) ? (WTFReportAssertionFailure(file, line, function, #assertion), CRASH()) : (void)0)
|
|
|
| -#define ASSERT_NOT_REACHED() do { \
|
| +#define ASSERT_NOT_REACHED() \
|
| + do { \
|
| WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, 0); \
|
| - CRASH(); \
|
| -} while (0)
|
| + CRASH(); \
|
| + } while (0)
|
|
|
| #define ASSERT_UNUSED(variable, assertion) ASSERT(assertion)
|
|
|
| @@ -269,11 +270,10 @@ using WTF::ScopedLogger;
|
| */
|
| #ifdef ADDRESS_SANITIZER
|
|
|
| -#define ASSERT_WITH_SECURITY_IMPLICATION(assertion) \
|
| - (!(assertion) ? \
|
| - (WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion), \
|
| - CRASH()) : \
|
| - (void)0)
|
| +#define ASSERT_WITH_SECURITY_IMPLICATION(assertion) \
|
| + (!(assertion) ? (WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion), \
|
| + CRASH()) \
|
| + : (void)0)
|
|
|
| #define RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(assertion) ASSERT_WITH_SECURITY_IMPLICATION(assertion)
|
|
|
| @@ -297,12 +297,13 @@ using WTF::ScopedLogger;
|
| #if ASSERT_MSG_DISABLED
|
| #define ASSERT_WITH_MESSAGE(assertion, ...) ((void)0)
|
| #else
|
| -#define ASSERT_WITH_MESSAGE(assertion, ...) do \
|
| - if (!(assertion)) { \
|
| - WTFReportAssertionFailureWithMessage(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion, __VA_ARGS__); \
|
| - CRASH(); \
|
| - } \
|
| -while (0)
|
| +#define ASSERT_WITH_MESSAGE(assertion, ...) \
|
| + do \
|
| + if (!(assertion)) { \
|
| + WTFReportAssertionFailureWithMessage(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion, __VA_ARGS__); \
|
| + CRASH(); \
|
| + } \
|
| + while (0)
|
| #endif
|
|
|
| /* ASSERT_WITH_MESSAGE_UNUSED */
|
| @@ -310,12 +311,13 @@ while (0)
|
| #if ASSERT_MSG_DISABLED
|
| #define ASSERT_WITH_MESSAGE_UNUSED(variable, assertion, ...) ((void)variable)
|
| #else
|
| -#define ASSERT_WITH_MESSAGE_UNUSED(variable, assertion, ...) do \
|
| - if (!(assertion)) { \
|
| - WTFReportAssertionFailureWithMessage(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion, __VA_ARGS__); \
|
| - CRASH(); \
|
| - } \
|
| -while (0)
|
| +#define ASSERT_WITH_MESSAGE_UNUSED(variable, assertion, ...) \
|
| + do \
|
| + if (!(assertion)) { \
|
| + WTFReportAssertionFailureWithMessage(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion, __VA_ARGS__); \
|
| + CRASH(); \
|
| + } \
|
| + while (0)
|
| #endif
|
|
|
| /* ASSERT_ARG */
|
| @@ -326,12 +328,13 @@ while (0)
|
|
|
| #else
|
|
|
| -#define ASSERT_ARG(argName, assertion) do \
|
| - if (!(assertion)) { \
|
| - WTFReportArgumentAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #argName, #assertion); \
|
| - CRASH(); \
|
| - } \
|
| -while (0)
|
| +#define ASSERT_ARG(argName, assertion) \
|
| + do \
|
| + if (!(assertion)) { \
|
| + WTFReportArgumentAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #argName, #assertion); \
|
| + CRASH(); \
|
| + } \
|
| + while (0)
|
|
|
| #endif
|
|
|
| @@ -340,10 +343,11 @@ while (0)
|
| #if FATAL_DISABLED
|
| #define FATAL(...) ((void)0)
|
| #else
|
| -#define FATAL(...) do { \
|
| +#define FATAL(...) \
|
| + do { \
|
| WTFReportFatalError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, __VA_ARGS__); \
|
| - CRASH(); \
|
| -} while (0)
|
| + CRASH(); \
|
| + } while (0)
|
| #endif
|
|
|
| /* WTF_LOG_ERROR */
|
| @@ -361,7 +365,7 @@ while (0)
|
| #else
|
| #define WTF_LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
|
| #define JOIN_LOG_CHANNEL_WITH_PREFIX(prefix, channel) JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel)
|
| -#define JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel) prefix ## channel
|
| +#define JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel) prefix##channel
|
| #endif
|
|
|
| /* UNREACHABLE_FOR_PLATFORM */
|
| @@ -371,9 +375,8 @@ while (0)
|
| a function. Hence it uses macro naming convention. */
|
| #pragma clang diagnostic push
|
| #pragma clang diagnostic ignored "-Wmissing-noreturn"
|
| -static inline void UNREACHABLE_FOR_PLATFORM()
|
| -{
|
| - ASSERT_NOT_REACHED();
|
| +static inline void UNREACHABLE_FOR_PLATFORM() {
|
| + ASSERT_NOT_REACHED();
|
| }
|
| #pragma clang diagnostic pop
|
| #else
|
| @@ -402,45 +405,41 @@ static inline void UNREACHABLE_FOR_PLATFORM()
|
|
|
| // Allow equality comparisons of Objects by reference or pointer, interchangeably.
|
| // This can be only used on types whose equality makes no other sense than pointer equality.
|
| -#define DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(thisType) \
|
| - inline bool operator==(const thisType& a, const thisType& b) { return &a == &b; } \
|
| - inline bool operator==(const thisType& a, const thisType* b) { return &a == b; } \
|
| - inline bool operator==(const thisType* a, const thisType& b) { return a == &b; } \
|
| - inline bool operator!=(const thisType& a, const thisType& b) { return !(a == b); } \
|
| - inline bool operator!=(const thisType& a, const thisType* b) { return !(a == b); } \
|
| - inline bool operator!=(const thisType* a, const thisType& b) { return !(a == b); }
|
| -
|
| -#define DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES_REFCOUNTED(thisType) \
|
| - DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(thisType) \
|
| - inline bool operator==(const PassRefPtr<thisType>& a, const thisType& b) { return a.get() == &b; } \
|
| - inline bool operator==(const thisType& a, const PassRefPtr<thisType>& b) { return &a == b.get(); } \
|
| - inline bool operator!=(const PassRefPtr<thisType>& a, const thisType& b) { return !(a == b); } \
|
| - inline bool operator!=(const thisType& a, const PassRefPtr<thisType>& b) { return !(a == b); }
|
| +#define DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(thisType) \
|
| + inline bool operator==(const thisType& a, const thisType& b) { return &a == &b; } \
|
| + inline bool operator==(const thisType& a, const thisType* b) { return &a == b; } \
|
| + inline bool operator==(const thisType* a, const thisType& b) { return a == &b; } \
|
| + inline bool operator!=(const thisType& a, const thisType& b) { return !(a == b); } \
|
| + inline bool operator!=(const thisType& a, const thisType* b) { return !(a == b); } \
|
| + inline bool operator!=(const thisType* a, const thisType& b) { return !(a == b); }
|
| +
|
| +#define DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES_REFCOUNTED(thisType) \
|
| + DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(thisType) \
|
| + inline bool operator==(const PassRefPtr<thisType>& a, const thisType& b) { return a.get() == &b; } \
|
| + inline bool operator==(const thisType& a, const PassRefPtr<thisType>& b) { return &a == b.get(); } \
|
| + inline bool operator!=(const PassRefPtr<thisType>& a, const thisType& b) { return !(a == b); } \
|
| + inline bool operator!=(const thisType& a, const PassRefPtr<thisType>& b) { return !(a == b); }
|
|
|
| /* DEFINE_TYPE_CASTS */
|
|
|
| #define DEFINE_TYPE_CASTS(thisType, argumentType, argumentName, pointerPredicate, referencePredicate) \
|
| -inline thisType* to##thisType(argumentType* argumentName) \
|
| -{ \
|
| - ASSERT_WITH_SECURITY_IMPLICATION(!argumentName || (pointerPredicate)); \
|
| - return static_cast<thisType*>(argumentName); \
|
| -} \
|
| -inline const thisType* to##thisType(const argumentType* argumentName) \
|
| -{ \
|
| - ASSERT_WITH_SECURITY_IMPLICATION(!argumentName || (pointerPredicate)); \
|
| - return static_cast<const thisType*>(argumentName); \
|
| -} \
|
| -inline thisType& to##thisType(argumentType& argumentName) \
|
| -{ \
|
| - ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \
|
| - return static_cast<thisType&>(argumentName); \
|
| -} \
|
| -inline const thisType& to##thisType(const argumentType& argumentName) \
|
| -{ \
|
| - ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \
|
| - return static_cast<const thisType&>(argumentName); \
|
| -} \
|
| -void to##thisType(const thisType*); \
|
| -void to##thisType(const thisType&)
|
| + inline thisType* to##thisType(argumentType* argumentName) { \
|
| + ASSERT_WITH_SECURITY_IMPLICATION(!argumentName || (pointerPredicate)); \
|
| + return static_cast<thisType*>(argumentName); \
|
| + } \
|
| + inline const thisType* to##thisType(const argumentType* argumentName) { \
|
| + ASSERT_WITH_SECURITY_IMPLICATION(!argumentName || (pointerPredicate)); \
|
| + return static_cast<const thisType*>(argumentName); \
|
| + } \
|
| + inline thisType& to##thisType(argumentType& argumentName) { \
|
| + ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \
|
| + return static_cast<thisType&>(argumentName); \
|
| + } \
|
| + inline const thisType& to##thisType(const argumentType& argumentName) { \
|
| + ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \
|
| + return static_cast<const thisType&>(argumentName); \
|
| + } \
|
| + void to##thisType(const thisType*); \
|
| + void to##thisType(const thisType&)
|
|
|
| #endif /* WTF_Assertions_h */
|
|
|