[PATCH] Add -Wno-cast-truncate
[smatch.git] / compile.c
blob5c209f2b551c74fdbf6512a398eba531900ff9ea
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 *filename;
42 clean_up_symbols(sparse_initialize(argc, argv));
43 while ((filename = *argv) != NULL) {
44 struct symbol_list *list;
45 const char *basename = strrchr(filename, '/');
46 if (basename)
47 filename = basename+1;
48 list = sparse(argv);
50 // Do type evaluation and simplification
51 emit_unit_begin(filename);
52 clean_up_symbols(list);
53 emit_unit_end();
56 #if 0
57 // And show the allocation statistics
58 show_ident_alloc();
59 show_token_alloc();
60 show_symbol_alloc();
61 show_expression_alloc();
62 show_statement_alloc();
63 show_string_alloc();
64 show_bytes_alloc();
65 #endif
66 return 0;