Don't optimize away casts too early.
[smatch.git] / compile.c
blob8dfe6f7184626f2c88b0515b5e8ee1eef14e65b0
1 /*
2 * Example trivial client program that uses the sparse library
3 * and x86 backend.
5 * Copyright (C) 2003 Transmeta Corp.
6 * 2003 Linus Torvalds
7 * Copyright 2003 Jeff Garzik
9 * Licensed under the Open Software License version 1.1
12 #include <stdarg.h>
13 #include <stdlib.h>
14 #include <stdio.h>
15 #include <string.h>
16 #include <ctype.h>
17 #include <unistd.h>
18 #include <fcntl.h>
20 #include "lib.h"
21 #include "allocate.h"
22 #include "token.h"
23 #include "parse.h"
24 #include "symbol.h"
25 #include "expression.h"
26 #include "compile.h"
28 static void clean_up_symbols(struct symbol_list *list)
30 struct symbol *sym;
32 FOR_EACH_PTR(list, sym) {
33 expand_symbol(sym);
34 emit_one_symbol(sym);
35 } END_FOR_EACH_PTR(sym);
38 int main(int argc, char **argv)
40 const char *basename, *filename;
41 struct symbol_list *list;
43 list = sparse(argc, argv);
45 filename = stream_name(1);
46 basename = strrchr(filename, '/');
47 if (basename)
48 filename = basename+1;
50 // Do type evaluation and simplification
51 emit_unit_begin(filename);
52 clean_up_symbols(list);
53 emit_unit_end();
55 #if 0
56 // And show the allocation statistics
57 show_ident_alloc();
58 show_token_alloc();
59 show_symbol_alloc();
60 show_expression_alloc();
61 show_statement_alloc();
62 show_string_alloc();
63 show_bytes_alloc();
64 #endif
65 return 0;