aboutsummaryrefslogtreecommitdiff
path: root/gcc/is-a.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/is-a.h')
-rw-r--r--gcc/is-a.h34
1 files changed, 17 insertions, 17 deletions
diff --git a/gcc/is-a.h b/gcc/is-a.h
index bc756b1..a14e344 100644
--- a/gcc/is-a.h
+++ b/gcc/is-a.h
@@ -34,21 +34,21 @@ bool is_a <TYPE> (pointer)
Suppose you have a symtab_node *ptr, AKA symtab_node *ptr. You can test
whether it points to a 'derived' cgraph_node as follows.
- if (is_a <cgraph_node> (ptr))
+ if (is_a <cgraph_node *> (ptr))
....
-TYPE *as_a <TYPE> (pointer)
+TYPE as_a <TYPE> (pointer)
- Converts pointer to a TYPE*.
+ Converts pointer to a TYPE.
You can just assume that it is such a node.
- do_something_with (as_a <cgraph_node> *ptr);
+ do_something_with (as_a <cgraph_node *> *ptr);
-TYPE *dyn_cast <TYPE> (pointer)
+TYPE dyn_cast <TYPE> (pointer)
- Converts pointer to TYPE* if and only if "is_a <TYPE> pointer". Otherwise,
+ Converts pointer to TYPE if and only if "is_a <TYPE> pointer". Otherwise,
returns NULL. This function is essentially a checked down cast.
This functions reduce compile time and increase type safety when treating a
@@ -57,7 +57,7 @@ TYPE *dyn_cast <TYPE> (pointer)
You can test and obtain a pointer to the 'derived' type in one indivisible
operation.
- if (cgraph_node *cptr = dyn_cast <cgraph_node> (ptr))
+ if (cgraph_node *cptr = dyn_cast <cgraph_node *> (ptr))
....
As an example, the code change is from
@@ -70,7 +70,7 @@ TYPE *dyn_cast <TYPE> (pointer)
to
- if (cgraph_node *cnode = dyn_cast <cgraph_node> (node))
+ if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node))
{
....
}
@@ -88,7 +88,7 @@ TYPE *dyn_cast <TYPE> (pointer)
becomes
- varpool_node *vnode = dyn_cast <varpool_node> (node);
+ varpool_node *vnode = dyn_cast <varpool_node *> (node);
if (vnode && vnode->finalized)
varpool_analyze_node (vnode);
@@ -110,7 +110,7 @@ example,
template <>
template <>
inline bool
- is_a_helper <cgraph_node>::test (symtab_node *p)
+ is_a_helper <cgraph_node *>::test (symtab_node *p)
{
return p->type == SYMTAB_FUNCTION;
}
@@ -122,7 +122,7 @@ when needed may result in a crash. For example,
template <>
template <>
inline bool
- is_a_helper <cgraph_node>::cast (symtab_node *p)
+ is_a_helper <cgraph_node *>::cast (symtab_node *p)
{
return &p->x_function;
}
@@ -140,7 +140,7 @@ struct is_a_helper
template <typename U>
static inline bool test (U *p);
template <typename U>
- static inline T *cast (U *p);
+ static inline T cast (U *p);
};
/* Note that we deliberately do not define the 'test' member template. Not
@@ -154,10 +154,10 @@ struct is_a_helper
template <typename T>
template <typename U>
-inline T *
+inline T
is_a_helper <T>::cast (U *p)
{
- return reinterpret_cast <T *> (p);
+ return reinterpret_cast <T> (p);
}
@@ -178,7 +178,7 @@ is_a (U *p)
discussion above for when to use this function. */
template <typename T, typename U>
-inline T *
+inline T
as_a (U *p)
{
gcc_checking_assert (is_a <T> (p));
@@ -189,13 +189,13 @@ as_a (U *p)
the discussion above for when to use this function. */
template <typename T, typename U>
-inline T *
+inline T
dyn_cast (U *p)
{
if (is_a <T> (p))
return is_a_helper <T>::cast (p);
else
- return static_cast <T *> (0);
+ return static_cast <T> (0);
}
#endif /* GCC_IS_A_H */