OSDN Git Service

2007-02-15 Sandra Loosemore <sandra@codesourcery.com>
[pf3gnuchains/gcc-fork.git] / gcc / ipa-type-escape.c
index ccb6010..8c7253e 100644 (file)
@@ -1011,20 +1011,14 @@ static bool
 check_call (tree call_expr) 
 {
   int flags = call_expr_flags(call_expr);
-  tree operand_list = TREE_OPERAND (call_expr, 1);
   tree operand;
   tree callee_t = get_callee_fndecl (call_expr);
-  tree argument;
   struct cgraph_node* callee;
   enum availability avail = AVAIL_NOT_AVAILABLE;
+  call_expr_arg_iterator iter;
 
-  for (operand = operand_list;
-       operand != NULL_TREE;
-       operand = TREE_CHAIN (operand))
-    {
-      tree argument = TREE_VALUE (operand);
-      check_rhs_var (argument);
-    }
+  FOR_EACH_CALL_EXPR_ARG (operand, iter, call_expr)
+    check_rhs_var (operand);
   
   if (callee_t)
     {
@@ -1037,17 +1031,16 @@ check_call (tree call_expr)
         parameters.  */
       if (TYPE_ARG_TYPES (TREE_TYPE (callee_t)))
        {
-         operand = operand_list;
-         for (arg_type = TYPE_ARG_TYPES (TREE_TYPE (callee_t));
+         for (arg_type = TYPE_ARG_TYPES (TREE_TYPE (callee_t)),
+                operand = first_call_expr_arg (call_expr, &iter);
               arg_type && TREE_VALUE (arg_type) != void_type_node;
-              arg_type = TREE_CHAIN (arg_type))
+              arg_type = TREE_CHAIN (arg_type),
+                operand = next_call_expr_arg (&iter))
            {
              if (operand)
                {
-                 argument = TREE_VALUE (operand);
                  last_arg_type = TREE_VALUE(arg_type);
-                 check_cast (last_arg_type, argument);
-                 operand = TREE_CHAIN (operand);
+                 check_cast (last_arg_type, operand);
                }
              else 
                /* The code reaches here for some unfortunate
@@ -1061,17 +1054,16 @@ check_call (tree call_expr)
          /* FIXME - According to Geoff Keating, we should never
             have to do this; the front ends should always process
             the arg list from the TYPE_ARG_LIST. */
-         operand = operand_list;
-         for (arg_type = DECL_ARGUMENTS (callee_t); 
+         for (arg_type = DECL_ARGUMENTS (callee_t),
+                operand = first_call_expr_arg (call_expr, &iter);
               arg_type;
-              arg_type = TREE_CHAIN (arg_type))
+              arg_type = TREE_CHAIN (arg_type),
+                operand = next_call_expr_arg (&iter))
            {
              if (operand)
                {
-                 argument = TREE_VALUE (operand);
                  last_arg_type = TREE_TYPE(arg_type);
-                 check_cast (last_arg_type, argument);
-                 operand = TREE_CHAIN (operand);
+                 check_cast (last_arg_type, operand);
                } 
              else 
                /* The code reaches here for some unfortunate
@@ -1086,11 +1078,10 @@ check_call (tree call_expr)
       arg_type = last_arg_type;
       for (;
           operand != NULL_TREE;
-          operand = TREE_CHAIN (operand))
+          operand = next_call_expr_arg (&iter))
        {
-         argument = TREE_VALUE (operand);
          if (arg_type)
-           check_cast (arg_type, argument);
+           check_cast (arg_type, operand);
          else 
            {
              /* The code reaches here for some unfortunate
@@ -1098,7 +1089,7 @@ check_call (tree call_expr)
                 argument types.  Most of these functions have
                 been marked as having their parameters not
                 escape, but for the rest, the type is doomed.  */
-             tree type = get_canon_type (TREE_TYPE (argument), false, false);
+             tree type = get_canon_type (TREE_TYPE (operand), false, false);
              mark_interesting_type (type, FULL_ESCAPE);
            }
        }
@@ -1114,12 +1105,9 @@ check_call (tree call_expr)
     {
       /* If this is a direct call to an external function, mark all of
         the parameter and return types.  */
-      for (operand = operand_list;
-          operand != NULL_TREE;
-          operand = TREE_CHAIN (operand))
+      FOR_EACH_CALL_EXPR_ARG (operand, iter, call_expr)
        {
-         tree type = 
-           get_canon_type (TREE_TYPE (TREE_VALUE (operand)), false, false);
+         tree type = get_canon_type (TREE_TYPE (operand), false, false);
          mark_interesting_type (type, EXPOSED_PARAMETER);
     }
          
@@ -1257,7 +1245,14 @@ scan_for_refs (tree *tp, int *walk_subtrees, void *data)
                look_for_casts (lhs, TREE_OPERAND (rhs, 0));
                check_rhs_var (rhs);
                break;
-             case CALL_EXPR: 
+             default:
+               break;
+             }
+           break;
+         case tcc_vl_exp:
+           switch (TREE_CODE (rhs))
+             {
+             case CALL_EXPR:
                /* If this is a call to malloc, squirrel away the
                   result so we do mark the resulting cast as being
                   bad.  */