constraints: remove some dead code
[smatch.git] / smatch_flow.c
blob0b28c74eddb6c4c5c5cb2734ee1a5972e0d00482
1 /*
2 * sparse/smatch_flow.c
4 * Copyright (C) 2006,2008 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
10 #define _GNU_SOURCE 1
11 #include <unistd.h>
12 #include <stdio.h>
13 #include "token.h"
14 #include "smatch.h"
15 #include "smatch_expression_stacks.h"
16 #include "smatch_extra.h"
17 #include "smatch_slist.h"
19 int final_pass;
21 static int __smatch_lineno = 0;
23 static char *base_file;
24 static const char *filename;
25 static char *pathname;
26 static char *full_filename;
27 static char *cur_func;
28 static int line_func_start;
29 static int loop_count;
30 int __expr_stmt_count;
31 static struct expression_list *switch_expr_stack = NULL;
33 struct expression_list *big_expression_stack;
34 struct statement_list *big_statement_stack;
35 int __in_pre_condition = 0;
36 int __bail_on_rest_of_function = 0;
37 char *get_function(void) { return cur_func; }
38 int get_lineno(void) { return __smatch_lineno; }
39 int inside_loop(void) { return !!loop_count; }
40 int in_expression_statement(void) { return !!__expr_stmt_count; }
42 static void split_symlist(struct symbol_list *sym_list);
43 static void split_declaration(struct symbol_list *sym_list);
44 static void split_expr_list(struct expression_list *expr_list);
45 static void add_inline_function(struct symbol *sym);
47 int option_assume_loops = 0;
48 int option_known_conditions = 0;
49 int option_two_passes = 0;
50 struct symbol *cur_func_sym = NULL;
52 const char *get_filename(void)
54 if (option_info)
55 return base_file;
56 if (option_full_path)
57 return full_filename;
58 return filename;
61 static void set_position(struct position pos)
63 int len;
64 static int prev_stream = -1;
66 __smatch_lineno = pos.line;
68 if (pos.stream == prev_stream)
69 return;
71 filename = stream_name(pos.stream);
73 free(full_filename);
74 pathname = getcwd(NULL, 0);
75 if (pathname) {
76 len = strlen(pathname) + 1 + strlen(filename) + 1;
77 full_filename = malloc(len);
78 snprintf(full_filename, len, "%s/%s", pathname, filename);
79 } else {
80 full_filename = alloc_string(filename);
82 free(pathname);
85 static int is_inline_func(struct expression *expr)
87 if (expr->type != EXPR_SYMBOL || !expr->symbol)
88 return 0;
89 if (expr->symbol->ctype.modifiers & MOD_INLINE)
90 return 1;
91 return 0;
94 void __split_expr(struct expression *expr)
96 if (!expr)
97 return;
99 // sm_msg(" Debug expr_type %d %s", expr->type, show_special(expr->op));
101 push_expression(&big_expression_stack, expr);
102 set_position(expr->pos);
103 __pass_to_client(expr, EXPR_HOOK);
105 switch (expr->type) {
106 case EXPR_PREOP:
107 if (expr->op == '*')
108 __pass_to_client(expr, DEREF_HOOK);
109 case EXPR_POSTOP:
110 __pass_to_client(expr, OP_HOOK);
111 __split_expr(expr->unop);
112 break;
113 case EXPR_STATEMENT:
114 __expr_stmt_count++;
115 __split_stmt(expr->statement);
116 __expr_stmt_count--;
117 break;
118 case EXPR_LOGICAL:
119 case EXPR_COMPARE:
120 __pass_to_client(expr, LOGIC_HOOK);
121 __handle_logic(expr);
122 break;
123 case EXPR_BINOP:
124 __pass_to_client(expr, BINOP_HOOK);
125 case EXPR_COMMA:
126 __split_expr(expr->left);
127 __split_expr(expr->right);
128 break;
129 case EXPR_ASSIGNMENT: {
130 struct expression *tmp;
132 if (!expr->right)
133 break;
135 __pass_to_client(expr, RAW_ASSIGNMENT_HOOK);
137 /* foo = !bar() */
138 if (__handle_condition_assigns(expr))
139 break;
140 /* foo = (x < 5 ? foo : 5); */
141 if (__handle_select_assigns(expr))
142 break;
143 /* foo = ({frob(); frob(); frob(); 1;}) */
144 if (__handle_expr_statement_assigns(expr))
145 break;
147 __split_expr(expr->right);
148 __pass_to_client(expr, ASSIGNMENT_HOOK);
149 tmp = strip_expr(expr->right);
150 if (tmp->type == EXPR_CALL)
151 __pass_to_client(expr, CALL_ASSIGNMENT_HOOK);
152 if (get_macro_name(tmp->pos))
153 __pass_to_client(expr, MACRO_ASSIGNMENT_HOOK);
154 __split_expr(expr->left);
155 break;
157 case EXPR_DEREF:
158 __pass_to_client(expr, DEREF_HOOK);
159 __split_expr(expr->deref);
160 break;
161 case EXPR_SLICE:
162 __split_expr(expr->base);
163 break;
164 case EXPR_CAST:
165 case EXPR_FORCE_CAST:
166 __pass_to_client(expr, CAST_HOOK);
167 __split_expr(expr->cast_expression);
168 break;
169 case EXPR_SIZEOF:
170 /* there isn't anything to pass a client from inside a sizeof() */
171 break;
172 case EXPR_CONDITIONAL:
173 case EXPR_SELECT:
174 if (known_condition_true(expr->conditional)) {
175 __split_expr(expr->cond_true);
176 break;
178 if (known_condition_false(expr->conditional)) {
179 __split_expr(expr->cond_false);
180 break;
182 __pass_to_client(expr, SELECT_HOOK);
183 __split_whole_condition(expr->conditional);
184 __split_expr(expr->cond_true);
185 __push_true_states();
186 __use_false_states();
187 __split_expr(expr->cond_false);
188 __merge_true_states();
189 break;
190 case EXPR_CALL:
191 if (sym_name_is("__builtin_constant_p", expr->fn))
192 break;
193 split_expr_list(expr->args);
194 __split_expr(expr->fn);
195 if (is_inline_func(expr->fn))
196 add_inline_function(expr->fn->symbol);
197 __pass_to_client(expr, FUNCTION_CALL_HOOK);
198 break;
199 case EXPR_INITIALIZER:
200 split_expr_list(expr->expr_list);
201 break;
202 case EXPR_IDENTIFIER:
203 __split_expr(expr->ident_expression);
204 break;
205 case EXPR_INDEX:
206 __split_expr(expr->idx_expression);
207 break;
208 case EXPR_POS:
209 __split_expr(expr->init_expr);
210 break;
211 case EXPR_SYMBOL:
212 __pass_to_client(expr, SYM_HOOK);
213 break;
214 case EXPR_STRING:
215 __pass_to_client(expr, STRING_HOOK);
216 break;
217 default:
218 break;
220 pop_expression(&big_expression_stack);
223 static int is_forever_loop(struct statement *stmt)
225 struct expression *expr;
227 expr = strip_expr(stmt->iterator_pre_condition);
228 if (!expr)
229 expr = stmt->iterator_post_condition;
230 if (!expr) {
231 /* this is a for(;;) loop... */
232 return 1;
235 if (expr->type == EXPR_VALUE && expr->value == 1)
236 return 1;
238 return 0;
241 static int loop_num;
242 static char *get_loop_name(int num)
244 char buf[256];
246 snprintf(buf, 255, "-loop%d", num);
247 buf[255] = '\0';
248 return alloc_sname(buf);
252 * Pre Loops are while and for loops.
254 static void handle_pre_loop(struct statement *stmt)
256 int once_through; /* we go through the loop at least once */
257 struct sm_state *extra_sm = NULL;
258 int unchanged = 0;
259 char *loop_name;
260 struct state_list *slist = NULL;
261 struct sm_state *sm = NULL;
263 loop_name = get_loop_name(loop_num);
264 loop_num++;
266 __split_stmt(stmt->iterator_pre_statement);
268 once_through = implied_condition_true(stmt->iterator_pre_condition);
270 loop_count++;
271 __push_continues();
272 __push_breaks();
274 __merge_gotos(loop_name);
276 extra_sm = __extra_handle_canonical_loops(stmt, &slist);
277 __in_pre_condition++;
278 __pass_to_client(stmt, PRELOOP_HOOK);
279 __split_whole_condition(stmt->iterator_pre_condition);
280 __in_pre_condition--;
281 FOR_EACH_PTR(slist, sm) {
282 set_state(sm->owner, sm->name, sm->sym, sm->state);
283 } END_FOR_EACH_PTR(sm);
284 free_slist(&slist);
285 if (extra_sm)
286 extra_sm = get_sm_state(extra_sm->owner, extra_sm->name, extra_sm->sym);
288 if (option_assume_loops)
289 once_through = 1;
291 __split_stmt(stmt->iterator_statement);
292 __warn_on_silly_pre_loops();
293 if (is_forever_loop(stmt)) {
294 struct state_list *slist;
296 __save_gotos(loop_name);
298 __push_fake_cur_slist();
299 __split_stmt(stmt->iterator_post_statement);
300 slist = __pop_fake_cur_slist();
302 __discard_continues();
303 __discard_false_states();
304 __use_breaks();
306 if (!__path_is_null())
307 __merge_slist_into_cur(slist);
308 free_slist(&slist);
309 } else {
310 __merge_continues();
311 unchanged = __iterator_unchanged(extra_sm);
312 __split_stmt(stmt->iterator_post_statement);
313 __save_gotos(loop_name);
314 __split_whole_condition(stmt->iterator_pre_condition);
315 nullify_path();
316 __merge_false_states();
317 if (once_through)
318 __discard_false_states();
319 else
320 __merge_false_states();
322 if (extra_sm && unchanged)
323 __extra_pre_loop_hook_after(extra_sm,
324 stmt->iterator_post_statement,
325 stmt->iterator_pre_condition);
326 __merge_breaks();
328 loop_count--;
332 * Post loops are do {} while();
334 static void handle_post_loop(struct statement *stmt)
336 char *loop_name;
338 loop_name = get_loop_name(loop_num);
339 loop_num++;
340 loop_count++;
342 __push_continues();
343 __push_breaks();
344 __merge_gotos(loop_name);
345 __split_stmt(stmt->iterator_statement);
346 __merge_continues();
347 if (!is_zero(stmt->iterator_post_condition))
348 __save_gotos(loop_name);
350 if (is_forever_loop(stmt)) {
351 __use_breaks();
352 } else {
353 __split_whole_condition(stmt->iterator_post_condition);
354 __use_false_states();
355 __merge_breaks();
357 loop_count--;
360 static int empty_statement(struct statement *stmt)
362 if (!stmt)
363 return 0;
364 if (stmt->type == STMT_EXPRESSION && !stmt->expression)
365 return 1;
366 return 0;
369 static int last_stmt_on_same_line()
371 struct statement *stmt;
372 int i = 0;
374 FOR_EACH_PTR_REVERSE(big_statement_stack, stmt) {
375 if (!i++)
376 continue;
377 if (stmt->pos.line == get_lineno())
378 return 1;
379 return 0;
380 } END_FOR_EACH_PTR_REVERSE(stmt);
381 return 0;
384 static struct statement *last_stmt;
385 static int is_last_stmt(struct statement *stmt)
387 if (stmt == last_stmt)
388 return 1;
389 return 0;
392 static void print_unreached_initializers(struct symbol_list *sym_list)
394 struct symbol *sym;
396 FOR_EACH_PTR(sym_list, sym) {
397 if (sym->initializer)
398 sm_msg("info: '%s' is not actually initialized (unreached code).",
399 (sym->ident ? sym->ident->name : "this variable"));
400 } END_FOR_EACH_PTR(sym);
403 static void print_unreached(struct statement *stmt)
405 static int print = 1;
407 if (!__path_is_null()) {
408 print = 1;
409 return;
411 if (!print)
412 return;
414 switch (stmt->type) {
415 case STMT_COMPOUND: /* after a switch before a case stmt */
416 case STMT_RANGE:
417 case STMT_CASE:
418 case STMT_LABEL:
419 return;
420 case STMT_DECLARATION: /* switch (x) { int a; case foo: ... */
421 print_unreached_initializers(stmt->declaration);
422 return;
423 case STMT_RETURN: /* gcc complains if you don't have a return statement */
424 if (is_last_stmt(stmt))
425 return;
426 break;
427 case STMT_GOTO:
428 if (!option_spammy)
429 return;
430 break;
431 default:
432 break;
434 if (!option_spammy && empty_statement(stmt))
435 return;
436 sm_msg("info: ignoring unreachable code.");
437 print = 0;
440 static void split_asm_constraints(struct expression_list *expr_list)
442 struct expression *expr;
443 int state = 0;
445 FOR_EACH_PTR(expr_list, expr) {
446 switch (state) {
447 case 0: /* identifier */
448 case 1: /* constraint */
449 state++;
450 continue;
451 case 2: /* expression */
452 state = 0;
453 __split_expr(expr);
454 continue;
456 } END_FOR_EACH_PTR(expr);
459 static int is_case_val(struct statement *stmt, long long val)
461 long long case_val;
463 if (stmt->type != STMT_CASE)
464 return 0;
465 if (!stmt->case_expression) {
466 __set_default();
467 return 1;
469 if (!get_value(stmt->case_expression, &case_val))
470 return 0;
471 if (case_val == val)
472 return 1;
473 return 0;
476 static void split_known_switch(struct statement *stmt, long long val)
478 struct statement *tmp;
480 __split_expr(stmt->switch_expression);
482 push_expression(&switch_expr_stack, stmt->switch_expression);
483 __save_switch_states(top_expression(switch_expr_stack));
484 nullify_path();
485 __push_default();
486 __push_breaks();
488 stmt = stmt->switch_statement;
490 if (!last_stmt)
491 last_stmt = last_ptr_list((struct ptr_list *)stmt->stmts);
493 __push_scope_hooks();
494 FOR_EACH_PTR(stmt->stmts, tmp) {
495 __smatch_lineno = tmp->pos.line;
496 if (is_case_val(tmp, val)) {
497 __merge_switches(top_expression(switch_expr_stack),
498 stmt->case_expression);
499 __pass_case_to_client(top_expression(switch_expr_stack),
500 stmt->case_expression);
502 if (__path_is_null())
503 continue;
504 __split_stmt(tmp);
505 if (__path_is_null()) {
506 __set_default();
507 goto out;
509 } END_FOR_EACH_PTR(tmp);
510 out:
511 __call_scope_hooks();
512 if (!__pop_default())
513 __merge_switches(top_expression(switch_expr_stack),
514 NULL);
515 __discard_switches();
516 __merge_breaks();
517 pop_expression(&switch_expr_stack);
520 void __split_stmt(struct statement *stmt)
522 long long val;
524 if (!stmt)
525 return;
527 if (out_of_memory() || __bail_on_rest_of_function) {
528 static char *printed = NULL;
530 if (printed != cur_func)
531 sm_msg("Function too hairy. Giving up.");
532 final_pass = 0; /* turn off sm_msg() from here */
533 printed = cur_func;
534 return;
537 add_ptr_list(&big_statement_stack, stmt);
538 free_expression_stack(&big_expression_stack);
539 set_position(stmt->pos);
540 print_unreached(stmt);
541 __pass_to_client(stmt, STMT_HOOK);
543 switch (stmt->type) {
544 case STMT_DECLARATION:
545 split_declaration(stmt->declaration);
546 return;
547 case STMT_RETURN:
548 __split_expr(stmt->ret_value);
549 __pass_to_client(stmt->ret_value, RETURN_HOOK);
550 nullify_path();
551 return;
552 case STMT_EXPRESSION:
553 __split_expr(stmt->expression);
554 return;
555 case STMT_COMPOUND: {
556 struct statement *tmp;
558 if (!last_stmt)
559 last_stmt = last_ptr_list((struct ptr_list *)stmt->stmts);
560 __push_scope_hooks();
561 FOR_EACH_PTR(stmt->stmts, tmp) {
562 __split_stmt(tmp);
563 } END_FOR_EACH_PTR(tmp);
564 __call_scope_hooks();
565 return;
567 case STMT_IF:
568 if (known_condition_true(stmt->if_conditional)) {
569 __split_stmt(stmt->if_true);
570 return;
572 if (known_condition_false(stmt->if_conditional)) {
573 __split_stmt(stmt->if_false);
574 return;
576 if (option_known_conditions &&
577 implied_condition_true(stmt->if_conditional)) {
578 sm_info("this condition is true.");
579 __split_stmt(stmt->if_true);
580 return;
582 if (option_known_conditions &&
583 implied_condition_false(stmt->if_conditional)) {
584 sm_info("this condition is false.");
585 __split_stmt(stmt->if_false);
586 return;
588 __split_whole_condition(stmt->if_conditional);
589 __split_stmt(stmt->if_true);
590 if (empty_statement(stmt->if_true) &&
591 last_stmt_on_same_line() &&
592 !get_macro_name(stmt->if_true->pos))
593 sm_msg("warn: if();");
594 __push_true_states();
595 __use_false_states();
596 __split_stmt(stmt->if_false);
597 __merge_true_states();
598 return;
599 case STMT_ITERATOR:
600 if (stmt->iterator_pre_condition)
601 handle_pre_loop(stmt);
602 else if (stmt->iterator_post_condition)
603 handle_post_loop(stmt);
604 else {
605 // these are for(;;) type loops.
606 handle_pre_loop(stmt);
608 return;
609 case STMT_SWITCH:
610 if (get_value(stmt->switch_expression, &val)) {
611 split_known_switch(stmt, val);
612 return;
614 __split_expr(stmt->switch_expression);
615 push_expression(&switch_expr_stack, stmt->switch_expression);
616 __save_switch_states(top_expression(switch_expr_stack));
617 nullify_path();
618 __push_default();
619 __push_breaks();
620 __split_stmt(stmt->switch_statement);
621 if (!__pop_default())
622 __merge_switches(top_expression(switch_expr_stack),
623 NULL);
624 __discard_switches();
625 __merge_breaks();
626 pop_expression(&switch_expr_stack);
627 return;
628 case STMT_CASE:
629 __merge_switches(top_expression(switch_expr_stack),
630 stmt->case_expression);
631 __pass_case_to_client(top_expression(switch_expr_stack),
632 stmt->case_expression);
633 if (!stmt->case_expression)
634 __set_default();
635 __split_expr(stmt->case_expression);
636 __split_expr(stmt->case_to);
637 __split_stmt(stmt->case_statement);
638 return;
639 case STMT_LABEL:
640 if (stmt->label_identifier &&
641 stmt->label_identifier->type == SYM_LABEL &&
642 stmt->label_identifier->ident) {
643 loop_count = 1000000;
644 __merge_gotos(stmt->label_identifier->ident->name);
646 __split_stmt(stmt->label_statement);
647 return;
648 case STMT_GOTO:
649 __split_expr(stmt->goto_expression);
650 if (stmt->goto_label && stmt->goto_label->type == SYM_NODE) {
651 if (!strcmp(stmt->goto_label->ident->name, "break")) {
652 __process_breaks();
653 } else if (!strcmp(stmt->goto_label->ident->name,
654 "continue")) {
655 __process_continues();
657 } else if (stmt->goto_label &&
658 stmt->goto_label->type == SYM_LABEL &&
659 stmt->goto_label->ident) {
660 __save_gotos(stmt->goto_label->ident->name);
662 nullify_path();
663 return;
664 case STMT_NONE:
665 return;
666 case STMT_ASM:
667 __pass_to_client(stmt, ASM_HOOK);
668 __split_expr(stmt->asm_string);
669 split_asm_constraints(stmt->asm_outputs);
670 split_asm_constraints(stmt->asm_inputs);
671 split_asm_constraints(stmt->asm_clobbers);
672 return;
673 case STMT_CONTEXT:
674 return;
675 case STMT_RANGE:
676 __split_expr(stmt->range_expression);
677 __split_expr(stmt->range_low);
678 __split_expr(stmt->range_high);
679 return;
683 static void split_expr_list(struct expression_list *expr_list)
685 struct expression *expr;
687 FOR_EACH_PTR(expr_list, expr) {
688 __split_expr(expr);
689 } END_FOR_EACH_PTR(expr);
692 static void split_sym(struct symbol *sym)
694 if (!sym)
695 return;
696 if (!(sym->namespace & NS_SYMBOL))
697 return;
699 __split_stmt(sym->stmt);
700 __split_expr(sym->array_size);
701 split_symlist(sym->arguments);
702 split_symlist(sym->symbol_list);
703 __split_stmt(sym->inline_stmt);
704 split_symlist(sym->inline_symbol_list);
707 static void split_symlist(struct symbol_list *sym_list)
709 struct symbol *sym;
711 FOR_EACH_PTR(sym_list, sym) {
712 split_sym(sym);
713 } END_FOR_EACH_PTR(sym);
716 static struct expression *fake_assign_expr(struct symbol *sym)
718 struct expression *e_assign, *e_symbol;
720 e_assign = alloc_expression(sym->initializer->pos, EXPR_ASSIGNMENT);
721 e_symbol = alloc_expression(sym->pos, EXPR_SYMBOL);
722 e_assign->op = (int)'=';
723 e_symbol->symbol = sym;
724 e_symbol->symbol_name = sym->ident;
725 e_assign->left = e_symbol;
726 e_assign->right = sym->initializer;
727 return e_assign;
730 static void do_initializer_stuff(struct symbol *sym)
732 struct expression *assign;
734 if (!sym->initializer)
735 return;
736 assign = fake_assign_expr(sym);
737 __split_expr(assign);
740 static void split_declaration(struct symbol_list *sym_list)
742 struct symbol *sym;
744 FOR_EACH_PTR(sym_list, sym) {
745 __pass_to_client(sym, DECLARATION_HOOK);
746 do_initializer_stuff(sym);
747 split_sym(sym);
748 } END_FOR_EACH_PTR(sym);
751 static void split_function(struct symbol *sym)
753 struct symbol *base_type = get_base_type(sym);
755 cur_func_sym = sym;
756 if (base_type->stmt)
757 line_func_start = base_type->stmt->pos.line;
758 if (sym->ident)
759 cur_func = sym->ident->name;
760 __smatch_lineno = sym->pos.line;
761 last_stmt = NULL;
762 loop_count = 0;
763 sm_debug("new function: %s\n", cur_func);
764 if (option_two_passes) {
765 __unnullify_path();
766 loop_num = 0;
767 final_pass = 0;
768 __pass_to_client(sym, FUNC_DEF_HOOK);
769 __split_stmt(base_type->stmt);
770 __split_stmt(base_type->inline_stmt);
771 nullify_path();
773 __unnullify_path();
774 loop_num = 0;
775 final_pass = 1;
776 __pass_to_client(sym, FUNC_DEF_HOOK);
777 __split_stmt(base_type->stmt);
778 __split_stmt(base_type->inline_stmt);
779 __pass_to_client(sym, END_FUNC_HOOK);
780 cur_func = NULL;
781 line_func_start = 0;
782 clear_all_states();
783 free_data_info_allocs();
784 free_expression_stack(&switch_expr_stack);
785 __free_ptr_list((struct ptr_list **)&big_statement_stack);
786 __bail_on_rest_of_function = 0;
789 static struct symbol_list *inlines_called;
790 static void add_inline_function(struct symbol *sym)
792 static struct symbol_list *already_added;
793 struct symbol *tmp;
795 FOR_EACH_PTR(already_added, tmp) {
796 if (tmp == sym)
797 return;
798 } END_FOR_EACH_PTR(tmp);
800 add_ptr_list(&already_added, sym);
801 add_ptr_list(&inlines_called, sym);
804 static void process_inlines()
806 struct symbol *tmp;
808 FOR_EACH_PTR(inlines_called, tmp) {
809 split_function(tmp);
810 } END_FOR_EACH_PTR(tmp);
811 free_ptr_list(&inlines_called);
814 static void split_functions(struct symbol_list *sym_list)
816 struct symbol *sym;
818 FOR_EACH_PTR(sym_list, sym) {
819 set_position(sym->pos);
820 if (sym->type == SYM_NODE && get_base_type(sym)->type == SYM_FN) {
821 split_function(sym);
822 process_inlines();
823 } else {
824 __pass_to_client(sym, BASE_HOOK);
826 } END_FOR_EACH_PTR(sym);
827 __pass_to_client_no_data(END_FILE_HOOK);
830 void smatch(int argc, char **argv)
833 struct string_list *filelist = NULL;
834 struct symbol_list *sym_list;
836 if (argc < 2) {
837 printf("Usage: smatch [--debug] <filename.c>\n");
838 exit(1);
840 sparse_initialize(argc, argv, &filelist);
841 FOR_EACH_PTR_NOTAG(filelist, base_file) {
842 if (option_file_output) {
843 char buf[256];
845 snprintf(buf, sizeof(buf), "%s.smatch", base_file);
846 sm_outfd = fopen(buf, "w");
847 if (!sm_outfd) {
848 printf("Error: Cannot open %s\n", base_file);
849 exit(1);
852 sym_list = sparse_keep_tokens(base_file);
853 split_functions(sym_list);
854 } END_FOR_EACH_PTR_NOTAG(base_file);