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

Unified Diff: include/core/SkTypes.h

Issue 2161103002: Improve assert reporting. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments. Created 4 years, 5 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 | « include/core/SkPostConfig.h ('k') | src/ports/SkMemory_malloc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTypes.h
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index 1ac3efb2217b5d217ea111902fb2e8c96a138243..279557498eb44d978a0a49d8994bd9116f95214f 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -139,24 +139,24 @@ inline void operator delete(void* p) {
SK_API void SkDebugf(const char format[], ...);
#endif
-#define SkASSERT_RELEASE(cond) if(!(cond)) { SK_ABORT(#cond); }
+#define SkASSERT_RELEASE(cond) if (!(cond)) { SK_ABORT(#cond); }
#ifdef SK_DEBUG
- #if defined SK_BUILD_FOR_WIN
- #define SkASSERT(cond) if(!(cond)) { __debugbreak(); }
- #else
- #define SkASSERT(cond) SkASSERT_RELEASE(cond)
- #endif
- #define SkDEBUGFAIL(message) SkASSERT(false && message)
+ #define SkASSERT(cond) if (!(cond)) { SK_ABORT("assert(" #cond ")"); }
+ #define SkASSERTF(cond, fmt, ...) if (!(cond)) { \
+ SkDebugf(fmt"\n", __VA_ARGS__); \
+ SK_ABORT("assert(" #cond ")"); \
+ }
+ #define SkDEBUGFAIL(message) SK_ABORT(message)
#define SkDEBUGFAILF(fmt, ...) SkASSERTF(false, fmt, ##__VA_ARGS__)
#define SkDEBUGCODE(code) code
#define SkDECLAREPARAM(type, var) , type var
#define SkPARAM(var) , var
-// #define SkDEBUGF(args ) SkDebugf##args
#define SkDEBUGF(args ) SkDebugf args
#define SkAssertResult(cond) SkASSERT(cond)
#else
#define SkASSERT(cond)
+ #define SkASSERTF(cond, fmt, ...)
#define SkDEBUGFAIL(message)
#define SkDEBUGCODE(code)
#define SkDEBUGF(args)
@@ -172,11 +172,6 @@ inline void operator delete(void* p) {
#define SkFAIL(message) SK_ABORT(message)
#define sk_throw() SK_ABORT("sk_throw")
-// We want to evaluate cond only once, and inside the SkASSERT somewhere so we see its string form.
-// So we use the comma operator to make an SkDebugf that always returns false: we'll evaluate cond,
-// and if it's true the assert passes; if it's false, we'll print the message and the assert fails.
-#define SkASSERTF(cond, fmt, ...) SkASSERT((cond) || (SkDebugf(fmt"\n", __VA_ARGS__), false))
-
#ifdef SK_IGNORE_TO_STRING
#define SK_TO_STRING_NONVIRT()
#define SK_TO_STRING_VIRT()
« no previous file with comments | « include/core/SkPostConfig.h ('k') | src/ports/SkMemory_malloc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698