]> andersk Git - splint.git/blame - src/Headers/usymtab.h
Testing CVS setup. Changed src/Makefile.am to reflect correct number of
[splint.git] / src / Headers / usymtab.h
CommitLineData
885824d3 1/*
c0de361f 2** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2003.
885824d3 3** See ../LICENSE for license information.
4*/
5/*
6** usymtab.h
7*/
8
9# ifndef USYMTAB_H
10# define USYMTAB_H
11
12/*@constant null usymtab GLOBAL_ENV; @*/
13# define GLOBAL_ENV usymtab_undefined
14
15typedef enum {
16 US_GLOBAL,
17 US_NORMAL,
18 US_TBRANCH, US_FBRANCH,
19 US_CBRANCH, US_SWITCH
20} uskind;
21
28bf4b0b 22typedef struct { int level; int index; } *refentry;
885824d3 23typedef /*@only@*/ refentry o_refentry;
24typedef o_refentry *refTable;
25
28bf4b0b 26struct s_usymtab
885824d3 27{
28 uskind kind;
29 int nentries;
30 int nspace;
31 int lexlevel;
32 bool mustBreak;
33 exitkind exitCode;
34 /*@reldef@*/ /*@only@*/ o_uentry *entries;
28bf4b0b 35 /*@null@*/ /*@only@*/ cstringTable htable; /* for the global environment */
885824d3 36 /*@null@*/ /*@only@*/ refTable reftable; /* for branched environments */
37 /*@only@*/ guardSet guards; /* guarded references (not null) */
38 aliasTable aliases;
39 /*@owned@*/ usymtab env;
40} ;
41
42/*
43** rep invariant:
44**
45** (left as exercise to reader) ;)
46*/
47
48extern void usymtab_printTypes (void)
49 /*@globals internalState@*/
80489f0a 50 /*@modifies g_warningstream@*/ ;
885824d3 51
52extern void usymtab_setMustBreak (void) /*@modifies internalState@*/ ;
53
54extern bool usymtab_inGlobalScope (void) /*@globals internalState@*/ ;
55extern bool usymtab_inFunctionScope (void) /*@globals internalState@*/ ;
56extern bool usymtab_inFileScope (void) /*@globals internalState@*/ ;
57extern void usymtab_checkFinalScope (bool p_isReturn)
58 /*@globals internalState@*/
80489f0a 59 /*@modifies *g_warningstream@*/ ;
885824d3 60
61extern void usymtab_allUsed (void)
62 /*@globals internalState@*/
80489f0a 63 /*@modifies *g_warningstream@*/ ;
885824d3 64
65extern void usymtab_allDefined (void)
66 /*@globals internalState@*/
80489f0a 67 /*@modifies *g_warningstream@*/ ;
885824d3 68
69extern void usymtab_prepareDump (void)
70 /*@modifies internalState@*/ ;
71
72extern void usymtab_dump (FILE *p_fout)
73 /*@globals internalState@*/
74 /*@modifies *p_fout@*/ ;
75
76
77extern void usymtab_load (FILE *p_f) /*@modifies p_f, internalState@*/ ;
78
79extern /*@exposed@*/ /*@dependent@*/ uentry
80 usymtab_getRefQuiet (int p_level, usymId p_index)
81 /*@globals internalState@*/ ;
82
83extern void usymtab_printLocal (void)
84 /*@globals internalState@*/
85 /*@modifies stdout@*/ ;
86
87extern /*@exposed@*/ /*@dependent@*/ uentry usymtab_getParam (int p_paramno)
88 /*@globals internalState@*/;
89extern void usymtab_free (void) /*@modifies internalState@*/ ;
90extern bool usymtab_inDeepScope (void) /*@globals internalState@*/ ;
91
92extern /*@exposed@*/ uentry usymtab_lookupExpose (cstring p_k)
93 /*@globals internalState@*/ ;
28bf4b0b 94
885824d3 95extern /*@observer@*/ uentry usymtab_lookup (cstring p_k)
96 /*@globals internalState@*/ ;
28bf4b0b 97
885824d3 98# define usymtab_lookup(s) (usymtab_lookupExpose (s))
99
100extern /*@observer@*/ uentry usymtab_lookupGlob (cstring p_k)
101 /*@globals internalState@*/ ;
102extern /*@exposed@*/ uentry usymtab_lookupExposeGlob (cstring p_k)
103 /*@globals internalState@*/ ;
104extern /*@observer@*/ uentry usymtab_lookupUnionTag (cstring p_k)
105 /*@globals internalState@*/ ;
106extern /*@observer@*/ uentry usymtab_lookupStructTag (cstring p_k)
107 /*@globals internalState@*/ ;
108extern /*@observer@*/ uentry usymtab_lookupEither (cstring p_k)
109 /*@globals internalState@*/ ;
110
885824d3 111extern ctype usymtab_lookupType (cstring p_k)
112 /*@globals internalState@*/ ;
885824d3 113
28bf4b0b 114extern bool usymtab_isDefinitelyNull (sRef p_s)
885824d3 115 /*@globals internalState@*/ ;
28bf4b0b 116extern bool usymtab_isDefinitelyNullDeep (sRef p_s)
885824d3 117 /*@globals internalState@*/ ;
118
885824d3 119extern usymId usymtab_supExposedTypeEntry (/*@only@*/ uentry p_e, bool p_dodef)
120 /*@modifies internalState, p_e@*/ ;
885824d3 121
122extern ctype usymtab_supTypeEntry (/*@only@*/ uentry p_e)
123 /*@modifies internalState, p_e@*/ ;
124
125extern /*@exposed@*/ uentry usymtab_supReturnTypeEntry (/*@only@*/ uentry p_e)
126 /*@modifies internalState@*/ ;
127
128extern /*@observer@*/ uentry usymtab_lookupSafe (cstring p_k)
129 /*@globals internalState@*/ ;
130
131extern /*@observer@*/ uentry usymtab_getGlobalEntry (usymId p_uid)
132 /*@globals internalState@*/ ;
133
134extern bool usymtab_exists (cstring p_k)
135 /*@globals internalState@*/ ;
136
885824d3 137extern bool usymtab_existsVar (cstring p_k)
138 /*@globals internalState@*/ ;
885824d3 139
140extern bool usymtab_existsGlob (cstring p_k)
141 /*@globals internalState@*/ ;
142
143extern bool usymtab_existsType (cstring p_k)
144 /*@globals internalState@*/ ;
145
885824d3 146extern bool usymtab_existsEither (cstring p_k)
147 /*@globals internalState@*/ ;
885824d3 148
149extern bool usymtab_existsTypeEither (cstring p_k)
150 /*@globals internalState@*/ ;
151
152extern usymId usymtab_getId (cstring p_k) /*@globals internalState@*/ ;
153extern usymId usymtab_getTypeId (cstring p_k) /*@globals internalState@*/ ;
154
155extern void usymtab_supEntry (/*@only@*/ uentry p_e)
156 /*@modifies internalState, p_e@*/ ;
157
885824d3 158extern void usymtab_replaceEntry (/*@only@*/ uentry p_s)
159 /*@modifies internalState, p_s@*/ ;
885824d3 160
161extern void usymtab_supEntrySref (/*@only@*/ uentry p_e)
162 /*@modifies internalState, p_e@*/ ;
163
164extern void usymtab_supGlobalEntry (/*@only@*/ uentry p_e)
165 /*@modifies internalState@*/ ;
166
167extern void usymtab_addGlobalEntry (/*@only@*/ uentry p_e)
168 /*@modifies internalState, p_e@*/ ;
169
170extern /*@exposed@*/ uentry
171 usymtab_supEntryReturn (/*@only@*/ uentry p_e)
172 /*@modifies internalState, p_e@*/ ;
173
174extern usymId usymtab_addEntry (/*@only@*/ uentry p_e)
175 /*@modifies internalState, p_e@*/ ;
176
177extern ctype usymtab_lookupAbstractType (cstring p_k)
28bf4b0b 178 /*@globals internalState@*/ /*@modifies nothing@*/ ;
179
885824d3 180extern bool usymtab_matchForwardStruct (usymId p_u1, usymId p_u2)
28bf4b0b 181 /*@globals internalState@*/ ;
885824d3 182
183extern bool usymtab_existsEnumTag (cstring p_k)
184 /*@globals internalState@*/ ;
185extern bool usymtab_existsUnionTag (cstring p_k)
186 /*@globals internalState@*/ ;
187extern bool usymtab_existsStructTag (cstring p_k)
188 /*@globals internalState@*/ ;
189
190extern usymId usymId_fromInt (int p_i) /*@*/ ;
191# define usymId_fromInt(i) ((usymId)(i))
192
193extern bool usymId_isInvalid (usymId p_u) /*@*/ ;
194# define usymId_isInvalid(u) ((u) == USYMIDINVALID)
195
196extern bool usymId_isValid (usymId p_u) /*@*/ ;
197# define usymId_isValid(u) ((u) != USYMIDINVALID)
198
199extern bool typeId_isInvalid (typeId p_u) /*@*/ ;
200# define typeId_isInvalid(u) ((u) == typeId_invalid)
201
202extern bool typeId_isValid (typeId p_u) /*@*/ ;
203# define typeId_isValid(u) ((u) != typeId_invalid)
204
205extern bool typeId_equal (typeId p_u1, typeId p_u2) /*@*/ ;
206# define typeId_equal(u1,u2) ((u1) == (u2))
207
208extern typeId typeId_fromInt (int p_i);
209# define typeId_fromInt(i) ((typeId)(i))
210
211/*@iter usymtab_entries (sef usymtab u, yield exposed uentry el); @*/
212# define usymtab_entries(x, m_i) \
213 { int m_ind; \
214 if (usymtab_isDefined (x)) \
215 for (m_ind = 0; m_ind < (x)->nentries; m_ind++) \
216 { uentry m_i = (x)->entries[m_ind];
217
218# define end_usymtab_entries }}
219
220extern /*@unused@*/ void usymtab_displayAllUses (void)
221 /*@globals internalState@*/
80489f0a 222 /*@modifies *g_warningstream@*/ ;
885824d3 223
224extern /*@unused@*/ void usymtab_printOut (void)
225 /*@globals internalState@*/
80489f0a 226 /*@modifies *g_warningstream@*/ ;
885824d3 227
228extern /*@unused@*/ void usymtab_printAll (void)
229 /*@globals internalState@*/
80489f0a 230 /*@modifies *g_warningstream@*/ ;
885824d3 231
232extern void usymtab_enterScope (void)
233 /*@modifies internalState;@*/ ;
234extern void usymtab_enterFunctionScope (uentry p_fcn)
235 /*@modifies internalState;@*/ ;
236extern void usymtab_quietExitScope (fileloc p_loc)
237 /*@modifies internalState;@*/ ;
238extern void usymtab_exitScope (exprNode p_expr) /*@modifies internalState@*/ ;
239extern void usymtab_addGuards (guardSet p_guards) /*@modifies internalState@*/ ;
240extern void usymtab_setExitCode (exitkind p_ex) /*@modifies internalState@*/ ;
241extern void usymtab_exitFile (void) /*@modifies internalState@*/ ;
242extern void usymtab_enterFile (void) /*@modifies internalState@*/ ;
243
244extern /*@observer@*/ uentry usymtab_lookupEnumTag (cstring p_k)
245 /*@globals internalState@*/ ;
246
247extern usymId usymtab_convertId (usymId p_uid) /*@globals internalState@*/ ;
248extern void usymtab_initMod (void) /*@modifies internalState@*/ ;
6fcd0b1e 249extern void usymtab_destroyMod (void) /*@modifies internalState@*/ ;
885824d3 250extern void usymtab_initBool (void) /*@modifies internalState@*/ ;
28bf4b0b 251extern void usymtab_initGlobalMarker (void) /*@modifies internalState@*/ ;
885824d3 252
253extern void usymtab_exportHeader (void)
254 /*@modifies internalState@*/ ;
255
256extern ctype usymtab_structFieldsType (uentryList p_f)
257 /*@globals internalState@*/ ;
258
259extern ctype usymtab_unionFieldsType (uentryList p_f)
260 /*@globals internalState@*/ ;
261
262extern ctype usymtab_enumEnumNameListType (enumNameList p_f)
263 /*@globals internalState@*/ ;
264
28bf4b0b 265extern /*@exposed@*/ uentry usymtab_getTypeEntrySafe (typeId p_uid)
885824d3 266 /*@globals internalState@*/ ;
267
268extern void usymtab_popOrBranch (exprNode p_pred, exprNode p_expr)
269 /*@modifies internalState@*/ ;
270extern void usymtab_popAndBranch (exprNode p_pred, exprNode p_expr)
271 /*@modifies internalState@*/ ;
272
273extern void usymtab_trueBranch (/*@only@*/ guardSet p_guards)
274 /*@modifies internalState@*/ ;
275extern void usymtab_altBranch (/*@only@*/ guardSet p_guards)
276 /*@modifies internalState@*/ ;
277
278extern void usymtab_popTrueBranch (exprNode p_pred, exprNode p_expr, clause p_cl)
279 /*@modifies internalState@*/ ;
28bf4b0b 280
885824d3 281extern void
282 usymtab_popTrueExecBranch (exprNode p_pred, exprNode p_expr, clause p_cl)
283 /*@modifies internalState@*/ ;
284
285extern void
286 usymtab_popBranches (exprNode p_pred, exprNode p_tbranch, exprNode p_fbranch,
287 bool p_isOpt, clause p_cl)
288 /*@modifies internalState@*/ ;
289
290extern void usymtab_unguard (sRef p_s) /*@modifies internalState@*/ ;
291extern bool usymtab_isGuarded (sRef p_s) /*@globals internalState@*/ ;
80489f0a 292extern void usymtab_printGuards (void) /*@globals internalState@*/ /*@modifies *g_warningstream@*/ ;
885824d3 293extern void usymtab_quietPlainExitScope (void) /*@modifies internalState@*/ ;
294extern void usymtab_printComplete (void) /*@globals internalState@*/ /*@modifies *stdout@*/ ;
295
885824d3 296extern bool usymtab_existsGlobEither (cstring p_k) /*@globals internalState@*/ ;
885824d3 297
28bf4b0b 298extern bool usymtab_isBoolType (typeId p_uid) /*@globals internalState@*/ ;
299extern /*@only@*/ cstring usymtab_getTypeEntryName (typeId p_uid)
885824d3 300 /*@globals internalState@*/ ;
28bf4b0b 301extern /*@exposed@*/ uentry usymtab_getTypeEntry (typeId p_uid)
885824d3 302 /*@globals internalState@*/ ;
303
28bf4b0b 304extern typeId
885824d3 305 usymtab_supAbstractTypeEntry (/*@only@*/ uentry p_e, bool p_dodef)
306 /*@modifies internalState, p_e@*/ ;
307extern ctype usymtab_supForwardTypeEntry (/*@only@*/ uentry p_e)
308 /*@modifies internalState, p_e@*/ ;
309
310extern /*@exposed@*/ uentry
311 usymtab_supGlobalEntryReturn (/*@only@*/ uentry p_e)
312 /*@modifies internalState, p_e@*/ ;
313
314extern /*@exposed@*/ uentry
315 usymtab_supEntrySrefReturn (/*@only@*/ uentry p_e)
316 /*@modifies internalState, p_e@*/ ;
317
318extern int uentry_directParamNo (uentry p_ue)
319 /*@globals internalState@*/ ;
320
321extern bool usymtab_newCase (exprNode p_pred, exprNode p_last)
322 /*@modifies internalState@*/ ;
323
324extern void usymtab_switchBranch (exprNode p_s)
325 /*@modifies internalState@*/ ;
326
327extern /*@only@*/ cstring usymtab_unparseStack (void)
328 /*@globals internalState@*/ ;
329extern void usymtab_exitSwitch (exprNode p_sw, bool p_allpaths)
330 /*@modifies internalState@*/ ;
331
332extern /*@observer@*/ uentry usymtab_lookupGlobSafe (cstring p_k)
333 /*@globals internalState@*/ ;
334
335extern /*@only@*/ sRefSet usymtab_aliasedBy (sRef p_s)
336 /*@globals internalState@*/ ;
337
338extern /*@only@*/ sRefSet usymtab_canAlias (sRef p_s)
339 /*@globals internalState@*/ ;
340
341extern void usymtab_clearAlias (sRef p_s)
342 /*@modifies internalState, p_s@*/ ;
343
28bf4b0b 344extern void usymtab_addMustAlias (/*@exposed@*/ sRef p_s, /*@exposed@*/ sRef p_al)
885824d3 345 /*@modifies internalState@*/ ;
346
28bf4b0b 347extern void usymtab_addForceMustAlias (/*@exposed@*/ sRef p_s, /*@exposed@*/ sRef p_al)
885824d3 348 /*@modifies internalState@*/ ;
349
350extern /*@only@*/ cstring usymtab_unparseAliases (void)
351 /*@globals internalState@*/ ;
352
353extern /*@exposed@*/ uentry
354 usymtab_supReturnFileEntry (/*@only@*/ uentry p_e)
355 /*@modifies internalState@*/ ;
356
28bf4b0b 357extern bool usymtab_isAltDefinitelyNullDeep (sRef p_s)
885824d3 358 /*@globals internalState@*/ ;
359
360extern bool usymtab_existsReal (cstring p_k)
361 /*@globals internalState@*/ ;
362
363extern /*@only@*/ sRefSet usymtab_allAliases (sRef p_s)
364 /*@globals internalState@*/ ;
365
366extern void usymtab_exportLocal (void)
367 /*@modifies internalState@*/ ;
368
369extern void usymtab_popCaseBranch (void)
370 /*@modifies internalState@*/ ;
371
372/* special scopes */
373
374/*@constant int globScope;@*/
375# define globScope 0 /* global variables */
376
377/*@constant int fileScope;@*/
378# define fileScope 1 /* file-level static variables */
379
380/*@constant int paramsScope;@*/
381# define paramsScope 2 /* function parameters */
382
383/*@constant int functionScope;@*/
384# define functionScope 3
385
0e41eb0e 386extern /*@falsewhennull@*/ bool usymtab_isDefined (usymtab p_u) /*@*/ ;
885824d3 387
388/*@constant null usymtab usymtab_undefined; @*/
389# define usymtab_undefined ((usymtab)NULL)
390# define usymtab_isDefined(u) ((u) != usymtab_undefined)
391
392extern void usymtab_checkDistinctName (uentry p_e, int p_scope)
393 /*@globals internalState@*/
80489f0a 394 /*@modifies *g_warningstream, p_e@*/ ;
885824d3 395
28bf4b0b 396extern /*@exposed@*/ sRef usymtab_lookupGlobalMarker (void) /*@globals internalState@*/ ;
393e573f 397extern void usymtab_addReallyForceMustAlias (/*@exposed@*/ sRef p_s, /*@exposed@*/ sRef p_al) /*@modifies internalState@*/ ;
28bf4b0b 398extern int usymtab_getCurrentDepth (void) /*@globals internalState@*/ ;
399
6483a926 400# ifdef DEBUGSPLINT
401extern void usymtab_checkAllValid (void) /*@modifies g_errorstream@*/ ;
402# endif
403
885824d3 404# else
405# error "Multiple include"
406# endif
407
408
409
This page took 0.128618 seconds and 5 git commands to generate.