| Index: third_party/WebKit/Source/wtf/Assertions.h
|
| diff --git a/third_party/WebKit/Source/wtf/Assertions.h b/third_party/WebKit/Source/wtf/Assertions.h
|
| index 438e7aa9de8955502c9d843da3f64aa02f6404fc..093919688a7f99237d2b196a836110c01d805d13 100644
|
| --- a/third_party/WebKit/Source/wtf/Assertions.h
|
| +++ b/third_party/WebKit/Source/wtf/Assertions.h
|
| @@ -290,26 +290,52 @@ class WTF_EXPORT ScopedLogger {
|
| }
|
|
|
| // DEFINE_TYPE_CASTS
|
| -// Provide static_cast<> wrappers with SECURITY_DCHECK for bad casts.
|
| -#define DEFINE_TYPE_CASTS(thisType, argumentType, argumentName, \
|
| - pointerPredicate, referencePredicate) \
|
| - inline thisType* to##thisType(argumentType* argumentName) { \
|
| - SECURITY_DCHECK(!argumentName || (pointerPredicate)); \
|
| - return static_cast<thisType*>(argumentName); \
|
| - } \
|
| - inline const thisType* to##thisType(const argumentType* argumentName) { \
|
| - SECURITY_DCHECK(!argumentName || (pointerPredicate)); \
|
| - return static_cast<const thisType*>(argumentName); \
|
| - } \
|
| - inline thisType& to##thisType(argumentType& argumentName) { \
|
| - SECURITY_DCHECK(referencePredicate); \
|
| - return static_cast<thisType&>(argumentName); \
|
| - } \
|
| - inline const thisType& to##thisType(const argumentType& argumentName) { \
|
| - SECURITY_DCHECK(referencePredicate); \
|
| - return static_cast<const thisType&>(argumentName); \
|
| - } \
|
| - void to##thisType(const thisType*); \
|
| - void to##thisType(const thisType&)
|
| +//
|
| +// toType() functions are static_cast<> wrappers with SECURITY_DCHECK. It's
|
| +// helpful to find bad casts.
|
| +//
|
| +// toTypeOrDie() has a runtime type check, and it crashes if the specified
|
| +// object is not an instance of the destination type. It is used if
|
| +// * it's hard to prevent from passing unexpected objects,
|
| +// * proceeding with the following code doesn't make sense, and
|
| +// * cost of runtime type check is acceptable.
|
| +#define DEFINE_TYPE_CASTS(thisType, argumentType, argument, pointerPredicate, \
|
| + referencePredicate) \
|
| + inline thisType* to##thisType(argumentType* argument) { \
|
| + SECURITY_DCHECK(!argument || (pointerPredicate)); \
|
| + return static_cast<thisType*>(argument); \
|
| + } \
|
| + inline const thisType* to##thisType(const argumentType* argument) { \
|
| + SECURITY_DCHECK(!argument || (pointerPredicate)); \
|
| + return static_cast<const thisType*>(argument); \
|
| + } \
|
| + inline thisType& to##thisType(argumentType& argument) { \
|
| + SECURITY_DCHECK(referencePredicate); \
|
| + return static_cast<thisType&>(argument); \
|
| + } \
|
| + inline const thisType& to##thisType(const argumentType& argument) { \
|
| + SECURITY_DCHECK(referencePredicate); \
|
| + return static_cast<const thisType&>(argument); \
|
| + } \
|
| + void to##thisType(const thisType*); \
|
| + void to##thisType(const thisType&); \
|
| + inline thisType* to##thisType##OrDie(argumentType* argument) { \
|
| + CHECK(!argument || (pointerPredicate)); \
|
| + return static_cast<thisType*>(argument); \
|
| + } \
|
| + inline const thisType* to##thisType##OrDie(const argumentType* argument) { \
|
| + CHECK(!argument || (pointerPredicate)); \
|
| + return static_cast<const thisType*>(argument); \
|
| + } \
|
| + inline thisType& to##thisType##OrDie(argumentType& argument) { \
|
| + CHECK(referencePredicate); \
|
| + return static_cast<thisType&>(argument); \
|
| + } \
|
| + inline const thisType& to##thisType##OrDie(const argumentType& argument) { \
|
| + CHECK(referencePredicate); \
|
| + return static_cast<const thisType&>(argument); \
|
| + } \
|
| + void to##thisType##OrDie(const thisType*); \
|
| + void to##thisType##OrDie(const thisType&)
|
|
|
| #endif // WTF_Assertions_h
|
|
|