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

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

Issue 2552613002: Mere "Avoid unchecked casts in UA shadow DOM." to M56 (Closed)
Patch Set: Created 4 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 | « third_party/WebKit/Source/core/svg/SVGUseElement.cpp ('k') | no next file » | no next file with comments »
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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 return !(a == b); \ 283 return !(a == b); \
284 } \ 284 } \
285 inline bool operator!=(const thisType& a, const thisType* b) { \ 285 inline bool operator!=(const thisType& a, const thisType* b) { \
286 return !(a == b); \ 286 return !(a == b); \
287 } \ 287 } \
288 inline bool operator!=(const thisType* a, const thisType& b) { \ 288 inline bool operator!=(const thisType* a, const thisType& b) { \
289 return !(a == b); \ 289 return !(a == b); \
290 } 290 }
291 291
292 // DEFINE_TYPE_CASTS 292 // DEFINE_TYPE_CASTS
293 // Provide static_cast<> wrappers with SECURITY_DCHECK for bad casts. 293 //
294 #define DEFINE_TYPE_CASTS(thisType, argumentType, argumentName, \ 294 // toType() functions are static_cast<> wrappers with SECURITY_DCHECK. It's
295 pointerPredicate, referencePredicate) \ 295 // helpful to find bad casts.
296 inline thisType* to##thisType(argumentType* argumentName) { \ 296 //
297 SECURITY_DCHECK(!argumentName || (pointerPredicate)); \ 297 // toTypeOrDie() has a runtime type check, and it crashes if the specified
298 return static_cast<thisType*>(argumentName); \ 298 // object is not an instance of the destination type. It is used if
299 } \ 299 // * it's hard to prevent from passing unexpected objects,
300 inline const thisType* to##thisType(const argumentType* argumentName) { \ 300 // * proceeding with the following code doesn't make sense, and
301 SECURITY_DCHECK(!argumentName || (pointerPredicate)); \ 301 // * cost of runtime type check is acceptable.
302 return static_cast<const thisType*>(argumentName); \ 302 #define DEFINE_TYPE_CASTS(thisType, argumentType, argument, pointerPredicate, \
303 } \ 303 referencePredicate) \
304 inline thisType& to##thisType(argumentType& argumentName) { \ 304 inline thisType* to##thisType(argumentType* argument) { \
305 SECURITY_DCHECK(referencePredicate); \ 305 SECURITY_DCHECK(!argument || (pointerPredicate)); \
306 return static_cast<thisType&>(argumentName); \ 306 return static_cast<thisType*>(argument); \
307 } \ 307 } \
308 inline const thisType& to##thisType(const argumentType& argumentName) { \ 308 inline const thisType* to##thisType(const argumentType* argument) { \
309 SECURITY_DCHECK(referencePredicate); \ 309 SECURITY_DCHECK(!argument || (pointerPredicate)); \
310 return static_cast<const thisType&>(argumentName); \ 310 return static_cast<const thisType*>(argument); \
311 } \ 311 } \
312 void to##thisType(const thisType*); \ 312 inline thisType& to##thisType(argumentType& argument) { \
313 void to##thisType(const thisType&) 313 SECURITY_DCHECK(referencePredicate); \
314 return static_cast<thisType&>(argument); \
315 } \
316 inline const thisType& to##thisType(const argumentType& argument) { \
317 SECURITY_DCHECK(referencePredicate); \
318 return static_cast<const thisType&>(argument); \
319 } \
320 void to##thisType(const thisType*); \
321 void to##thisType(const thisType&); \
322 inline thisType* to##thisType##OrDie(argumentType* argument) { \
323 CHECK(!argument || (pointerPredicate)); \
324 return static_cast<thisType*>(argument); \
325 } \
326 inline const thisType* to##thisType##OrDie(const argumentType* argument) { \
327 CHECK(!argument || (pointerPredicate)); \
328 return static_cast<const thisType*>(argument); \
329 } \
330 inline thisType& to##thisType##OrDie(argumentType& argument) { \
331 CHECK(referencePredicate); \
332 return static_cast<thisType&>(argument); \
333 } \
334 inline const thisType& to##thisType##OrDie(const argumentType& argument) { \
335 CHECK(referencePredicate); \
336 return static_cast<const thisType&>(argument); \
337 } \
338 void to##thisType##OrDie(const thisType*); \
339 void to##thisType##OrDie(const thisType&)
314 340
315 #endif // WTF_Assertions_h 341 #endif // WTF_Assertions_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGUseElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698