Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: third_party/WebKit/Source/wtf/Assertions.h

Issue 1611343002: wtf reformat test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pydent Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/ArrayPiece.cpp ('k') | third_party/WebKit/Source/wtf/Assertions.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 68ebaed26a9933e2e1d63d7df502fc963dc84035..6c36e3527b54584b4eccea592dc1d94b794ed17b 100644
--- a/third_party/WebKit/Source/wtf/Assertions.h
+++ b/third_party/WebKit/Source/wtf/Assertions.h
@@ -85,7 +85,8 @@
emits a warning when %@ is used in the format string. Until <rdar://problem/5195437> is resolved we can't include
the attribute when being used from Objective-C code in case it decides to use %@. */
#if COMPILER(GCC) && !defined(__OBJC__)
-#define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments) __attribute__((__format__(printf, formatStringArgument, extraArguments)))
+#define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments) \
+ __attribute__((__format__(printf, formatStringArgument, extraArguments)))
#else
#define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments)
#endif
@@ -94,18 +95,44 @@
typedef enum { WTFLogChannelOff, WTFLogChannelOn } WTFLogChannelState;
-typedef struct {
- WTFLogChannelState state;
-} WTFLogChannel;
-
-WTF_EXPORT void WTFReportAssertionFailure(const char* file, int line, const char* function, const char* assertion);
-WTF_EXPORT void WTFReportAssertionFailureWithMessage(const char* file, int line, const char* function, const char* assertion, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6);
-WTF_EXPORT void WTFReportArgumentAssertionFailure(const char* file, int line, const char* function, const char* argName, const char* assertion);
-WTF_EXPORT void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...) WTF_ATTRIBUTE_PRINTF(4, 5);
-WTF_EXPORT void WTFReportError(const char* file, int line, const char* function, const char* format, ...) WTF_ATTRIBUTE_PRINTF(4, 5);
-WTF_EXPORT void WTFLog(WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PRINTF(2, 3);
-WTF_EXPORT void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6);
-WTF_EXPORT void WTFLogAlways(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2);
+typedef struct { WTFLogChannelState state; } WTFLogChannel;
+
+WTF_EXPORT void WTFReportAssertionFailure(const char* file,
+ int line,
+ const char* function,
+ const char* assertion);
+WTF_EXPORT void WTFReportAssertionFailureWithMessage(const char* file,
+ int line,
+ const char* function,
+ const char* assertion,
+ const char* format,
+ ...)
+ WTF_ATTRIBUTE_PRINTF(5, 6);
+WTF_EXPORT void WTFReportArgumentAssertionFailure(const char* file,
+ int line,
+ const char* function,
+ const char* argName,
+ const char* assertion);
+WTF_EXPORT void WTFReportFatalError(const char* file,
+ int line,
+ const char* function,
+ const char* format,
+ ...) WTF_ATTRIBUTE_PRINTF(4, 5);
+WTF_EXPORT void WTFReportError(const char* file,
+ int line,
+ const char* function,
+ const char* format,
+ ...) WTF_ATTRIBUTE_PRINTF(4, 5);
+WTF_EXPORT void WTFLog(WTFLogChannel*, const char* format, ...)
+ WTF_ATTRIBUTE_PRINTF(2, 3);
+WTF_EXPORT void WTFLogVerbose(const char* file,
+ int line,
+ const char* function,
+ WTFLogChannel*,
+ const char* format,
+ ...) WTF_ATTRIBUTE_PRINTF(5, 6);
+WTF_EXPORT void WTFLogAlways(const char* format, ...)
+ WTF_ATTRIBUTE_PRINTF(1, 2);
WTF_EXPORT void WTFGetBacktrace(void** stack, int* size);
WTF_EXPORT void WTFReportBacktrace(int framesToShow = 31);
@@ -114,56 +141,62 @@ 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_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 +223,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 +243,10 @@ using WTF::ScopedLogger;
#else
-#define BACKTRACE() do { \
+#define BACKTRACE() \
+ do { \
WTFReportBacktrace(); \
-} while (false)
+ } while (false)
#endif
@@ -228,21 +262,23 @@ 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)
+#define ASSERT_AT(assertion, file, line, function) \
+ (!(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,18 +305,20 @@ 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)
+#define RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(assertion) \
+ ASSERT_WITH_SECURITY_IMPLICATION(assertion)
#else
#define ASSERT_WITH_SECURITY_IMPLICATION(assertion) ASSERT(assertion)
-#define RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(assertion) RELEASE_ASSERT(assertion)
+#define RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(assertion) \
+ RELEASE_ASSERT(assertion)
#endif
@@ -297,12 +335,14 @@ 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 +350,14 @@ 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 +368,14 @@ 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 +384,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 */
@@ -351,7 +396,8 @@ while (0)
#if ERROR_DISABLED
#define WTF_LOG_ERROR(...) ((void)0)
#else
-#define WTF_LOG_ERROR(...) WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, __VA_ARGS__)
+#define WTF_LOG_ERROR(...) \
+ WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, __VA_ARGS__)
#endif
/* WTF_LOG */
@@ -359,9 +405,12 @@ while (0)
#if LOG_DISABLED
#define WTF_LOG(channel, ...) ((void)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 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
#endif
/* UNREACHABLE_FOR_PLATFORM */
@@ -371,9 +420,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
@@ -390,10 +438,12 @@ static inline void UNREACHABLE_FOR_PLATFORM()
#if ENABLE(ASSERT)
#define RELEASE_ASSERT(assertion) ASSERT(assertion)
-#define RELEASE_ASSERT_WITH_MESSAGE(assertion, ...) ASSERT_WITH_MESSAGE(assertion, __VA_ARGS__)
+#define RELEASE_ASSERT_WITH_MESSAGE(assertion, ...) \
+ ASSERT_WITH_MESSAGE(assertion, __VA_ARGS__)
#define RELEASE_ASSERT_NOT_REACHED() ASSERT_NOT_REACHED()
#else
-#define RELEASE_ASSERT(assertion) (UNLIKELY(!(assertion)) ? (IMMEDIATE_CRASH()) : (void)0)
+#define RELEASE_ASSERT(assertion) \
+ (UNLIKELY(!(assertion)) ? (IMMEDIATE_CRASH()) : (void)0)
#define RELEASE_ASSERT_WITH_MESSAGE(assertion, ...) RELEASE_ASSERT(assertion)
#define RELEASE_ASSERT_NOT_REACHED() IMMEDIATE_CRASH()
#endif
@@ -402,45 +452,62 @@ 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) \
-{ \
+#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) \
-{ \
+ 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&)
+ 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 */
« no previous file with comments | « third_party/WebKit/Source/wtf/ArrayPiece.cpp ('k') | third_party/WebKit/Source/wtf/Assertions.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698