gimple-ssa-sprintf.c: Fix comment formatting.
authorJakub Jelinek <jakub@redhat.com>
Wed, 28 Sep 2016 19:47:04 +0000 (21:47 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 28 Sep 2016 19:47:04 +0000 (21:47 +0200)
* gimple-ssa-sprintf.c: Fix comment formatting.
(format_integer): Use is_gimple_assign.
(pass_sprintf_length::handle_gimple_call): Use gimple_call_builtin_p
and gimple_call_fndecl.  Reorder case BUILT_IN_SPRINTF_CHK.  Fix up
BUILT_IN_SNPRINTF_CHK comment.  Replace "to to" with "to" in comment.
(pass_sprintf_length::execute): Use is_gimple_call.

From-SVN: r240594

gcc/ChangeLog
gcc/gimple-ssa-sprintf.c

index 4c02c9d..5de30f8 100644 (file)
@@ -1,3 +1,12 @@
+2016-09-28  Jakub Jelinek  <jakub@redhat.com>
+
+       * gimple-ssa-sprintf.c: Fix comment formatting.
+       (format_integer): Use is_gimple_assign.
+       (pass_sprintf_length::handle_gimple_call): Use gimple_call_builtin_p
+       and gimple_call_fndecl.  Reorder case BUILT_IN_SPRINTF_CHK.  Fix up
+       BUILT_IN_SNPRINTF_CHK comment.  Replace "to to" with "to" in comment.
+       (pass_sprintf_length::execute): Use is_gimple_call.
+
 2016-09-28  Wilco Dijkstra  <wdijkstr@arm.com>
 
        * gimple-fold.c (gimple_fold_builtin): After failing to fold
index 8c92ab1..0b1e478 100644 (file)
@@ -37,7 +37,7 @@ along with GCC; see the file COPYING3.  If not see
 
    The pass handles all forms standard sprintf format directives,
    including character, integer, floating point, pointer, and strings,
-   with  the standard C flags, widths, and precisions.  For integers
+   with the standard C flags, widths, and precisions.  For integers
    and strings it computes the length of output itself.  For floating
    point it uses MPFR to fornmat known constants with up and down
    rounding and uses the resulting range of output lengths.  For
@@ -464,7 +464,7 @@ struct conversion_spec
 
   /* Format conversion function that given a conversion specification
      and an argument returns the formatting result.  */
-  fmtresult  (*fmtfunc) (const conversion_spec &, tree);
+  fmtresult (*fmtfunc) (const conversion_spec &, tree);
 
   /* Return True when a the format flag CHR has been used.  */
   bool get_flag (char chr) const
@@ -1041,10 +1041,10 @@ format_integer (const conversion_spec &spec, tree arg)
        {
          /* The argument here may be the result of promoting the actual
             argument to int.  Try to determine the type of the actual
-            argument before promotion and  narrow down its range that
+            argument before promotion and narrow down its range that
             way.  */
          gimple *def = SSA_NAME_DEF_STMT (arg);
-         if (gimple_code (def) == GIMPLE_ASSIGN)
+         if (is_gimple_assign (def))
            {
              tree_code code = gimple_assign_rhs_code (def);
              if (code == NOP_EXPR)
@@ -2480,18 +2480,10 @@ pass_sprintf_length::handle_gimple_call (gimple_stmt_iterator gsi)
   call_info info = call_info ();
 
   info.callstmt = gsi_stmt (gsi);
-  info.func = gimple_call_fn (info.callstmt);
-  if (!info.func)
-    return;
-
-  if (TREE_CODE (info.func) == ADDR_EXPR)
-    info.func = TREE_OPERAND (info.func, 0);
-
-  if (TREE_CODE (info.func) != FUNCTION_DECL
-      || !DECL_BUILT_IN(info.func)
-      || DECL_BUILT_IN_CLASS (info.func) != BUILT_IN_NORMAL)
+  if (!gimple_call_builtin_p (info.callstmt, BUILT_IN_NORMAL))
     return;
 
+  info.func = gimple_call_fndecl (info.callstmt);
   info.fncode = DECL_FUNCTION_CODE (info.func);
 
   /* The size of the destination as in snprintf(dest, size, ...).  */
@@ -2518,6 +2510,14 @@ pass_sprintf_length::handle_gimple_call (gimple_stmt_iterator gsi)
       info.argidx = 2;
       break;
 
+    case BUILT_IN_SPRINTF_CHK:
+      // Signature:
+      //   __builtin___sprintf_chk (dst, ost, objsize, format, ...)
+      idx_objsize = 2;
+      idx_format = 3;
+      info.argidx = 4;
+      break;
+
     case BUILT_IN_SNPRINTF:
       // Signature:
       //   __builtin_snprintf (dst, size, format, ...)
@@ -2529,7 +2529,7 @@ pass_sprintf_length::handle_gimple_call (gimple_stmt_iterator gsi)
 
     case BUILT_IN_SNPRINTF_CHK:
       // Signature:
-      //   __builtin___sprintf_chk (dst, size, ost, objsize, format, ...)
+      //   __builtin___snprintf_chk (dst, size, ost, objsize, format, ...)
       idx_dstsize = 1;
       idx_objsize = 3;
       idx_format = 4;
@@ -2537,14 +2537,6 @@ pass_sprintf_length::handle_gimple_call (gimple_stmt_iterator gsi)
       info.bounded = true;
       break;
 
-    case BUILT_IN_SPRINTF_CHK:
-      // Signature:
-      //   __builtin___sprintf_chk (dst, ost, objsize, format, ...)
-      idx_objsize = 2;
-      idx_format = 3;
-      info.argidx = 4;
-      break;
-
     case BUILT_IN_VSNPRINTF:
       // Signature:
       //   __builtin_vsprintf (dst, size, format, va)
@@ -2587,7 +2579,7 @@ pass_sprintf_length::handle_gimple_call (gimple_stmt_iterator gsi)
 
   if (idx_dstsize == HOST_WIDE_INT_M1U)
     {
-      // For non-bounded functions like sprintf, to to determine
+      // For non-bounded functions like sprintf, to determine
       // the size of the destination from the object or pointer
       // passed to it as the first argument.
       dstsize = get_destination_size (gimple_call_arg (info.callstmt, 0));
@@ -2698,7 +2690,7 @@ pass_sprintf_length::execute (function *fun)
          /* Iterate over statements, looking for function calls.  */
          gimple *stmt = gsi_stmt (si);
 
-         if (gimple_code (stmt) == GIMPLE_CALL)
+         if (is_gimple_call (stmt))
            handle_gimple_call (si);
        }
     }