2 * Parse and linearize the tree for testing.
4 * Copyright (C) 2003 Transmeta Corp.
5 * 2003-2004 Linus Torvalds
7 * Licensed under the Open Software License version 1.1
21 #include "expression.h"
22 #include "linearize.h"
24 static void clean_up_symbol(struct symbol
*sym
, void *_parent
, int flags
)
26 check_duplicates(sym
);
29 linearize_symbol(sym
);
32 int main(int argc
, char **argv
)
35 char *filename
= NULL
, **args
;
38 // Initialize symbol stream first, so that we can add defines etc
41 create_builtin_stream();
42 add_pre_buffer("#define __CHECKER__ 1\n");
43 add_pre_buffer("extern void *__builtin_memcpy(void *, const void *, unsigned long);\n");
44 add_pre_buffer("extern void * __builtin_return_address(int);\n");
52 args
= handle_switch(arg
+1, args
);
58 // Initialize type system
61 fd
= open(filename
, O_RDONLY
);
63 die("No such file: %s", filename
);
65 // Tokenize the input stream
66 token
= tokenize(filename
, fd
, NULL
);
69 // Prepend any "include" file to the stream.
71 token
= tokenize(include
, include_fd
, token
);
73 // Prepend the initial built-in stream
74 token
= tokenize_buffer(pre_buffer
, pre_buffer_size
, token
);
76 // Pre-process the stream
77 token
= preprocess(token
);
79 // Parse the resulting C code
80 translation_unit(token
, &used_list
);
82 // Do type evaluation and simplify
83 symbol_iterate(used_list
, clean_up_symbol
, NULL
);