Beispiel #1
0
void
gcc_rich_location::add_expr (tree expr)
{
  gcc_assert (expr);

  if (CAN_HAVE_RANGE_P (expr))
    add_range (EXPR_LOCATION (expr), false);
}
static void
show_tree (tree node)
{
  if (!CAN_HAVE_RANGE_P (node))
    return;

  gcc_rich_location richloc (EXPR_LOCATION (node));
  richloc.add_expr (node);

  if (richloc.get_num_locations () < 2)
    {
      error_at (&richloc, "range not found");
      return;
    }

  enum tree_code code = TREE_CODE (node);

  location_range *range = richloc.get_range (1);
  inform (&richloc, "%s", get_tree_code_name (code));

  /* Recurse.  */
  int min_idx = 0;
  int max_idx = TREE_OPERAND_LENGTH (node);
  switch (code)
    {
    case CALL_EXPR:
      min_idx = 3;
      break;

    default:
      break;
    }

  for (int i = min_idx; i < max_idx; i++)
    show_tree (TREE_OPERAND (node, i));
}