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

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

Issue 805073002: just use c++ static_assert everywhere (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | Source/wtf/Compiler.h » ('j') | Source/wtf/Compiler.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 #define ASSERT_ARG(argName, assertion) do \ 285 #define ASSERT_ARG(argName, assertion) do \
286 if (!(assertion)) { \ 286 if (!(assertion)) { \
287 WTFReportArgumentAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTIO N, #argName, #assertion); \ 287 WTFReportArgumentAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTIO N, #argName, #assertion); \
288 CRASH(); \ 288 CRASH(); \
289 } \ 289 } \
290 while (0) 290 while (0)
291 291
292 #endif 292 #endif
293 293
294 /* COMPILE_ASSERT */ 294 /* COMPILE_ASSERT */
295 #ifndef COMPILE_ASSERT 295 #ifndef COMPILE_ASSERT // also defined in base/macros.h
296 #if COMPILER_SUPPORTS(C_STATIC_ASSERT) 296 #define COMPILE_ASSERT(exp, msg) static_assert((exp), #msg)
297 /* Unlike static_assert below, this also works in plain C code. */
298 #define COMPILE_ASSERT(exp, name) _Static_assert((exp), #name)
299 #elif COMPILER_SUPPORTS(CXX_STATIC_ASSERT)
300 #define COMPILE_ASSERT(exp, name) static_assert((exp), #name)
301 #else
302 #define COMPILE_ASSERT(exp, name) typedef int dummy##name [(exp) ? 1 : -1]
303 #endif
304 #endif 297 #endif
305 298
306 /* FATAL */ 299 /* FATAL */
307 300
308 #if FATAL_DISABLED 301 #if FATAL_DISABLED
309 #define FATAL(...) ((void)0) 302 #define FATAL(...) ((void)0)
310 #else 303 #else
311 #define FATAL(...) do { \ 304 #define FATAL(...) do { \
312 WTFReportFatalError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, __VA_ARGS__); \ 305 WTFReportFatalError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, __VA_ARGS__); \
313 CRASH(); \ 306 CRASH(); \
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } \ 398 } \
406 inline const thisType& to##thisType(const argumentType& argumentName) \ 399 inline const thisType& to##thisType(const argumentType& argumentName) \
407 { \ 400 { \
408 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ 401 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \
409 return static_cast<const thisType&>(argumentName); \ 402 return static_cast<const thisType&>(argumentName); \
410 } \ 403 } \
411 void to##thisType(const thisType*); \ 404 void to##thisType(const thisType*); \
412 void to##thisType(const thisType&) 405 void to##thisType(const thisType&)
413 406
414 #endif /* WTF_Assertions_h */ 407 #endif /* WTF_Assertions_h */
OLDNEW
« no previous file with comments | « no previous file | Source/wtf/Compiler.h » ('j') | Source/wtf/Compiler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698