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

Side by Side Diff: Source/wtf/Assertions.h

Issue 331793004: Delete ASSERT_DISABLED (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add missing include Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/platform/mac/BlockExceptions.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 /* Disable ASSERT* macros in release mode. */ 47 /* Disable ASSERT* macros in release mode. */
48 #define ASSERTIONS_DISABLED_DEFAULT 1 48 #define ASSERTIONS_DISABLED_DEFAULT 1
49 #else 49 #else
50 #define ASSERTIONS_DISABLED_DEFAULT 0 50 #define ASSERTIONS_DISABLED_DEFAULT 0
51 #endif 51 #endif
52 52
53 #ifndef BACKTRACE_DISABLED 53 #ifndef BACKTRACE_DISABLED
54 #define BACKTRACE_DISABLED ASSERTIONS_DISABLED_DEFAULT 54 #define BACKTRACE_DISABLED ASSERTIONS_DISABLED_DEFAULT
55 #endif 55 #endif
56 56
57 #ifndef ASSERT_DISABLED 57 #ifndef ASSERT_ENABLED
58 #define ASSERT_DISABLED ASSERTIONS_DISABLED_DEFAULT 58 // Notice the not below:
59 #define ASSERT_ENABLED !ASSERTIONS_DISABLED_DEFAULT
59 #endif 60 #endif
60 #define ASSERT_ENABLED !ASSERT_DISABLED
61 61
62 #ifndef ASSERT_MSG_DISABLED 62 #ifndef ASSERT_MSG_DISABLED
63 #define ASSERT_MSG_DISABLED ASSERTIONS_DISABLED_DEFAULT 63 #define ASSERT_MSG_DISABLED ASSERTIONS_DISABLED_DEFAULT
64 #endif 64 #endif
65 65
66 #ifndef ASSERT_ARG_DISABLED 66 #ifndef ASSERT_ARG_DISABLED
67 #define ASSERT_ARG_DISABLED ASSERTIONS_DISABLED_DEFAULT 67 #define ASSERT_ARG_DISABLED ASSERTIONS_DISABLED_DEFAULT
68 #endif 68 #endif
69 69
70 #ifndef FATAL_DISABLED 70 #ifndef FATAL_DISABLED
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 /* ASSERT, ASSERT_NOT_REACHED, ASSERT_UNUSED 172 /* ASSERT, ASSERT_NOT_REACHED, ASSERT_UNUSED
173 173
174 These macros are compiled out of release builds. 174 These macros are compiled out of release builds.
175 Expressions inside them are evaluated in debug builds only. 175 Expressions inside them are evaluated in debug builds only.
176 */ 176 */
177 #if OS(WIN) 177 #if OS(WIN)
178 /* FIXME: Change to use something other than ASSERT to avoid this conflict with the underlying platform */ 178 /* FIXME: Change to use something other than ASSERT to avoid this conflict with the underlying platform */
179 #undef ASSERT 179 #undef ASSERT
180 #endif 180 #endif
181 181
182 #if ASSERT_DISABLED 182 #if ASSERT_ENABLED
183
184 #define ASSERT(assertion) ((void)0)
185 #define ASSERT_AT(assertion, file, line, function) ((void)0)
186 #define ASSERT_NOT_REACHED() ((void)0)
187 #define NO_RETURN_DUE_TO_ASSERT
188
189 #define ASSERT_UNUSED(variable, assertion) ((void)variable)
190
191 #else
192 183
193 #define ASSERT(assertion) \ 184 #define ASSERT(assertion) \
194 (!(assertion) ? \ 185 (!(assertion) ? \
195 (WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #ass ertion), \ 186 (WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #ass ertion), \
196 CRASH()) : \ 187 CRASH()) : \
197 (void)0) 188 (void)0)
198 189
199 #define ASSERT_AT(assertion, file, line, function) \ 190 #define ASSERT_AT(assertion, file, line, function) \
200 (!(assertion) ? \ 191 (!(assertion) ? \
201 (WTFReportAssertionFailure(file, line, function, #assertion), \ 192 (WTFReportAssertionFailure(file, line, function, #assertion), \
202 CRASH()) : \ 193 CRASH()) : \
203 (void)0) 194 (void)0)
204 195
205 #define ASSERT_NOT_REACHED() do { \ 196 #define ASSERT_NOT_REACHED() do { \
206 WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, 0); \ 197 WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, 0); \
207 CRASH(); \ 198 CRASH(); \
208 } while (0) 199 } while (0)
209 200
210 #define ASSERT_UNUSED(variable, assertion) ASSERT(assertion) 201 #define ASSERT_UNUSED(variable, assertion) ASSERT(assertion)
211 202
212 #define NO_RETURN_DUE_TO_ASSERT NO_RETURN_DUE_TO_CRASH 203 #define NO_RETURN_DUE_TO_ASSERT NO_RETURN_DUE_TO_CRASH
213 204
205 #else
206
207 #define ASSERT(assertion) ((void)0)
208 #define ASSERT_AT(assertion, file, line, function) ((void)0)
209 #define ASSERT_NOT_REACHED() ((void)0)
210 #define NO_RETURN_DUE_TO_ASSERT
211
212 #define ASSERT_UNUSED(variable, assertion) ((void)variable)
213
214 #endif 214 #endif
215 215
216 /* ASSERT_WITH_SECURITY_IMPLICATION / RELEASE_ASSERT_WITH_SECURITY_IMPLICATION 216 /* ASSERT_WITH_SECURITY_IMPLICATION / RELEASE_ASSERT_WITH_SECURITY_IMPLICATION
217 217
218 Use in places where failure of the assertion indicates a possible security 218 Use in places where failure of the assertion indicates a possible security
219 vulnerability. Classes of these vulnerabilities include bad casts, out of 219 vulnerability. Classes of these vulnerabilities include bad casts, out of
220 bounds accesses, use-after-frees, etc. Please be sure to file bugs for these 220 bounds accesses, use-after-frees, etc. Please be sure to file bugs for these
221 failures using the security template: 221 failures using the security template:
222 http://code.google.com/p/chromium/issues/entry?template=Security%20Bug 222 http://code.google.com/p/chromium/issues/entry?template=Security%20Bug
223 */ 223 */
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 #endif 345 #endif
346 346
347 /* RELEASE_ASSERT 347 /* RELEASE_ASSERT
348 348
349 Use in places where failure of an assertion indicates a definite security 349 Use in places where failure of an assertion indicates a definite security
350 vulnerability from which execution must not continue even in a release build. 350 vulnerability from which execution must not continue even in a release build.
351 Please sure to file bugs for these failures using the security template: 351 Please sure to file bugs for these failures using the security template:
352 http://code.google.com/p/chromium/issues/entry?template=Security%20Bug 352 http://code.google.com/p/chromium/issues/entry?template=Security%20Bug
353 */ 353 */
354 354
355 #if ASSERT_DISABLED 355 #if ASSERT_ENABLED
356 #define RELEASE_ASSERT(assertion) ASSERT(assertion)
357 #define RELEASE_ASSERT_WITH_MESSAGE(assertion, ...) ASSERT_WITH_MESSAGE(assertio n, __VA_ARGS__)
358 #define RELEASE_ASSERT_NOT_REACHED() ASSERT_NOT_REACHED()
359 #else
356 #define RELEASE_ASSERT(assertion) (UNLIKELY(!(assertion)) ? (IMMEDIATE_CRASH()) : (void)0) 360 #define RELEASE_ASSERT(assertion) (UNLIKELY(!(assertion)) ? (IMMEDIATE_CRASH()) : (void)0)
357 #define RELEASE_ASSERT_WITH_MESSAGE(assertion, ...) RELEASE_ASSERT(assertion) 361 #define RELEASE_ASSERT_WITH_MESSAGE(assertion, ...) RELEASE_ASSERT(assertion)
358 #define RELEASE_ASSERT_NOT_REACHED() IMMEDIATE_CRASH() 362 #define RELEASE_ASSERT_NOT_REACHED() IMMEDIATE_CRASH()
359 #else
360 #define RELEASE_ASSERT(assertion) ASSERT(assertion)
361 #define RELEASE_ASSERT_WITH_MESSAGE(assertion, ...) ASSERT_WITH_MESSAGE(assertio n, __VA_ARGS__)
362 #define RELEASE_ASSERT_NOT_REACHED() ASSERT_NOT_REACHED()
363 #endif 363 #endif
364 364
365 /* DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES */ 365 /* DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES */
366 366
367 // Allow equality comparisons of Objects by reference or pointer, interchangeabl y. 367 // Allow equality comparisons of Objects by reference or pointer, interchangeabl y.
368 #define DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(thisType) \ 368 #define DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(thisType) \
369 inline bool operator==(const thisType& a, const thisType& b) { return &a == &b; } \ 369 inline bool operator==(const thisType& a, const thisType& b) { return &a == &b; } \
370 inline bool operator==(const thisType& a, const thisType* b) { return &a == b; } \ 370 inline bool operator==(const thisType& a, const thisType* b) { return &a == b; } \
371 inline bool operator==(const thisType* a, const thisType& b) { return a == & b; } \ 371 inline bool operator==(const thisType* a, const thisType& b) { return a == & b; } \
372 inline bool operator!=(const thisType& a, const thisType& b) { return !(a == b); } \ 372 inline bool operator!=(const thisType& a, const thisType& b) { return !(a == b); } \
(...skipping 27 matching lines...) Expand all
400 } \ 400 } \
401 inline const thisType& to##thisType(const argumentType& argumentName) \ 401 inline const thisType& to##thisType(const argumentType& argumentName) \
402 { \ 402 { \
403 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ 403 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \
404 return static_cast<const thisType&>(argumentName); \ 404 return static_cast<const thisType&>(argumentName); \
405 } \ 405 } \
406 void to##thisType(const thisType*); \ 406 void to##thisType(const thisType*); \
407 void to##thisType(const thisType&) 407 void to##thisType(const thisType&)
408 408
409 #endif /* WTF_Assertions_h */ 409 #endif /* WTF_Assertions_h */
OLDNEW
« no previous file with comments | « Source/platform/mac/BlockExceptions.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698