extra: handle "if (a & 0x1)" conditions
[smatch.git] / test-parsing.c
blob0a0b1d448183464180e95a7328da5ed6d74cfaf6
1 /*
2 * Example trivial client program that uses the sparse library
3 * to tokenize, preprocess and parse a C file, and prints out
4 * the results.
6 * Copyright (C) 2003 Transmeta Corp.
7 * 2003 Linus Torvalds
9 * Licensed under the Open Software License version 1.1
11 #include <stdarg.h>
12 #include <stdlib.h>
13 #include <stdio.h>
14 #include <string.h>
15 #include <ctype.h>
16 #include <unistd.h>
17 #include <fcntl.h>
19 #include "lib.h"
20 #include "allocate.h"
21 #include "token.h"
22 #include "parse.h"
23 #include "symbol.h"
24 #include "expression.h"
26 static void clean_up_symbols(struct symbol_list *list)
28 struct symbol *sym;
30 FOR_EACH_PTR(list, sym) {
31 expand_symbol(sym);
32 } END_FOR_EACH_PTR(sym);
35 int main(int argc, char **argv)
37 struct symbol_list * list;
38 struct string_list * filelist = NULL;
39 char *file;
41 list = sparse_initialize(argc, argv, &filelist);
43 // Simplification
44 clean_up_symbols(list);
46 #if 1
47 show_symbol_list(list, "\n\n");
48 printf("\n\n");
49 #endif
51 FOR_EACH_PTR_NOTAG(filelist, file) {
52 list = sparse(file);
54 // Simplification
55 clean_up_symbols(list);
57 #if 1
58 // Show the end result.
59 show_symbol_list(list, "\n\n");
60 printf("\n\n");
61 #endif
62 } END_FOR_EACH_PTR_NOTAG(file);
64 #if 0
65 // And show the allocation statistics
66 show_ident_alloc();
67 show_token_alloc();
68 show_symbol_alloc();
69 show_expression_alloc();
70 show_statement_alloc();
71 show_string_alloc();
72 show_bytes_alloc();
73 #endif
74 return 0;