| 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 28af93a08d25f87328a1a5c4eaa00b164651dfd6..4036571ed3032374465ef8e6ed929ae0edb35e62 100644
|
| --- a/third_party/WebKit/Source/wtf/Assertions.h
|
| +++ b/third_party/WebKit/Source/wtf/Assertions.h
|
| @@ -270,26 +270,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
|
|
|