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

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

Issue 2394683005: Remove ASSERT_UNUSED (Closed)
Patch Set: Created 4 years, 2 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) 180 #if COMPILER(CLANG)
181 #define NO_RETURN_DUE_TO_CRASH NO_RETURN 181 #define NO_RETURN_DUE_TO_CRASH NO_RETURN
182 #else 182 #else
183 #define NO_RETURN_DUE_TO_CRASH 183 #define NO_RETURN_DUE_TO_CRASH
184 #endif 184 #endif
185 185
186 // ASSERT, ASSERT_NOT_REACHED, ASSERT_UNUSED 186 // ASSERT and ASSERT_NOT_REACHED
187 // These macros are compiled out of release builds. 187 // These macros are compiled out of release builds.
188 // Expressions inside them are evaluated in debug builds only. 188 // Expressions inside them are evaluated in debug builds only.
189 // They are deprecated. We should use: 189 // They are deprecated. We should use:
190 // - DCHECK() for ASSERT() 190 // - DCHECK() for ASSERT()
191 // - NOTREACHED() for ASSERT_NOT_REACHED() 191 // - NOTREACHED() for ASSERT_NOT_REACHED()
192 // - DCHECK() for ASSERT_UNUSED().
193 #if OS(WIN) 192 #if OS(WIN)
194 // FIXME: Change to use something other than ASSERT to avoid this conflict with 193 // FIXME: Change to use something other than ASSERT to avoid this conflict with
195 // the underlying platform. 194 // the underlying platform.
196 #undef ASSERT 195 #undef ASSERT
197 #endif 196 #endif
198 197
199 #define DCHECK_AT(assertion, file, line) \ 198 #define DCHECK_AT(assertion, file, line) \
200 LAZY_STREAM(logging::LogMessage(file, line, #assertion).stream(), \ 199 LAZY_STREAM(logging::LogMessage(file, line, #assertion).stream(), \
201 DCHECK_IS_ON() ? !(assertion) : false) 200 DCHECK_IS_ON() ? !(assertion) : false)
202 201
203 #if ENABLE(ASSERT) 202 #if ENABLE(ASSERT)
204 203
205 #define ASSERT(assertion) \ 204 #define ASSERT(assertion) \
206 (!(assertion) ? (WTFReportAssertionFailure(__FILE__, __LINE__, \ 205 (!(assertion) ? (WTFReportAssertionFailure(__FILE__, __LINE__, \
207 WTF_PRETTY_FUNCTION, #assertion), \ 206 WTF_PRETTY_FUNCTION, #assertion), \
208 CRASH()) \ 207 CRASH()) \
209 : (void)0) 208 : (void)0)
210 209
211 #define ASSERT_NOT_REACHED() \ 210 #define ASSERT_NOT_REACHED() \
212 do { \ 211 do { \
213 WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, 0); \ 212 WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, 0); \
214 CRASH(); \ 213 CRASH(); \
215 } while (0) 214 } while (0)
216 215
217 #define ASSERT_UNUSED(variable, assertion) ASSERT(assertion)
218
219 #define NO_RETURN_DUE_TO_ASSERT NO_RETURN_DUE_TO_CRASH 216 #define NO_RETURN_DUE_TO_ASSERT NO_RETURN_DUE_TO_CRASH
220 217
221 #else 218 #else
222 219
223 #define ASSERT(assertion) ((void)0) 220 #define ASSERT(assertion) ((void)0)
224 #define ASSERT_NOT_REACHED() ((void)0) 221 #define ASSERT_NOT_REACHED() ((void)0)
225 #define NO_RETURN_DUE_TO_ASSERT 222 #define NO_RETURN_DUE_TO_ASSERT
226 223
227 #define ASSERT_UNUSED(variable, assertion) ((void)variable)
228
229 #endif 224 #endif
230 225
231 // ASSERT_WITH_SECURITY_IMPLICATION 226 // ASSERT_WITH_SECURITY_IMPLICATION
232 // It is deprecated. ASSERT_WITH_SECURITY_IMPLICATION should be replaced 227 // It is deprecated. ASSERT_WITH_SECURITY_IMPLICATION should be replaced
233 // with SECURITY_DCHECK. 228 // with SECURITY_DCHECK.
234 #ifdef ADDRESS_SANITIZER 229 #ifdef ADDRESS_SANITIZER
235 230
236 #define ASSERT_WITH_SECURITY_IMPLICATION(assertion) \ 231 #define ASSERT_WITH_SECURITY_IMPLICATION(assertion) \
237 (!(assertion) ? (WTFReportAssertionFailure(__FILE__, __LINE__, \ 232 (!(assertion) ? (WTFReportAssertionFailure(__FILE__, __LINE__, \
238 WTF_PRETTY_FUNCTION, #assertion), \ 233 WTF_PRETTY_FUNCTION, #assertion), \
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 return static_cast<thisType&>(argumentName); \ 322 return static_cast<thisType&>(argumentName); \
328 } \ 323 } \
329 inline const thisType& to##thisType(const argumentType& argumentName) { \ 324 inline const thisType& to##thisType(const argumentType& argumentName) { \
330 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ 325 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \
331 return static_cast<const thisType&>(argumentName); \ 326 return static_cast<const thisType&>(argumentName); \
332 } \ 327 } \
333 void to##thisType(const thisType*); \ 328 void to##thisType(const thisType*); \
334 void to##thisType(const thisType&) 329 void to##thisType(const thisType&)
335 330
336 #endif // WTF_Assertions_h 331 #endif // WTF_Assertions_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698