2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2002 University of Virginia,
4 ** Massachusetts Institute of Technology
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.
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.
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.
20 ** For information on splint: info@splint.org
21 ** To report a bug: splint-bug@splint.org
22 ** For more information: http://www.splint.org
25 # include "splintMacros.nf"
28 void stateInfo_free (/*@only@*/ stateInfo a)
32 fileloc_free (a->loc);
37 /*@only@*/ stateInfo stateInfo_update (/*@only@*/ stateInfo old, stateInfo newinfo)
39 ** returns an stateInfo with the same value as new. May reuse the
40 ** storage of old. (i.e., same effect as copy, but more
46 old = stateInfo_copy (newinfo);
48 else if (newinfo == NULL)
55 old->loc = fileloc_update (old->loc, newinfo->loc);
56 old->ref = newinfo->ref;
57 old->ue = newinfo->ue;
63 /*@only@*/ stateInfo stateInfo_updateLoc (/*@only@*/ stateInfo old, fileloc loc)
67 old = stateInfo_makeLoc (loc);
71 old->loc = fileloc_update (old->loc, loc);
72 old->ue = uentry_undefined;
73 old->ref = sRef_undefined;
80 stateInfo_updateRefLoc (/*@only@*/ stateInfo old, /*@exposed@*/ sRef ref, fileloc loc)
84 old = stateInfo_makeRefLoc (ref, loc);
88 old->loc = fileloc_update (old->loc, loc);
89 old->ue = uentry_undefined;
96 /*@only@*/ stateInfo stateInfo_copy (stateInfo a)
104 stateInfo ret = (stateInfo) dmalloc (sizeof (*ret));
106 ret->loc = fileloc_copy (a->loc); /*< should report bug without copy! >*/
114 /*@only@*/ /*@notnull@*/ stateInfo
115 stateInfo_currentLoc (void)
117 return stateInfo_makeLoc (g_currentloc);
120 /*@only@*/ /*@notnull@*/ stateInfo
121 stateInfo_makeLoc (fileloc loc)
123 stateInfo ret = (stateInfo) dmalloc (sizeof (*ret));
125 ret->loc = fileloc_copy (loc); /* don't need to copy! */
126 ret->ue = uentry_undefined;
127 ret->ref = sRef_undefined;
133 stateInfo_makeRefLoc (/*@exposed@*/ sRef ref, fileloc loc)
135 stateInfo ret = (stateInfo) dmalloc (sizeof (*ret));
137 ret->loc = fileloc_copy (loc);
139 ret->ue = uentry_undefined;
145 stateInfo_unparse (stateInfo s)
147 if (stateInfo_isDefined (s) &&
148 fileloc_isDefined (s->loc)) {
149 return fileloc_unparse (s->loc);
151 return cstring_makeLiteral ("<no info>");
155 fileloc stateInfo_getLoc (stateInfo info)
157 if (stateInfo_isDefined (info)) {
161 return fileloc_undefined;