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

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

Issue 2640163004: Replace ENABLE(ASSERT) with DCHECK_IS_ON(). (Closed)
Patch Set: m_domTreeVersion initialization Created 3 years, 11 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
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 28 matching lines...) Expand all
39 #include "wtf/Compiler.h" 39 #include "wtf/Compiler.h"
40 #include "wtf/Noncopyable.h" 40 #include "wtf/Noncopyable.h"
41 #include "wtf/WTFExport.h" 41 #include "wtf/WTFExport.h"
42 #include "wtf/build_config.h" 42 #include "wtf/build_config.h"
43 #include <stdarg.h> 43 #include <stdarg.h>
44 44
45 #if OS(WIN) 45 #if OS(WIN)
46 #include <windows.h> 46 #include <windows.h>
47 #endif 47 #endif
48 48
49 // Users must test "#if ENABLE(ASSERT)", which helps ensure that code
50 // testing this macro has included this header.
51 #ifndef ENABLE_ASSERT
52 #define ENABLE_ASSERT DCHECK_IS_ON()
53 #endif
54
55 #ifndef LOG_DISABLED 49 #ifndef LOG_DISABLED
56 #define LOG_DISABLED !ENABLE(ASSERT) 50 #define LOG_DISABLED !DCHECK_IS_ON()
57 #endif 51 #endif
58 52
59 // These helper functions are always declared, but not necessarily always 53 // These helper functions are always declared, but not necessarily always
60 // defined if the corresponding function is disabled. 54 // defined if the corresponding function is disabled.
61 55
62 WTF_EXPORT void WTFReportAssertionFailure(const char* file, 56 WTF_EXPORT void WTFReportAssertionFailure(const char* file,
63 int line, 57 int line,
64 const char* function, 58 const char* function,
65 const char* assertion); 59 const char* assertion);
66 // WTFLogAlways() is deprecated. crbug.com/638849 60 // WTFLogAlways() is deprecated. crbug.com/638849
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 #if OS(WIN) 139 #if OS(WIN)
146 // FIXME: Change to use something other than ASSERT to avoid this conflict with 140 // FIXME: Change to use something other than ASSERT to avoid this conflict with
147 // the underlying platform. 141 // the underlying platform.
148 #undef ASSERT 142 #undef ASSERT
149 #endif 143 #endif
150 144
151 #define DCHECK_AT(assertion, file, line) \ 145 #define DCHECK_AT(assertion, file, line) \
152 LAZY_STREAM(logging::LogMessage(file, line, #assertion).stream(), \ 146 LAZY_STREAM(logging::LogMessage(file, line, #assertion).stream(), \
153 DCHECK_IS_ON() ? !(assertion) : false) 147 DCHECK_IS_ON() ? !(assertion) : false)
154 148
155 #if ENABLE(ASSERT) 149 #if DCHECK_IS_ON()
156 #define ASSERT(assertion) DCHECK(assertion) 150 #define ASSERT(assertion) DCHECK(assertion)
157 #define ASSERT_NOT_REACHED() NOTREACHED() 151 #define ASSERT_NOT_REACHED() NOTREACHED()
158 #else 152 #else
159 #define ASSERT(assertion) ((void)0) 153 #define ASSERT(assertion) ((void)0)
160 #define ASSERT_NOT_REACHED() ((void)0) 154 #define ASSERT_NOT_REACHED() ((void)0)
161 #endif 155 #endif
162 156
163 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure 157 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure
164 // that code testing this macro has included this header. 158 // that code testing this macro has included this header.
165 #if defined(ADDRESS_SANITIZER) || ENABLE(ASSERT) 159 #if defined(ADDRESS_SANITIZER) || DCHECK_IS_ON()
166 #define ENABLE_SECURITY_ASSERT 1 160 #define ENABLE_SECURITY_ASSERT 1
167 #else 161 #else
168 #define ENABLE_SECURITY_ASSERT 0 162 #define ENABLE_SECURITY_ASSERT 0
169 #endif 163 #endif
170 164
171 // SECURITY_DCHECK and SECURITY_CHECK 165 // SECURITY_DCHECK and SECURITY_CHECK
172 // Use in places where failure of the assertion indicates a possible security 166 // Use in places where failure of the assertion indicates a possible security
173 // vulnerability. Classes of these vulnerabilities include bad casts, out of 167 // vulnerability. Classes of these vulnerabilities include bad casts, out of
174 // bounds accesses, use-after-frees, etc. Please be sure to file bugs for these 168 // bounds accesses, use-after-frees, etc. Please be sure to file bugs for these
175 // failures using the security template: 169 // failures using the security template:
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 return static_cast<thisType&>(argument); \ 257 return static_cast<thisType&>(argument); \
264 } \ 258 } \
265 inline const thisType& to##thisType##OrDie(const argumentType& argument) { \ 259 inline const thisType& to##thisType##OrDie(const argumentType& argument) { \
266 CHECK(referencePredicate); \ 260 CHECK(referencePredicate); \
267 return static_cast<const thisType&>(argument); \ 261 return static_cast<const thisType&>(argument); \
268 } \ 262 } \
269 void to##thisType##OrDie(const thisType*); \ 263 void to##thisType##OrDie(const thisType*); \
270 void to##thisType##OrDie(const thisType&) 264 void to##thisType##OrDie(const thisType&)
271 265
272 #endif // WTF_Assertions_h 266 #endif // WTF_Assertions_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/weborigin/KURL.cpp ('k') | third_party/WebKit/Source/wtf/AssertionsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698