| 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 11 matching lines...) Expand all Loading... |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #ifndef WTF_Assertions_h | 27 #ifndef WTF_Assertions_h |
| 28 #define WTF_Assertions_h | 28 #define WTF_Assertions_h |
| 29 | 29 |
| 30 // This file uses some GCC extensions, but it should be compatible with C++ and | 30 // This file uses some GCC extensions, but it should be compatible with C++ and |
| 31 // Objective C++. | 31 // Objective C++. |
| 32 // | |
| 33 // For non-debug builds, everything is disabled by default, except for the | |
| 34 // RELEASE_ASSERT family of macros. | |
| 35 | 32 |
| 36 #include <stdarg.h> | 33 #include <stdarg.h> |
| 37 #include "base/allocator/partition_allocator/oom.h" | 34 #include "base/allocator/partition_allocator/oom.h" |
| 38 #include "base/gtest_prod_util.h" | 35 #include "base/gtest_prod_util.h" |
| 39 #include "base/logging.h" | 36 #include "base/logging.h" |
| 40 #include "platform/wtf/Compiler.h" | 37 #include "platform/wtf/Compiler.h" |
| 41 #include "platform/wtf/Noncopyable.h" | 38 #include "platform/wtf/Noncopyable.h" |
| 42 #include "platform/wtf/WTFExport.h" | 39 #include "platform/wtf/WTFExport.h" |
| 43 #include "platform/wtf/build_config.h" | 40 #include "platform/wtf/build_config.h" |
| 44 | 41 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 #define SECURITY_DCHECK(condition) \ | 159 #define SECURITY_DCHECK(condition) \ |
| 163 LOG_IF(FATAL, !(condition)) << "Security DCHECK failed: " #condition ". " | 160 LOG_IF(FATAL, !(condition)) << "Security DCHECK failed: " #condition ". " |
| 164 // A SECURITY_CHECK failure is actually not vulnerable. | 161 // A SECURITY_CHECK failure is actually not vulnerable. |
| 165 #define SECURITY_CHECK(condition) \ | 162 #define SECURITY_CHECK(condition) \ |
| 166 LOG_IF(FATAL, !(condition)) << "Security CHECK failed: " #condition ". " | 163 LOG_IF(FATAL, !(condition)) << "Security CHECK failed: " #condition ". " |
| 167 #else | 164 #else |
| 168 #define SECURITY_DCHECK(condition) ((void)0) | 165 #define SECURITY_DCHECK(condition) ((void)0) |
| 169 #define SECURITY_CHECK(condition) CHECK(condition) | 166 #define SECURITY_CHECK(condition) CHECK(condition) |
| 170 #endif | 167 #endif |
| 171 | 168 |
| 172 // RELEASE_ASSERT | |
| 173 // Use in places where failure of an assertion indicates a definite security | |
| 174 // vulnerability from which execution must not continue even in a release build. | |
| 175 // Please sure to file bugs for these failures using the security template: | |
| 176 // http://code.google.com/p/chromium/issues/entry?template=Security%20Bug | |
| 177 #if defined(ADDRESS_SANITIZER) | |
| 178 #define RELEASE_ASSERT(condition) SECURITY_CHECK(condition) | |
| 179 #else | |
| 180 #define RELEASE_ASSERT(condition) CHECK(condition) | |
| 181 #endif | |
| 182 | |
| 183 // DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES | 169 // DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES |
| 184 // Allow equality comparisons of Objects by reference or pointer, | 170 // Allow equality comparisons of Objects by reference or pointer, |
| 185 // interchangeably. This can be only used on types whose equality makes no | 171 // interchangeably. This can be only used on types whose equality makes no |
| 186 // other sense than pointer equality. | 172 // other sense than pointer equality. |
| 187 #define DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(thisType) \ | 173 #define DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(thisType) \ |
| 188 inline bool operator==(const thisType& a, const thisType& b) { \ | 174 inline bool operator==(const thisType& a, const thisType& b) { \ |
| 189 return &a == &b; \ | 175 return &a == &b; \ |
| 190 } \ | 176 } \ |
| 191 inline bool operator==(const thisType& a, const thisType* b) { \ | 177 inline bool operator==(const thisType& a, const thisType* b) { \ |
| 192 return &a == b; \ | 178 return &a == b; \ |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 return static_cast<thisType&>(argument); \ | 233 return static_cast<thisType&>(argument); \ |
| 248 } \ | 234 } \ |
| 249 inline const thisType& To##thisType##OrDie(const argumentType& argument) { \ | 235 inline const thisType& To##thisType##OrDie(const argumentType& argument) { \ |
| 250 CHECK(referencePredicate); \ | 236 CHECK(referencePredicate); \ |
| 251 return static_cast<const thisType&>(argument); \ | 237 return static_cast<const thisType&>(argument); \ |
| 252 } \ | 238 } \ |
| 253 void To##thisType##OrDie(const thisType*); \ | 239 void To##thisType##OrDie(const thisType*); \ |
| 254 void To##thisType##OrDie(const thisType&) | 240 void To##thisType##OrDie(const thisType&) |
| 255 | 241 |
| 256 #endif // WTF_Assertions_h | 242 #endif // WTF_Assertions_h |
| OLD | NEW |