diff options
Diffstat (limited to 'gcc/is-a.h')
-rw-r--r-- | gcc/is-a.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/is-a.h b/gcc/is-a.h index b4e5279514f..2adc7409acb 100644 --- a/gcc/is-a.h +++ b/gcc/is-a.h @@ -103,6 +103,11 @@ TYPE dyn_cast <TYPE> (pointer) Note that we have converted two sets of assertions in the calls to varpool into safe and efficient use of a variable. +TYPE safe_dyn_cast <TYPE> (pointer) + + Like dyn_cast <TYPE> (pointer), except that it accepts null pointers + and returns null results for them. + If you use these functions and get a 'inline function not defined' or a 'missing symbol' error message for 'is_a_helper<....>::test', it means that @@ -222,4 +227,13 @@ dyn_cast (U *p) return static_cast <T> (0); } +/* Similar to dyn_cast, except that the pointer may be null. */ + +template <typename T, typename U> +inline T +safe_dyn_cast (U *p) +{ + return p ? dyn_cast <T> (p) : 0; +} + #endif /* GCC_IS_A_H */ |