On Mon, Jul 28, 2014 at 7:30 PM, David Malcolm <dmalc...@redhat.com> wrote:
> On Mon, 2014-07-28 at 02:35 +0530, Prathamesh Kulkarni wrote:
>> -  if (o->type == operand::OP_CAPTURE)
>> +  if (is_a<capture *> (o))
>>      {
>> -      capture *c = static_cast<capture *> (o);
>> -      fprintf (f, "@%s", (static_cast<capture *> (o))->where);
>> +      capture *c = as_a<capture *> (o);
>
> FWIW, if you're doing an is_a<T> followed by a new declaration with an
> as_a<T>, that can be done in one line with is-a.h as:
>
>      if (capture *c = dyn_cast <capture *> (o))
>
>
>
Thanks, fixed in this patch.

* genmatch.c (print_operand): Adjust to use dyn_cast.

Regards,
Prathamesh
Index: genmatch.c
===================================================================
--- genmatch.c	(revision 213124)
+++ genmatch.c	(working copy)
@@ -448,9 +448,8 @@ struct decision_tree
 DEBUG_FUNCTION void
 print_operand (operand *o, FILE *f = stderr, bool flattened = false)
 {
-  if (is_a<capture *> (o))
+  if (capture *c = dyn_cast<capture *> (o))
     {
-      capture *c = as_a<capture *> (o); 
       fprintf (f, "@%s", c->where);
       if (c->what && flattened == false) 
 	{
@@ -460,15 +459,14 @@ print_operand (operand *o, FILE *f = std
 	}
     }
 
-  else if (is_a<predicate *> (o))
-    fprintf (f, "%s", (as_a<predicate *> (o))->ident);
+  else if (predicate *p = dyn_cast<predicate *> (o))
+    fprintf (f, "%s", p->ident);
 
   else if (is_a<c_expr *> (o))
     fprintf (f, "c_expr");
 
-  else if (is_a<expr *> (o))
+  else if (expr *e = dyn_cast<expr *> (o))
     {
-      expr *e = as_a<expr *> (o); 
       fprintf (f, "(%s", e->operation->op->id);
 
       if (flattened == false)

Reply via email to