OLD | NEW |
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // triggering either the debugger or the crash reporter. | 116 // triggering either the debugger or the crash reporter. |
117 // | 117 // |
118 // Use CRASH() in response to known, unrecoverable errors like out-of-memory. | 118 // Use CRASH() in response to known, unrecoverable errors like out-of-memory. |
119 // Macro is enabled in both debug and release mode. | 119 // Macro is enabled in both debug and release mode. |
120 // To test for unknown errors and verify assumptions, use ASSERT instead, to | 120 // To test for unknown errors and verify assumptions, use ASSERT instead, to |
121 // avoid impacting performance in release builds. | 121 // avoid impacting performance in release builds. |
122 #ifndef CRASH | 122 #ifndef CRASH |
123 #define CRASH() IMMEDIATE_CRASH() | 123 #define CRASH() IMMEDIATE_CRASH() |
124 #endif | 124 #endif |
125 | 125 |
126 // ASSERT and ASSERT_NOT_REACHED | 126 // ASSERT |
127 // These macros are compiled out of release builds. | 127 // These macros are compiled out of release builds. |
128 // Expressions inside them are evaluated in debug builds only. | 128 // Expressions inside them are evaluated in debug builds only. |
129 // They are deprecated. We should use: | 129 // This is deprecated. We should use: |
130 // - DCHECK() for ASSERT() | 130 // - DCHECK() for ASSERT() |
131 // - NOTREACHED() for ASSERT_NOT_REACHED() | |
132 #if OS(WIN) | 131 #if OS(WIN) |
133 // FIXME: Change to use something other than ASSERT to avoid this conflict with | 132 // FIXME: Change to use something other than ASSERT to avoid this conflict with |
134 // the underlying platform. | 133 // the underlying platform. |
135 #undef ASSERT | 134 #undef ASSERT |
136 #endif | 135 #endif |
137 | 136 |
138 #define DCHECK_AT(assertion, file, line) \ | 137 #define DCHECK_AT(assertion, file, line) \ |
139 LAZY_STREAM(logging::LogMessage(file, line, #assertion).stream(), \ | 138 LAZY_STREAM(logging::LogMessage(file, line, #assertion).stream(), \ |
140 DCHECK_IS_ON() ? !(assertion) : false) | 139 DCHECK_IS_ON() ? !(assertion) : false) |
141 | 140 |
142 #if DCHECK_IS_ON() | 141 #if DCHECK_IS_ON() |
143 #define ASSERT(assertion) DCHECK(assertion) | 142 #define ASSERT(assertion) DCHECK(assertion) |
144 #define ASSERT_NOT_REACHED() NOTREACHED() | |
145 #else | 143 #else |
146 #define ASSERT(assertion) ((void)0) | 144 #define ASSERT(assertion) ((void)0) |
147 #define ASSERT_NOT_REACHED() ((void)0) | |
148 #endif | 145 #endif |
149 | 146 |
150 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure | 147 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure |
151 // that code testing this macro has included this header. | 148 // that code testing this macro has included this header. |
152 #if defined(ADDRESS_SANITIZER) || DCHECK_IS_ON() | 149 #if defined(ADDRESS_SANITIZER) || DCHECK_IS_ON() |
153 #define ENABLE_SECURITY_ASSERT 1 | 150 #define ENABLE_SECURITY_ASSERT 1 |
154 #else | 151 #else |
155 #define ENABLE_SECURITY_ASSERT 0 | 152 #define ENABLE_SECURITY_ASSERT 0 |
156 #endif | 153 #endif |
157 | 154 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 return static_cast<thisType&>(argument); \ | 247 return static_cast<thisType&>(argument); \ |
251 } \ | 248 } \ |
252 inline const thisType& To##thisType##OrDie(const argumentType& argument) { \ | 249 inline const thisType& To##thisType##OrDie(const argumentType& argument) { \ |
253 CHECK(referencePredicate); \ | 250 CHECK(referencePredicate); \ |
254 return static_cast<const thisType&>(argument); \ | 251 return static_cast<const thisType&>(argument); \ |
255 } \ | 252 } \ |
256 void To##thisType##OrDie(const thisType*); \ | 253 void To##thisType##OrDie(const thisType*); \ |
257 void To##thisType##OrDie(const thisType&) | 254 void To##thisType##OrDie(const thisType&) |
258 | 255 |
259 #endif // WTF_Assertions_h | 256 #endif // WTF_Assertions_h |
OLD | NEW |