]> andersk Git - splint.git/blame - src/globSet.c
Updating to use the LEnsures and LRequires instead of the ensures requires so
[splint.git] / src / globSet.c
CommitLineData
616915dd 1/*
2** LCLint - annotation-assisted static program checker
3** Copyright (C) 1994-2000 University of Virginia,
4** Massachusetts Institute of Technology
5**
6** This program is free software; you can redistribute it and/or modify it
7** under the terms of the GNU General Public License as published by the
8** Free Software Foundation; either version 2 of the License, or (at your
9** option) any later version.
10**
11** This program is distributed in the hope that it will be useful, but
12** WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14** General Public License for more details.
15**
16** The GNU General Public License is available from http://www.gnu.org/ or
17** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18** MA 02111-1307, USA.
19**
20** For information on lclint: lclint-request@cs.virginia.edu
21** To report a bug: lclint-bug@cs.virginia.edu
22** For more information: http://lclint.cs.virginia.edu
23*/
24/*
25** globSet.c
26*/
27
28# include "lclintMacros.nf"
29# include "basic.h"
30
31globSet
32globSet_new ()
33{
34 return (globSet_undefined);
35}
36
37void
38globSet_clear (globSet g)
39{
40 sRefSet_clear (g);
41}
42
43globSet
44globSet_insert (/*@returned@*/ globSet s, sRef el)
45{
46 if (sRef_isKnown (el) && !sRef_isConst (el) && !sRef_isType (el))
47 {
48 llassertprint (sRef_isGlobal (el) || sRef_isKindSpecial (el),
49 ("el: %s", sRef_unparse (el)));
50
51 return (sRefSet_insert (s, el));
52 }
53 else
54 {
55 return s;
56 }
57}
58
59globSet
60 globSet_copy (/*@returned@*/ globSet s1, /*@exposed@*/ globSet s2)
61{
62 return (sRefSet_copy (s1, s2));
63}
64
65/*@only@*/ globSet
66globSet_newCopy (globSet s)
67{
68 return (sRefSet_newCopy (s));
69}
70
71bool
72globSet_member (globSet s, sRef el)
73{
74 return (sRefSet_member (s, el));
75}
76
77/*@exposed@*/ sRef globSet_lookup (globSet s, sRef el)
78{
79 sRefSet_allElements (s, e)
80 {
81 if (sRef_similar (e, el))
82 {
83 return e;
84 }
85 } end_sRefSet_allElements;
86
87 return sRef_undefined;
88}
89
90bool
91globSet_hasStatic (globSet s)
92{
93 sRefSet_allElements (s, el)
94 {
95 if (sRef_isFileStatic (el))
96 {
97 return TRUE;
98 }
99 } end_sRefSet_allElements;
100
101 return FALSE;
102}
103
104void
105globSet_free (/*@only@*/ globSet s)
106{
107 sRefSet_free (s);
108}
109
110/*@only@*/ cstring
111globSet_dump (globSet lset)
112{
113 cstring st = cstring_undefined;
114 bool first = TRUE;
115
116
117 sRefSet_allElements (lset, el)
118 {
119 if (!first)
120 {
121 st = cstring_appendChar (st, ',');
122 }
123 else
124 {
125 first = FALSE;
126 }
127
128 st = cstring_concatFree (st, sRef_dumpGlobal (el));
129 } end_sRefSet_allElements;
130
131 return st;
132}
133
134globSet
135globSet_undump (char **s)
136{
137 char c;
138 sRefSet sl = sRefSet_new ();
139
140 while ((c = **s) != '#' && c != '@' && c != '$' && c != '&')
141 {
142 sl = sRefSet_insert (sl, sRef_undumpGlobal (s));
143
144
145 if (**s == ',')
146 {
147 (*s)++;
148 }
149 }
150
151 return sl;
152}
153
154/*@only@*/ cstring
155globSet_unparse (globSet ll)
156{
157 return (sRefSet_unparse (ll));
158}
159
160int
161globSet_compare (globSet l1, globSet l2)
162{
163 return (sRefSet_compare (l1, l2));
164}
165
This page took 0.097651 seconds and 5 git commands to generate.