Print this page
new smatch

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/smatch/src/smatch_flow.c
          +++ new/usr/src/tools/smatch/src/smatch_flow.c
↓ open down ↓ 36 lines elided ↑ open up ↑
  37   37  static char *base_file;
  38   38  static const char *filename;
  39   39  static char *pathname;
  40   40  static char *full_filename;
  41   41  static char *full_base_file;
  42   42  static char *cur_func;
  43   43  static unsigned int loop_count;
  44   44  static int last_goto_statement_handled;
  45   45  int __expr_stmt_count;
  46   46  int __in_function_def;
       47 +int __in_unmatched_hook;
  47   48  static struct expression_list *switch_expr_stack = NULL;
  48   49  static struct expression_list *post_op_stack = NULL;
  49   50  
  50   51  static struct ptr_list *backup;
  51   52  
  52   53  struct expression_list *big_expression_stack;
  53   54  struct statement_list *big_statement_stack;
  54   55  struct statement *__prev_stmt;
  55   56  struct statement *__cur_stmt;
  56   57  struct statement *__next_stmt;
↓ open down ↓ 396 lines elided ↑ open up ↑
 453  454                          break;
 454  455  
 455  456                  __split_expr(expr->right);
 456  457                  if (outside_of_function())
 457  458                          __pass_to_client(expr, GLOBAL_ASSIGNMENT_HOOK);
 458  459                  else
 459  460                          __pass_to_client(expr, ASSIGNMENT_HOOK);
 460  461  
 461  462                  __fake_struct_member_assignments(expr);
 462  463  
      464 +                /* Re-examine ->right for inlines.  See the commit message */
      465 +                right = strip_expr(expr->right);
 463  466                  if (expr->op == '=' && right->type == EXPR_CALL)
 464  467                          __pass_to_client(expr, CALL_ASSIGNMENT_HOOK);
 465  468  
 466  469                  if (get_macro_name(right->pos) &&
 467  470                      get_macro_name(expr->pos) != get_macro_name(right->pos))
 468  471                          __pass_to_client(expr, MACRO_ASSIGNMENT_HOOK);
 469  472  
 470  473                  __pass_to_client(expr, ASSIGNMENT_HOOK_AFTER);
 471  474  
 472  475                  __split_expr(expr->left);
↓ open down ↓ 47 lines elided ↑ open up ↑
 520  523                  __split_expr(expr->cond_false);
 521  524                  __merge_true_states();
 522  525                  break;
 523  526          case EXPR_CALL:
 524  527                  expr_set_parent_expr(expr->fn, expr);
 525  528  
 526  529                  if (sym_name_is("__builtin_constant_p", expr->fn))
 527  530                          break;
 528  531                  if (handle__builtin_choose_expr(expr))
 529  532                          break;
 530      -                split_expr_list(expr->args, expr);
 531  533                  __split_expr(expr->fn);
      534 +                split_expr_list(expr->args, expr);
 532  535                  if (is_inline_func(expr->fn))
 533  536                          add_inline_function(expr->fn->symbol);
 534  537                  if (inlinable(expr->fn))
 535  538                          __inline_call = 1;
 536  539                  __process_post_op_stack();
 537  540                  __pass_to_client(expr, FUNCTION_CALL_HOOK_BEFORE);
 538  541                  __pass_to_client(expr, FUNCTION_CALL_HOOK);
 539  542                  __inline_call = 0;
 540  543                  if (inlinable(expr->fn)) {
 541  544                          parse_inline(expr);
↓ open down ↓ 20 lines elided ↑ open up ↑
 562  565                  break;
 563  566          case EXPR_SYMBOL:
 564  567                  __pass_to_client(expr, SYM_HOOK);
 565  568                  break;
 566  569          case EXPR_STRING:
 567  570                  __pass_to_client(expr, STRING_HOOK);
 568  571                  break;
 569  572          default:
 570  573                  break;
 571  574          };
      575 +        __pass_to_client(expr, EXPR_HOOK_AFTER);
 572  576          pop_expression(&big_expression_stack);
 573  577  }
 574  578  
 575  579  static int is_forever_loop(struct statement *stmt)
 576  580  {
 577  581          struct expression *expr;
 578  582          sval_t sval;
 579  583  
 580  584          expr = strip_expr(stmt->iterator_pre_condition);
 581  585          if (!expr)
↓ open down ↓ 111 lines elided ↑ open up ↑
 693  697  
 694  698          loop_name = get_loop_name(loop_num);
 695  699          loop_num++;
 696  700          loop_count++;
 697  701  
 698  702          __push_continues();
 699  703          __push_breaks();
 700  704          __merge_gotos(loop_name, NULL);
 701  705          __split_stmt(stmt->iterator_statement);
 702  706          __merge_continues();
 703      -        if (!is_zero(stmt->iterator_post_condition))
      707 +        if (!expr_is_zero(stmt->iterator_post_condition))
 704  708                  __save_gotos(loop_name, NULL);
 705  709  
 706  710          if (is_forever_loop(stmt)) {
 707  711                  __use_breaks();
 708  712          } else {
 709  713                  __split_whole_condition(stmt->iterator_post_condition);
 710  714                  __use_false_states();
 711  715                  __merge_breaks();
 712  716          }
 713  717          loop_count--;
↓ open down ↓ 893 lines elided ↑ open up ↑
1607 1611          cur_func_sym = NULL;
1608 1612          cur_func = NULL;
1609 1613          free_data_info_allocs();
1610 1614          free_expression_stack(&switch_expr_stack);
1611 1615          __free_ptr_list((struct ptr_list **)&big_statement_stack);
1612 1616          __bail_on_rest_of_function = 0;
1613 1617  }
1614 1618  
1615 1619  static void save_flow_state(void)
1616 1620  {
1617      -        __add_ptr_list(&backup, INT_PTR(loop_num << 2), 0);
1618      -        __add_ptr_list(&backup, INT_PTR(loop_count << 2), 0);
1619      -        __add_ptr_list(&backup, INT_PTR(final_pass << 2), 0);
     1621 +        __add_ptr_list(&backup, INT_PTR(loop_num << 2));
     1622 +        __add_ptr_list(&backup, INT_PTR(loop_count << 2));
     1623 +        __add_ptr_list(&backup, INT_PTR(final_pass << 2));
1620 1624  
1621      -        __add_ptr_list(&backup, big_statement_stack, 0);
1622      -        __add_ptr_list(&backup, big_expression_stack, 0);
1623      -        __add_ptr_list(&backup, big_condition_stack, 0);
1624      -        __add_ptr_list(&backup, switch_expr_stack, 0);
     1625 +        __add_ptr_list(&backup, big_statement_stack);
     1626 +        __add_ptr_list(&backup, big_expression_stack);
     1627 +        __add_ptr_list(&backup, big_condition_stack);
     1628 +        __add_ptr_list(&backup, switch_expr_stack);
1625 1629  
1626      -        __add_ptr_list(&backup, cur_func_sym, 0);
     1630 +        __add_ptr_list(&backup, cur_func_sym);
1627 1631  
1628      -        __add_ptr_list(&backup, __prev_stmt, 0);
1629      -        __add_ptr_list(&backup, __cur_stmt, 0);
1630      -        __add_ptr_list(&backup, __next_stmt, 0);
1631      -
     1632 +        __add_ptr_list(&backup, __prev_stmt);
     1633 +        __add_ptr_list(&backup, __cur_stmt);
     1634 +        __add_ptr_list(&backup, __next_stmt);
1632 1635  }
1633 1636  
1634 1637  static void *pop_backup(void)
1635 1638  {
1636 1639          void *ret;
1637 1640  
1638 1641          ret = last_ptr_list(backup);
1639 1642          delete_ptr_list_last(&backup);
1640 1643          return ret;
1641 1644  }
↓ open down ↓ 300 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX