| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // To test for unknown errors and verify assumptions, use ASSERT instead, to | 170 // To test for unknown errors and verify assumptions, use ASSERT instead, to |
| 171 // avoid impacting performance in release builds. | 171 // avoid impacting performance in release builds. |
| 172 #ifndef CRASH | 172 #ifndef CRASH |
| 173 #if COMPILER(MSVC) | 173 #if COMPILER(MSVC) |
| 174 #define CRASH() (__debugbreak(), IMMEDIATE_CRASH()) | 174 #define CRASH() (__debugbreak(), IMMEDIATE_CRASH()) |
| 175 #else | 175 #else |
| 176 #define CRASH() (WTFReportBacktrace(), IMMEDIATE_CRASH()) | 176 #define CRASH() (WTFReportBacktrace(), IMMEDIATE_CRASH()) |
| 177 #endif | 177 #endif |
| 178 #endif | 178 #endif |
| 179 | 179 |
| 180 #if COMPILER(CLANG) | |
| 181 #define NO_RETURN_DUE_TO_CRASH NO_RETURN | |
| 182 #else | |
| 183 #define NO_RETURN_DUE_TO_CRASH | |
| 184 #endif | |
| 185 | |
| 186 // ASSERT and ASSERT_NOT_REACHED | 180 // ASSERT and ASSERT_NOT_REACHED |
| 187 // These macros are compiled out of release builds. | 181 // These macros are compiled out of release builds. |
| 188 // Expressions inside them are evaluated in debug builds only. | 182 // Expressions inside them are evaluated in debug builds only. |
| 189 // They are deprecated. We should use: | 183 // They are deprecated. We should use: |
| 190 // - DCHECK() for ASSERT() | 184 // - DCHECK() for ASSERT() |
| 191 // - NOTREACHED() for ASSERT_NOT_REACHED() | 185 // - NOTREACHED() for ASSERT_NOT_REACHED() |
| 192 #if OS(WIN) | 186 #if OS(WIN) |
| 193 // FIXME: Change to use something other than ASSERT to avoid this conflict with | 187 // FIXME: Change to use something other than ASSERT to avoid this conflict with |
| 194 // the underlying platform. | 188 // the underlying platform. |
| 195 #undef ASSERT | 189 #undef ASSERT |
| (...skipping 10 matching lines...) Expand all Loading... |
| 206 WTF_PRETTY_FUNCTION, #assertion), \ | 200 WTF_PRETTY_FUNCTION, #assertion), \ |
| 207 CRASH()) \ | 201 CRASH()) \ |
| 208 : (void)0) | 202 : (void)0) |
| 209 | 203 |
| 210 #define ASSERT_NOT_REACHED() \ | 204 #define ASSERT_NOT_REACHED() \ |
| 211 do { \ | 205 do { \ |
| 212 WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, 0); \ | 206 WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, 0); \ |
| 213 CRASH(); \ | 207 CRASH(); \ |
| 214 } while (0) | 208 } while (0) |
| 215 | 209 |
| 216 #define NO_RETURN_DUE_TO_ASSERT NO_RETURN_DUE_TO_CRASH | |
| 217 | |
| 218 #else | 210 #else |
| 219 | 211 |
| 220 #define ASSERT(assertion) ((void)0) | 212 #define ASSERT(assertion) ((void)0) |
| 221 #define ASSERT_NOT_REACHED() ((void)0) | 213 #define ASSERT_NOT_REACHED() ((void)0) |
| 222 #define NO_RETURN_DUE_TO_ASSERT | |
| 223 | 214 |
| 224 #endif | 215 #endif |
| 225 | 216 |
| 226 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure | 217 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure |
| 227 // that code testing this macro has included this header. | 218 // that code testing this macro has included this header. |
| 228 #if defined(ADDRESS_SANITIZER) || ENABLE(ASSERT) | 219 #if defined(ADDRESS_SANITIZER) || ENABLE(ASSERT) |
| 229 #define ENABLE_SECURITY_ASSERT 1 | 220 #define ENABLE_SECURITY_ASSERT 1 |
| 230 #else | 221 #else |
| 231 #define ENABLE_SECURITY_ASSERT 0 | 222 #define ENABLE_SECURITY_ASSERT 0 |
| 232 #endif | 223 #endif |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 return static_cast<thisType&>(argumentName); \ | 297 return static_cast<thisType&>(argumentName); \ |
| 307 } \ | 298 } \ |
| 308 inline const thisType& to##thisType(const argumentType& argumentName) { \ | 299 inline const thisType& to##thisType(const argumentType& argumentName) { \ |
| 309 SECURITY_DCHECK(referencePredicate); \ | 300 SECURITY_DCHECK(referencePredicate); \ |
| 310 return static_cast<const thisType&>(argumentName); \ | 301 return static_cast<const thisType&>(argumentName); \ |
| 311 } \ | 302 } \ |
| 312 void to##thisType(const thisType*); \ | 303 void to##thisType(const thisType*); \ |
| 313 void to##thisType(const thisType&) | 304 void to##thisType(const thisType&) |
| 314 | 305 |
| 315 #endif // WTF_Assertions_h | 306 #endif // WTF_Assertions_h |
| OLD | NEW |