data_source: ignore fake assignments
[smatch.git] / lib.h
blob802719b3a980c73993e8f1f4e55d9348e3231a17
1 #ifndef LIB_H
2 #define LIB_H
4 #include <stdlib.h>
5 #include <stddef.h>
7 /*
8 * Basic helper routine descriptions for 'sparse'.
10 * Copyright (C) 2003 Transmeta Corp.
11 * 2003 Linus Torvalds
12 * 2004 Christopher Li
14 * Licensed under the Open Software License version 1.1
17 #include "compat.h"
18 #include "ptrlist.h"
20 #define DO_STRINGIFY(x) #x
21 #define STRINGIFY(x) DO_STRINGIFY(x)
23 #ifndef ARRAY_SIZE
24 #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
25 #endif
27 extern int verbose, optimize, optimize_size, preprocessing;
28 extern int die_if_error;
29 extern int repeat_phase, merge_phi_sources;
30 extern int gcc_major, gcc_minor, gcc_patchlevel;
32 extern unsigned int hexval(unsigned int c);
34 struct position {
35 unsigned int type:6,
36 stream:14,
37 newline:1,
38 whitespace:1,
39 pos:10;
40 unsigned int line:31,
41 noexpand:1;
44 struct ident;
45 struct token;
46 struct symbol;
47 struct statement;
48 struct expression;
49 struct basic_block;
50 struct entrypoint;
51 struct instruction;
52 struct multijmp;
53 struct pseudo;
55 DECLARE_PTR_LIST(symbol_list, struct symbol);
56 DECLARE_PTR_LIST(statement_list, struct statement);
57 DECLARE_PTR_LIST(expression_list, struct expression);
58 DECLARE_PTR_LIST(basic_block_list, struct basic_block);
59 DECLARE_PTR_LIST(instruction_list, struct instruction);
60 DECLARE_PTR_LIST(context_list, struct context);
61 DECLARE_PTR_LIST(multijmp_list, struct multijmp);
62 DECLARE_PTR_LIST(pseudo_list, struct pseudo);
63 DECLARE_PTR_LIST(string_list, char);
65 typedef struct pseudo *pseudo_t;
67 struct token *skip_to(struct token *, int);
68 struct token *expect(struct token *, int, const char *);
69 #ifdef __GNUC__
70 #define FORMAT_ATTR(pos) __attribute__ ((__format__ (__printf__, pos, pos+1)))
71 #define NORETURN_ATTR __attribute__ ((__noreturn__))
72 #define SENTINEL_ATTR __attribute__ ((__sentinel__))
73 #else
74 #define FORMAT_ATTR(pos)
75 #define NORETURN_ATTR
76 #define SENTINEL_ATTR
77 #endif
78 extern void die(const char *, ...) FORMAT_ATTR(1) NORETURN_ATTR;
79 extern void info(struct position, const char *, ...) FORMAT_ATTR(2);
80 extern void warning(struct position, const char *, ...) FORMAT_ATTR(2);
81 extern void sparse_error(struct position, const char *, ...) FORMAT_ATTR(2);
82 extern void error_die(struct position, const char *, ...) FORMAT_ATTR(2) NORETURN_ATTR;
83 extern void expression_error(struct expression *, const char *, ...) FORMAT_ATTR(2);
85 extern void add_pre_buffer(const char *fmt, ...) FORMAT_ATTR(1);
87 extern int preprocess_only;
89 extern int Waddress_space;
90 extern int Wbitwise;
91 extern int Wcast_to_as;
92 extern int Wcast_truncate;
93 extern int Wcontext;
94 extern int Wdecl;
95 extern int Wdefault_bitfield_sign;
96 extern int Wdesignated_init;
97 extern int Wdo_while;
98 extern int Wenum_mismatch;
99 extern int Wnon_pointer_null;
100 extern int Wold_initializer;
101 extern int Wone_bit_signed_bitfield;
102 extern int Wparen_string;
103 extern int Wptr_subtraction_blows;
104 extern int Wreturn_void;
105 extern int Wshadow;
106 extern int Wtransparent_union;
107 extern int Wtypesign;
108 extern int Wundef;
109 extern int Wuninitialized;
110 extern int Wdeclarationafterstatement;
112 extern int dbg_entry;
113 extern int dbg_dead;
115 extern void declare_builtin_functions(void);
116 extern void create_builtin_stream(void);
117 extern struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list **files);
118 extern struct symbol_list *__sparse(char *filename);
119 extern struct symbol_list *sparse_keep_tokens(char *filename);
120 extern struct symbol_list *sparse(char *filename);
122 static inline int symbol_list_size(struct symbol_list *list)
124 return ptr_list_size((struct ptr_list *)(list));
127 static inline int statement_list_size(struct statement_list *list)
129 return ptr_list_size((struct ptr_list *)(list));
132 static inline int context_list_size(struct context_list *list)
134 return ptr_list_size((struct ptr_list *)(list));
137 static inline int expression_list_size(struct expression_list *list)
139 return ptr_list_size((struct ptr_list *)(list));
142 static inline int instruction_list_size(struct instruction_list *list)
144 return ptr_list_size((struct ptr_list *)(list));
147 static inline int pseudo_list_size(struct pseudo_list *list)
149 return ptr_list_size((struct ptr_list *)(list));
152 static inline int bb_list_size(struct basic_block_list *list)
154 return ptr_list_size((struct ptr_list *)(list));
157 static inline void free_instruction_list(struct instruction_list **head)
159 free_ptr_list((struct ptr_list **)head);
162 static inline struct instruction * delete_last_instruction(struct instruction_list **head)
164 return undo_ptr_list_last((struct ptr_list **)head);
167 static inline struct basic_block * delete_last_basic_block(struct basic_block_list **head)
169 return delete_ptr_list_last((struct ptr_list **)head);
172 static inline struct basic_block *first_basic_block(struct basic_block_list *head)
174 return first_ptr_list((struct ptr_list *)head);
176 static inline struct instruction *last_instruction(struct instruction_list *head)
178 return last_ptr_list((struct ptr_list *)head);
181 static inline struct instruction *first_instruction(struct instruction_list *head)
183 return first_ptr_list((struct ptr_list *)head);
186 static inline pseudo_t first_pseudo(struct pseudo_list *head)
188 return first_ptr_list((struct ptr_list *)head);
191 static inline void concat_symbol_list(struct symbol_list *from, struct symbol_list **to)
193 concat_ptr_list((struct ptr_list *)from, (struct ptr_list **)to);
196 static inline void concat_basic_block_list(struct basic_block_list *from, struct basic_block_list **to)
198 concat_ptr_list((struct ptr_list *)from, (struct ptr_list **)to);
201 static inline void concat_instruction_list(struct instruction_list *from, struct instruction_list **to)
203 concat_ptr_list((struct ptr_list *)from, (struct ptr_list **)to);
206 static inline void add_symbol(struct symbol_list **list, struct symbol *sym)
208 add_ptr_list(list, sym);
211 static inline void add_statement(struct statement_list **list, struct statement *stmt)
213 add_ptr_list(list, stmt);
216 static inline void add_expression(struct expression_list **list, struct expression *expr)
218 add_ptr_list(list, expr);
221 #define hashval(x) ((unsigned long)(x))
223 #endif